├── webrecognition ├── rootfs │ └── config │ │ └── webrecognition │ │ ├── 1.txt │ │ ├── names.txt │ │ ├── Eric.jpg │ │ ├── Angus.jpg │ │ ├── Bruce.jpg │ │ ├── Jamse.jpg │ │ ├── empty.png │ │ ├── empty512px.png │ │ └── dataset_faces.dat ├── icon.png ├── logo.png ├── CHANGELOG.md ├── Dockerfile ├── README.md └── config.json ├── img ├── upload.jpg ├── test-page.jpg ├── test-page.png ├── test_page.png ├── json-return.png ├── sample_page.jpg ├── completed-page.png ├── node-red-flow.jpg ├── chose_foto_name.jpg ├── node-red-switch.jpg ├── paypal-donation.png ├── install-image-tool.jpg ├── node-red-send-http.jpg ├── node-red-set-http-req.jpg ├── node-red-API-cam-thumbnail.jpg └── node-red-contrib-image-output.jpg ├── repository.json ├── flows.json ├── README-uk.md └── README.md /webrecognition/rootfs/config/webrecognition/1.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/names.txt: -------------------------------------------------------------------------------- 1 | Angus Bruce Eric Jamse 2 | -------------------------------------------------------------------------------- /img/upload.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/upload.jpg -------------------------------------------------------------------------------- /img/test-page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/test-page.jpg -------------------------------------------------------------------------------- /img/test-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/test-page.png -------------------------------------------------------------------------------- /img/test_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/test_page.png -------------------------------------------------------------------------------- /img/json-return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/json-return.png -------------------------------------------------------------------------------- /img/sample_page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/sample_page.jpg -------------------------------------------------------------------------------- /img/completed-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/completed-page.png -------------------------------------------------------------------------------- /img/node-red-flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-flow.jpg -------------------------------------------------------------------------------- /img/chose_foto_name.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/chose_foto_name.jpg -------------------------------------------------------------------------------- /img/node-red-switch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-switch.jpg -------------------------------------------------------------------------------- /img/paypal-donation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/paypal-donation.png -------------------------------------------------------------------------------- /webrecognition/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/icon.png -------------------------------------------------------------------------------- /webrecognition/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/logo.png -------------------------------------------------------------------------------- /img/install-image-tool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/install-image-tool.jpg -------------------------------------------------------------------------------- /img/node-red-send-http.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-send-http.jpg -------------------------------------------------------------------------------- /img/node-red-set-http-req.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-set-http-req.jpg -------------------------------------------------------------------------------- /img/node-red-API-cam-thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-API-cam-thumbnail.jpg -------------------------------------------------------------------------------- /img/node-red-contrib-image-output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/img/node-red-contrib-image-output.jpg -------------------------------------------------------------------------------- /webrecognition/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.1 4 | 5 | - Fix web_recognition addon backup size, by using "image" option in addon config 6 | -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/Eric.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/Eric.jpg -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/Angus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/Angus.jpg -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/Bruce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/Bruce.jpg -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/Jamse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/Jamse.jpg -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/empty.png -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/empty512px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/empty512px.png -------------------------------------------------------------------------------- /webrecognition/rootfs/config/webrecognition/dataset_faces.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndreiRadchenko/hassio-webrecognition/HEAD/webrecognition/rootfs/config/webrecognition/dataset_faces.dat -------------------------------------------------------------------------------- /repository.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HASSIO Add-on: Web Recognition", 3 | "url": "https://github.com/AndreiRadchenko/hassio-webrecognition", 4 | "maintainer": "Andrii Radchenko " 5 | } 6 | -------------------------------------------------------------------------------- /webrecognition/Dockerfile: -------------------------------------------------------------------------------- 1 | #ARG BUILD_ARCH 2 | #FROM andriiradchenko/web_recognition:${BUILD_ARCH} 3 | ARG BUILD_FROM 4 | FROM $BUILD_FROM 5 | 6 | LABEL \ 7 | io.hass.version="VERSION" \ 8 | io.hass.type="addon" \ 9 | io.hass.arch="aarch64|armv7|amd64" 10 | -------------------------------------------------------------------------------- /webrecognition/README.md: -------------------------------------------------------------------------------- 1 | # Home Assistant Add-on: webrecognition 2 | 3 | ![Supports amd64 Architecture][amd64-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports aarch64 Architecture][aarch64-shield] 4 | 5 | Face recognition on hassio web server. 6 | 7 | [Frigate]: https://github.com/blakeblackshear/frigate 8 | [aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 9 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 10 | [armhf-shield]: https://img.shields.io/badge/armhf-no-red.svg 11 | [armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg 12 | [i386-shield]: https://img.shields.io/badge/i386-no-red.svg 13 | -------------------------------------------------------------------------------- /webrecognition/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WebRecognition", 3 | "version": "1.1", 4 | "panel_icon": "mdi:face-recognition", 5 | "slug": "webrecognition", 6 | "description": "Face recognition local web server", 7 | "url": "https://github.com/AndreiRadchenko/hassio-webrecognition", 8 | "startup": "application", 9 | "boot": "auto", 10 | "panel_admin": true, 11 | "map": ["config:rw"], 12 | "ports": { 13 | "5001/tcp": 5001 14 | }, 15 | "ports_description": { 16 | "5001/tcp": "Web interface (Not required for Hass.io Ingress)" 17 | }, 18 | "host_network": true, 19 | "devices": [ 20 | ], 21 | "usb": false, 22 | "full_access": false, 23 | "options": {}, 24 | "schema": {}, 25 | "arch": [ 26 | "amd64", 27 | "armv7", 28 | "aarch64" 29 | ], 30 | "image": "andriiradchenko/{arch}-web_recognition" 31 | } 32 | -------------------------------------------------------------------------------- /flows.json: -------------------------------------------------------------------------------- 1 | [{"id":"fd0da101d6ae57aa","type":"tab","label":"Cam Doorbell","disabled":false,"info":"","env":[]},{"id":"74d0274a6be965e0","type":"server-state-changed","z":"fd0da101d6ae57aa","name":"Doorbell button","server":"b4fc3608.34f618","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.wicket_doorbell","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":100,"y":200,"wires":[["fd5e19fd1489d54b"],[]]},{"id":"fd5e19fd1489d54b","type":"ha-api","z":"fd0da101d6ae57aa","name":"","server":"b4fc3608.34f618","version":1,"debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\":\"camera_thumbnail\",\"entity_id\":\"camera.doorbell_sd\"}","dataType":"json","responseType":"json","outputProperties":[{"property":"doorbell","propertyType":"msg","value":"","valueType":"results"}],"x":250,"y":280,"wires":[["3902b924fc91f020","71f13115040ea88e"]]},{"id":"111ece9671f4d76d","type":"inject","z":"fd0da101d6ae57aa","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":280,"wires":[["fd5e19fd1489d54b"]]},{"id":"e95e2b555cd19247","type":"http request","z":"fd0da101d6ae57aa","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"localhost:5001/test","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":730,"y":280,"wires":[["4f63c893d5f39120"]]},{"id":"512d65cc7eed6582","type":"function","z":"fd0da101d6ae57aa","name":"Set http request","func":"msg.payload = {\n \"file\": {\n \"value\": msg.payload,\n \"options\": {\n \"filename\": \"cam_snapshot.jpg\"\n }\n }\n}\n\n//files = {'file': msg.doorbell.content}\n\n//msg.payload = msg.doorbell.content\nmsg.headers = {};\nmsg.headers['content-type'] = \"multipart/form-data\";\n\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":280,"wires":[["e95e2b555cd19247"]]},{"id":"a6ee824eb2a173b2","type":"debug","z":"fd0da101d6ae57aa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":390,"y":340,"wires":[]},{"id":"4f63c893d5f39120","type":"switch","z":"fd0da101d6ae57aa","name":"","property":"payload.faces_list","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"},{"t":"cont","v":"andrii","vt":"str"},{"t":"cont","v":"ira","vt":"str"},{"t":"cont","v":"misha","vt":"str"},{"t":"cont","v":"dima","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":150,"y":440,"wires":[["a6ee824eb2a173b2"],["3f7ebaa3607bafe6"],["73fed6d9b18d6585"],["dd297456a686f6d8"],["e2802bb0578e0567"],["2db862eb8c8bcd5b"]]},{"id":"3f7ebaa3607bafe6","type":"api-call-service","z":"fd0da101d6ae57aa","name":"Unlock wiket","server":"b4fc3608.34f618","version":3,"debugenabled":false,"service":"unlock","entityId":"lock.wicket","data":"","dataType":"json","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","service_domain":"lock","mergecontext":"","x":410,"y":380,"wires":[[]]},{"id":"73fed6d9b18d6585","type":"api-call-service","z":"fd0da101d6ae57aa","name":"Andrii at the door","server":"b4fc3608.34f618","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.doorbell_andrii"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":430,"y":440,"wires":[[]]},{"id":"dd297456a686f6d8","type":"api-call-service","z":"fd0da101d6ae57aa","name":"Ira at the door","server":"b4fc3608.34f618","version":3,"debugenabled":false,"service":"turn_on","entityId":"input_boolean.doorbell_ira","data":"","dataType":"json","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","service_domain":"input_boolean","mergecontext":"","x":420,"y":500,"wires":[[]]},{"id":"e2802bb0578e0567","type":"api-call-service","z":"fd0da101d6ae57aa","name":"Misha at the door","server":"b4fc3608.34f618","version":3,"debugenabled":false,"service":"turn_on","entityId":"input_boolean.doorbell_misha","data":"","dataType":"json","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","service_domain":"input_boolean","mergecontext":"","x":670,"y":440,"wires":[[]]},{"id":"2db862eb8c8bcd5b","type":"api-call-service","z":"fd0da101d6ae57aa","name":"Dima at the door","server":"b4fc3608.34f618","version":3,"debugenabled":false,"service":"turn_on","entityId":"input_boolean.doorbell_dima","data":"","dataType":"json","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","service_domain":"input_boolean","mergecontext":"","x":670,"y":500,"wires":[[]]},{"id":"71f13115040ea88e","type":"image","z":"fd0da101d6ae57aa","name":"","width":"200","data":"doorbell.content","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":500,"y":40,"wires":[]},{"id":"8096034b6d543514","type":"image","z":"fd0da101d6ae57aa","name":"","width":"200","data":"doorbell.content","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":740,"y":40,"wires":[]},{"id":"3902b924fc91f020","type":"jimp-image","z":"fd0da101d6ae57aa","name":"","data":"doorbell.content","dataType":"msg","ret":"buf","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":385,"y":275,"wires":[["512d65cc7eed6582","8096034b6d543514"]]},{"id":"b4fc3608.34f618","type":"server","name":"Hassio","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}] -------------------------------------------------------------------------------- /README-uk.md: -------------------------------------------------------------------------------- 1 | # hassio-webrecognition: add-on repository 2 | Hassio addon for local face recognition web server створений на основі проекту https://github.com/ageitgey/face_recognition. На даний час є докер образи для платформ armv7 amd64. Перевірено працює на raspberry 3B+, raspberry 4B (Home Assistant Operating System.), intel i3 linux Mint (Home Assistant Supervised and Home Assistant Operating System VM). У мене особисто сервер працював в HAOS RPI 4B і використовувався для розпізнавання облич камерою дзвінка на хвіртці. Було також налаштовано сповіщення через алексу хто саме подзвонив в дзвінок і автоматичне відкриття замка хвіртки в разі знайомого обличчя. Взаємодія сервера розпізнавання з home assistant реалізована в Node-Red. Flow наведено в кінці статті. 3 | 4 | ## Video illustration 5 | 6 | Коротке відео з субтитрами про дзвінок з розпізнаванням облич на НА. 7 | 8 | [![Watch on youtube](https://img.youtube.com/vi/LVS-DfC3EMw/0.jpg)](https://youtu.be/LVS-DfC3EMw) 9 | 10 | ## Installing 11 | In Hass.io, navigate to Supervisor > Add-on Store > Repositories and add 12 | `HASSIO Add-on: Web Recognition` repositorie 13 | 14 | https://github.com/AndreiRadchenko/hassio-webrecognition 15 | 16 | Файл образа важить біля 1 ГБ, тож для скачування може знадобитись 10-15 хвилин. Install and start addon. 17 | 18 | ## Local web server for realtime face recognition by http request or web interface. 19 | 20 | Після встановлення аддону в веббраузері перейдіть за адресою [Home Assistant IP]:5001 21 | Відкриється сторінка "Samples page" на якій ви можете завантажити фото знайомих облич. Для вибору фото натисніть `Select`. В сусідньому полі введіть ім'я, одним словом без пробілів. Для більш швидкого розпізнавання 22 | я рекомендую використовувати зображення SD resolution (1280x720 or 720x576 pix) and up to 60 kB size. Звичайно таке зображення дає SD потік камери. 23 | Сервер дозволяє задати до 5 "знайомих" облич з іменами. 24 | 25 | 26 | 27 | Після додавання зображень знайомих облич і редагування імен натисніть кнопку `Upload` внизу сторінки. Це призведе до запуску скрипта,який 28 | закодує обличчя в вигляді векторних масивів і запише ці масиви в файл. Процес кодування на rpi3 B+ може зайняти до 1 хв часу, в залежності від кількості облич і розміру фійлів зображень. Запуск скрипта кодування облич запускається також натисненням `Enter`. 29 | 30 | 31 | 32 | Після завершення роботи скрипту кодування відобразиться сторінка Completed. На ній натисніть кнопу `Return to the main page`. 33 | 34 | 35 | 36 | Для перевірки розпізнавання облич, натисніть на кнопку `Taste Page` вгорі сторінки задавання знайомих облич 37 | 38 | 39 | 40 | На сторінці Test Page натисніть кнопку `Select` для вибору тестового фотопортрету 41 | 42 | 43 | 44 | Обравши фото, натисніть кнопку `Upload` 45 | 46 | 47 | 48 | Якщо дотримуватись моїх рекомендацій щодо розміру зображень, то розпізнавання обличчя займає до 3 с на rpi 3 B+. Після завершення 49 | обробки сервер видасть json структуру що відобразиться браузером 50 | 51 | 52 | 53 | Для того щоб продовжити тести натисніть стрілку назад в браузері. 54 | 55 | ## hassio-webrecognition: add-on restriction 56 | 57 | Додаток має одне обмеження - фотографії облич і файл з закодованими данними облич не зберігаються після перезавантаження додатка чи Home Assistant. 58 | Для того щоб позбутися цього обмеження, прошу підтримайте мене на ByMeACoffee чи PayPal, напишіть мені, і я поділюся інструкцією, як встановити сервер розпізнавання облич в HAOS що зберігає дані облич при перезавантаженні. Ваша підтримка дуже потрібна мені і моїй родині в умовах війни в Україні. 59 | Якщо проект зацікавить велику аудіторію, я продовжу роботу по інтегріції проекта в Home assistant, наприклад додам вивід результату в mqtt, чи створю сенсор розпізнавання. 60 | 61 | Buy Me A Coffee Donate with PayPal 62 | 63 | ## Взаємодія серверу розпізнавання облич webrecognition з Home Assistant. 64 | 65 | Взаємодія серверу розпізнавання облич з Home Assistant реалізована в Node-Red. Ви можете імпортувати наведене мною flow в Node-Red. Flow "Cam Dorbell" 66 | у відповідь на подію натиснення кнопки дзвінка робить знімок з камери дзвінка і надсилає його через `html request node` серверу webrecognition. 67 | Після обробки сервером, результат розпізнавання у вигляді JSON об'єкта надходить в `html request node` і в залежності від його вмісту `Switch node` 68 | відкриває чи не відкриває хвіртку і встановлює сенсори input_boolean. Ці сенсори я використовую в Alexa rutine для оголошення голосовим помічником хто саме подзвонив в дзвінок. 69 | 70 | 71 | Node-Red Flow | Description 72 | -------------------------|------------------------- 73 | [Cam_Doorbell.json](https://github.com/AndreiRadchenko/hassio-webrecognition/blob/main/flows.json) | Flow for interaction with Home Assistant 74 | 75 | 76 | 77 | Для роботи flow вам необхідно встановити в Node-Red [node-red-contrib-image-tools](https://flows.nodered.org/node/node-red-contrib-image-tools) і 78 | [node-red-contrib-image-output](https://flows.nodered.org/node/node-red-contrib-image-output). 79 | Для цього відкрийте Node-Red -> Settings (Sandwich button) -> Manage palette. Перейдіть на вкладку Install і в полі пошуку введіть "image-tools". 80 | Встановіть цей `node`, потім так само встановіть `node` "image-output" 81 | 82 | 83 | 84 | Відредагуйте node "Doorbell button" у відповідності з сенсором що буде активувати автоматизацію. 85 | Для налаштування з якої камери потрібно робити знімок, відредагуйте node "API". Для більш швидкої обробки зображень потрібно брати SD відео потік. 86 | 87 | 88 | 89 | Якщо сервер розпізнавання webrecognition запущений на тому ж сервері що і Node-Red, node "http request" можна залишити без змін. Інакше потрібно 90 | відредагувати IP адресу сервера webrecognition в полі URL вузла "http request" : [webrecognition_IP]:5001/test 91 | 92 | 93 | 94 | Якщо сервер webrecognition повертає JSON об'єкт з пустим полем "faces_list", node "Switch" активує свій перший вихід, що просто виводить 95 | JSON об'єкт в Debug. Якщо поле "faces_list" не пусте, значить перед дверима стоїть хтось із знайомим обличчям і "Switch" передає управління на другий 96 | вихід. До нього підключений node що відчиняє хвіртку. Node "Switch" також активує вихід що містить ім'я впізнаної людини, до якого підключені nodes 97 | що активують відповідні `input_boolean` 98 | 99 | 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hassio-webrecognition: add-on repository 2 | Hassio addon for local face recognition web server based on the https://github.com/ageitgey/face_recognition progect. Currently there are docker images for armv7, aarch64 and amd64 platforms. Tested on raspberry 3B +, raspberry 4B (Home Assistant Operating System.), Intel i3 linux Mint (Home Assistant Supervised and Home Assistant Operating System VM). In my setup, server worked on HAOS RPI 4B and used for face recognition with a doorbell camera on the wicket. There is a Alexa notification, that anounse who the ring doorbell, and the automatic wicket lock open in case of a known face. The recognition server interactions with the home assistant implemented in Node-Red. Flow is given at the end of the article. 3 | 4 | ## Video illustration 5 | 6 | Short video with subtitles about the doorbell with face recognition on Home Assistant. 7 | 8 | [![Watch on youtube](https://img.youtube.com/vi/LVS-DfC3EMw/0.jpg)](https://youtu.be/LVS-DfC3EMw) 9 | 10 | ## Installing 11 | In Hass.io, navigate to Supervisor > Add-on Store > Repositories and add 12 | `HASSIO Add-on: Web Recognition` repositorie 13 | 14 | https://github.com/AndreiRadchenko/hassio-webrecognition 15 | 16 | The image file is about 1 GB, so it may take 10-15 minutes to download. Install and start addon. 17 | 18 | If you have dedicated server with docker and with amd64 architecture, you can install webrecognition server by cli command: 19 | 20 | ```cli 21 | docker run --restart always -d --name=web_recognition -p 5001:5001 andriiradchenko/web_recognition:amd64 22 | ``` 23 | 24 | ## Local web server for realtime face recognition by http request or web interface. 25 | 26 | After add-on installation open the web browser and go to [Home Assistant IP]: 5001. 27 | A "Samples page" will open, and there you can upload photos of known faces. To select a photo, press `Select`. Enter a name in the adjacent field, in one word without spaces. If you don't use all 5 photos, just delete name and leave field empty. For faster recognition I recommend using SD resolution images (1280x720 or 720x576 pix) and up to 60 kB size. Usually this image resolution is given by the SD stream of the camera. 28 | The server allows you to specify up to 5 "known" faces with names. 29 | 30 | 31 | 32 | After adding images of known faces and editing names, click the `Upload` button at the bottom of the page. This will run a script that 33 | encodes faces as vector arrays and writes these arrays to a file. The encoding process on rpi3 B + can take up to 1 minute, depending on the number of faces and the size of the image files. The face encoding script also started by pressing `Enter`. 34 | 35 | 36 | 37 | When the encoding script ends, the Completed page will display. Click the `Return to the main page` button. 38 | 39 | 40 | 41 | For the face recognition test, click on the `Test Page` button at the top of the Samples page. 42 | 43 | 44 | 45 | On the Test Page, click the `Select` button to select a test portrait. 46 | 47 | 48 | 49 | After selecting a photo, click the `Upload` button. 50 | 51 | 52 | 53 | If you follow my image size recommendations, face recognition takes up to 10 seconds at rpi 3B+ and up to 3 seconds at rpi 4B. After the processing completion 54 | server will return a json structure to be displayed by the browser. 55 | 56 | 57 | 58 | To continue the tests, click the back arrow in the browser.. 59 | 60 | ## hassio-webrecognition: add-on restriction 61 | 62 | The add-on has one limitation - photos of faces and the file with encoded face data are not saved after restarting the add-on or Home Assistant. 63 | To get rid of this limitation, please support me on ByMeACoffee or PayPal, email me and I will share instructions on how to install a face recognition server in HAOS that stores face data after rebooting. I'm and my family really need your support during the war in Ukraine. 64 | If a large audience will be interested in the project, I will continue to work on integrating the project into the Home assistant, for example, I will add the output to mqtt, or create a recognition sensor. 65 | 66 | Buy Me A Coffee Donate with PayPal 67 | 68 | ## Face recognition server interaction with Home Assistant. 69 | 70 | Face recognition server interaction with Home Assistant is implemented in Node-Red. You can import my flow to Node-Red. 71 | In response to the event of pressing the doorbell button, "Cam Dorbell" flow takes a picture from the doorbell camera and sends it via `html request node` to the webrecognition server. 72 | After the server processing, result of recognition in the form of JSON object arrives in `html request node`. And depending on its contents` Switch node` 73 | open or does not open the wicket lock and set input_boolean sensors. I use these sensors in the Alexa routine to announce by voice assistant who exactly ring the doorbell. 74 | 75 | 76 | Node-Red Flow | Description 77 | -------------------------|------------------------- 78 | [Cam_Doorbell.json](https://github.com/AndreiRadchenko/hassio-webrecognition/blob/main/flows.json) | Flow for interaction with Home Assistant 79 | 80 | 81 | 82 | You need to install in Node-Red [node-red-contrib-image-tools](https://flows.nodered.org/node/node-red-contrib-image-tools) and 83 | [node-red-contrib-image-output](https://flows.nodered.org/node/node-red-contrib-image-output) nodes. 84 | To do this, open Node-Red -> Settings (Sandwich button) -> Manage palette. Go to the Install tab and enter "image-tools" in the search field. 85 | Install this node, then install "image-output" node. 86 | 87 | 88 | 89 | Edit the node "Doorbell button" according to the sensor that will activate the automation. 90 | Edit the node "API" to configure which camera you want to capture. For faster image processing you need to take SD video stream. 91 | 92 | 93 | 94 | If the webrecognition server and Node-Red are running on the same machine, the node "http request" can be left unchanged. Otherwise it is necessary 95 | to edit the IP address of the webrecognition server in the URL field of the "http request" node: [webrecognition_IP]:5001/test 96 | 97 | 98 | 99 | If the webrecognition server returns a JSON object with an empty field "faces_list", node "Switch" activates its first output, which simply outputs 100 | JSON object to Debug stream. If the "faces_list" field is not empty, then someone with a known face is standing in front of the door and "Switch" passes control to second 101 | output. A node that opens the wicket lock is connected to it. Node "Switch" also activates the output containing the name of the recognized person to which connected the nodes that 102 | activates corresponding `input_boolean` 103 | 104 | 105 | --------------------------------------------------------------------------------