Face detection with Docker/Machinebox

Checkout docs for tensorflow object detrection and others, to find scripts for adding bounding boxes to an image. We need to add this capability to the platform

1 Like

Thanks @robmarkcole, will do.

Have another question about my automation script.
The notify telegram will send the picture with a timestamp but does not include the message element.

Wondering if any of the more experienced users can spot an issue with it?
Have checked the docs and other notify examples and I believe I have it correct.

- id: facebox_announcement
  alias: 'Facebox Announcement'
  initial_state: on
  trigger:
    platform: event
    event_type: doorbird_gate_motion
  action:
  - delay: 00:00:02
  - service: camera.snapshot
    data:
      entity_id: camera.gate_live
      filename: '/config/www/facebox/tmp/image.jpg'
  - delay: 00:00:01
  - service: image_processing.scan
    entity_id: image_processing.facebox_saved_image
  - delay: 00:00:02
  - service: media_player.volume_set
    data:
      entity_id: media_player.kitchen_echo_dot
      volume_level: 0.9
  - service_template: '{% if states.sensor.facebox_detection.state != "unknown" %} media_player.alexa_tts {% endif %}'
    data_template:
      entity_id: media_player.kitchen_echo_dot
      message: '{% if states.sensor.facebox_detection.state != "unknown" %}  {{ states("sensor.facebox_detection") }} is at the door {% else %} {% endif %}'
  - service: notify.telegram
    data:
      message: '{% if states.sensor.facebox_detection.state != "unknown" %}  Facebox triggered. {{ states("sensor.facebox_detection") }} is at the door {% else %} Facebox triggered. {% endif %}'
      data:
        photo:
          file: '/config/www/facebox/tmp/image.jpg'
          caption: '{{now().strftime("%d.%m.%Y-%H:%M:%S")}}'
  - service: media_player.volume_set
    data:
      entity_id: media_player.kitchen_echo_dot
      volume_level: 0.5

Hi there!

So, I’ve been playing with facebox/cameras/HA for days now and not all is going well…
Here is my setup:

Synology with docker running:

  • Home assistant
  • node-red
  • Facebox
  • MQTT (not used for this)

Config.yaml:

 camera:
   - platform: synology
     url: https://IP-adress-deleted:5002
     username: !secret syno-name
     password: !secret syno-pwd
     verify_ssl: false
   - platform: local_file
     name: Saved Image
     file_path: /config/tmp/balcony.jpg
image_processing:
  - platform: facebox
    scan_interval: 10000
    ip_address: 127.0.0.1
    port: 8080
    source:
      - entity_id: camera.local_file 

Connection to synology cameras and local camera is working (I can get entities displayed just fine in).

sensors.yaml

  - platform: template
    sensors:
      facebox_detection:
        friendly_name: 'Facebox Detection'
        value_template: '{{ states.image_processing.facebox_saved_image.attributes.faces[0]["name"].title}}'

Since I have entity camera.saved_image - I changes here from facebox_saved_images to facebox_saved_image - and this entity DOES indeed show latest snapshot after motion is detected.

And last - automations.yaml:

- id: '1552944284375'
  alias: SS Balcony webhook
  trigger:
  - platform: webhook
    webhook_id: motion_balcony_hook
  condition: []
  action:
  - data:
      entity_id: camera.terasa2
      filename: /config/tmp/balcony.jpg
    service: camera.snapshot
  - data:
      entity_id: image_processing.facebox_saved_image
    service: image_processing.scan

And this automation does work as intended (I had also notification here so, yeah, snapshot is triggered,
just fine, using node-red - tested via http call too).
Facebox is nicely setup (i think) - I can check it via web interface with post command on snapshot and it does work ok - recognising face if there is one. BUT, automation does nothing.

I get frequently:

2019-03-27 05:18:23 ERROR (MainThread) [homeassistant.components.image_processing] Error on receive image from entity: Camera not found
2019-03-27 08:05:03 ERROR (MainThread) [homeassistant.components.image_processing] Error on receive image from entity: Camera not found

sensor.facebox_detection is always unknown
image_processing.facebox_local_file is always 0

Any ideas? Sorry for a long post!!!

Do you mind sharing your node red flow? I’ve been struggling to get this to work in Node Red.

Thanks

Here is copy of it…
It uses synology to create webhook based on what camera has motion.
But since 0.90.x I’m also receiving new errors that webhooks are not registered…

[{“id”:“3a3710e2.b0ec4”,“type”:“tab”,“label”:“Synology webhook”,“disabled”:false,“info”:""},{“id”:“6031b9f1.decbb8”,“type”:“http in”,“z”:“3a3710e2.b0ec4”,“name”:"",“url”:"/synology_flows/:webhook",“method”:“get”,“upload”:false,“swaggerDoc”:"",“x”:176.5,“y”:119.99999904632568,“wires”:[[“11e82352.ac456d”]]},{“id”:“89f6a2be.82e43”,“type”:“http request”,“z”:“3a3710e2.b0ec4”,“name”:"",“method”:“use”,“ret”:“txt”,“paytoqs”:false,“url”:“https://PRIVATE:8123/api/webhook/{{req.params.webhook}}”,“tls”:“b6c11d45.7c62c”,“proxy”:"",“x”:608.500072479248,“y”:408.99999713897705,“wires”:[[“30c1cbb2.dc86a4”]]},{“id”:“30c1cbb2.dc86a4”,“type”:“http response”,“z”:“3a3710e2.b0ec4”,“name”:"",“statusCode”:"",“headers”:{},“x”:830.5000419616699,“y”:539.0000066757202,“wires”:[]},{“id”:“11e82352.ac456d”,“type”:“function”,“z”:“3a3710e2.b0ec4”,“name”:"",“func”:“msg.payload = {};\nmsg.payload = “{}”;\nmsg.headers = {};\nmsg.headers[‘Content-Type’] = ‘application/json’;\nmsg.method = “POST”\n\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:409.5000190734863,“y”:242.99999904632568,“wires”:[[“89f6a2be.82e43”]]},{“id”:“b6c11d45.7c62c”,“type”:“tls-config”,“z”:"",“name”:"",“cert”:"",“key”:"",“ca”:"",“certname”:"",“keyname”:"",“caname”:"",“servername”:"",“verifyservercert”:true}]

Sorry again, having trouble importing your flow. :slight_smile:

Did you change IP address - it is here listed as “PRIVATE” - it should be your domain/IP address?

I can’t actually import your flow. I’m getting this error:

SyntaxError: Unexpected token “ in JSON at position 2

Can’t access node-red from here, will try exporting it again and saving as text once more.

Thank you. Appreciate it.

This shoul be it. Formated. You can put it in .json and import

[
{
“id”: “6031b9f1.decbb8”,
“type”: “http in”,
“z”: “3a3710e2.b0ec4”,
“name”: “”,
“url”: “/synology_flows/:webhook”,
“method”: “get”,
“upload”: false,
“swaggerDoc”: “”,
“x”: 176.5,
“y”: 119.99999904632568,
“wires”: [
[
“11e82352.ac456d”
]
]
},
{
“id”: “89f6a2be.82e43”,
“type”: “http request”,
“z”: “3a3710e2.b0ec4”,
“name”: “”,
“method”: “use”,
“ret”: “txt”,
“paytoqs”: false,
“url”: “https://127.0.0.1:8123/api/webhook/{{req.params.webhook}}”,
“tls”: “b6c11d45.7c62c”,
“proxy”: “”,
“x”: 608.500072479248,
“y”: 408.99999713897705,
“wires”: [
[
“30c1cbb2.dc86a4”
]
]
},
{
“id”: “30c1cbb2.dc86a4”,
“type”: “http response”,
“z”: “3a3710e2.b0ec4”,
“name”: “”,
“statusCode”: “”,
“headers”: {},
“x”: 830.5000419616699,
“y”: 539.0000066757202,
“wires”: []
},
{
“id”: “11e82352.ac456d”,
“type”: “function”,
“z”: “3a3710e2.b0ec4”,
“name”: “”,
“func”: “msg.payload = {};\nmsg.payload = “{}”;\nmsg.headers = {};\nmsg.headers[‘Content-Type’] = ‘application/json’;\nmsg.method = “POST”\n\nreturn msg;”,
“outputs”: 1,
“noerr”: 0,
“x”: 409.5000190734863,
“y”: 242.99999904632568,
“wires”: [
[
“89f6a2be.82e43”
]
]
},
{
“id”: “b6c11d45.7c62c”,
“type”: “tls-config”,
“z”: “”,
“name”: “”,
“cert”: “”,
“key”: “”,
“ca”: “”,
“certname”: “”,
“keyname”: “”,
“caname”: “”,
“servername”: “”,
“verifyservercert”: true
}
]

Hey Everyone. So I have attempted to setup facebox. It looks like for whatever reason I am missing some of the endpoints such as /facebox/teach and /facebox/check both of those pages gives me a 404 page not found. I have reached out to facebox as well but I’m not sure if I’ll get a response. Does anyone know where I can find a detailed logs for facebox? When I look at the /heatlhz it looks like everything is good to go without any errors.

Hmm - I belive you are doing it wrong. Those URLs are for POST I think:

Use the /facebox/teach endpoint to teach Facebox a face:

POST /facebox/teach
  • name - (required string) The name of the person (ensure this value is exactly the same for multiple examples from the same person)
  • id - (optional string) Unique ID for each teaching example (typically use the filename)

The face may be provided by submitting an image file, or by specifying the Faceprint.

  • The image you use to teach Facebox must contain only a single detectable face, an error will be returned if Facebox cannot detect a face, or if it detects multiple faces
  • Facebox supports one-shot teaching, but providing more examples of each person will improve its accuracy

If you open default URL (I think it’s port 8080), just below that text you will see “By URL” “By Post” & “By Face print”

There you can use By post to submit images to teach it.
Also someone has made script for teaching it with multiple images (in same folder).

And REMEMBER! free version doesn’t save face print, just keeps it in memory.
So if you want to have it availabe after restart save face print to local/network disk and reload it after restart (again, someone made a script).

Hi!
I’ve a second HassOS working on a 4 GB Ram Virtual Machine for testing purposes.
It’s a fresh install and only has the Portainer add-on.
I’m trying to deploy machinebox, but I don’t know how inside Portainer, since It’s not in the App list, and neither do find the CLI for writing the commands mentioned in the documentation.
Some guidance would be highly appreciated!

AFAIK Machinebox products are not supported on HassOS. You coul dtry the OpenCV or Tensorflow integrations for face detection

Hey man!

Followed your tutorial and ended up with a pretty similar setup.
But I am not having an issue where the recognized face seems to stay in cache and then gets redetected the next time someone rings.

Did you had a similar issue?

That is most likely an issue with the camera, returning the same image or something

I resolved the issue by bypassing home assistant with the face-recognition.

It now works pretty great.

Instead of running the scan service and watching the current state afterward, I use an HTTP node (in node-red) to post the image of the camera to facebox.

Thanks for the reply tho!

1 Like

Hi guys,
i’ve correctly installed and configured the docker image and facebox is running fine. I’m tryng to get the script for training working but i’m not able to do that. I’ve the script in my hass.io python_scripts folder and there i have 2 subdir named with people i want to identify. Inside that folders i have a couple.of images to train, but if i run the script, nothing happens, no face identified (checked in the frontend of the facebox instance). What i’m doing wrong?

Hi, currently I’m running Deepstack face/object in Docker on an Intel NUC and all works fine. I’m eager to try Facebox too for the sake of comparing. The problem is when I try to register to Veritone to get the key I get a “bad request” error without further explanation. Anyone faced the same problem?
Thank you in advance