Facial recognition & room presence using Double Take & Frigate

@Jako great, thanks! The other thing I was wondering, is it possible to have the room presence sensor time-out (return to empty) after a specified time? Or to have an event sent when a face stops being detected? I’d like to make a wall mounted tablet that displays a different dashboard depending on which user is looking at it (easy enough), but not sure how to make it react when the user moves away again?

Hi All,
Double Take seems a very interesting project, i’m installed on a system with Frigate and Deepstack.
I’m using Frigate since a month and it works good, i installed just now Double Take and Deepstack.
I can manage (load face and check images) and access Deepstack with Deepstack UI.

My issue is that I cant’ make double take interact with frigate or deepstack too…
Nothing happen in double take logs. it’s up…but…

What can i check? How can i improve log level?

i can see deepstack online topic into mqtt broker too, but nothing else…

—my config–

frigate:
  url: http://10.0.0.37:5000
[...]
detectors:
  deepstack:
    url: http://10.0.0.37:8001

Thank you for your help

do you have Double-Take configured with MQTT properly? I had to supply a user/password (even though that is not part of the DT example config file)

Thank you for reply. Yes it was with user and pass and it’s ok.

i found just now an error in my config about frigate section, and maybe all the following config lines were not read (for example timezone settings)

frigate:
  url: http://10.0.0.37:5000
  image:
    height: 500
  attempts:
    latest: 10
    snapshot: 0
  cameras:
    - box
    - fontanella
  zones:
    - camera: box
        zone: giardino

Removing cameras: and zones: lines now i can see logs (yeah!!!)
I suppose there is an error on the zones section, but for now it’s ok to analyze all cameras.

I can see logs, but with an error :frowning:

deepstack process error: Cannot read property ‘map’ of undefined

i’m going on trying to understand it

Thanks!!!

@zil0g, I think the easiest way to accomplish this would be to have a timeout like you mentioned and after X amount of seconds the topic is cleared off. Would something like that work?

Are you looking to do this at a camera level and configure different timeouts per camera?

@ppluti007, glad you got it running! Are you running DeepStack with VISION-FACE enabled?

docker run -e VISION-FACE=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack

Yes i should…,
this is my docker-compose:

version: "3.7"
services:
  deepstack:
    container_name: deepstack
    restart: unless-stopped
    image: deepquestai/deepstack
    ports:
      - '8001:5000'
    environment:
      - VISION-FACE=True
      - API-KEY=""
      - MODE="Medium"
      - TZ=Europe/Rome
    volumes:
      - /etc/localtime:/etc/localtime
      - /root/docker.config/deepstack/datastore:/datastore
  deepstack_ui:
    container_name: deepstack_ui
    restart: unless-stopped
    image: robmarkcole/deepstack-ui:latest
    environment:
      - DEEPSTACK_IP=10.0.0.37
      - DEEPSTACK_PORT=8001
      - DEEPSTACK_API_KEY=""
      - DEEPSTACK_TIMEOUT=20
    ports:
      - '8501:8501'

ps: even if i’m not so good using deepstack… i was able to load face and recognize with the UI

Thank you for your reply… and well done for your work, even if i’m not yet able to use it… :slight_smile: … but it’s a matter of time!!

Glad to help and thank you! Try to hit localhost:PORT/api/recognize/test and see what the output of that is. I’ll try to debug more tonight if you can’t figure it out.

ooopps…
maybe i found something…

[
  {
    "detector": "deepstack",
    "response": {
      "success": false,
      "error": "Incorrect api key",
      "duration": 0
    }
  }
]

i will setup an api key and let’s see what will happen…

1 Like

I think the easiest way to accomplish this would be to have a timeout like you mentioned and after X amount of seconds the topic is cleared off. Would something like that work?

Hi @Jako , I think this would be useful for room-presence generally, as sometimes the data may go stale even though another camera hasn’t yet picked the person up.

Are you looking to do this at a camera level and configure different timeouts per camera?

however this made me think - would it be possible to have a Double Take sensor per camera also? It could contain the name of the person that’s been recognised, and could also listen out for the “end” event message from Frigate that occurs when the motion detection event is over, i.e. the person leaves the cameras field of view. So the sensor could report the person currently being viewed by the camera, and then when that person is no longer visible, the sensor resets. Do you think this would be possible?

Got it working!!! yeahhhh

I had to remove at all the API-KEY entry in the deepsack docker-compose.yaml…
If it is API-KEY="" it doesn’t work.

is it possible to seti it in double face? i don’t see in the config options

By the way…Thank you jako for your excellent work!

@zil0g, results are already published to camera specific topics. Is this what you were talking about in regards to the sensor per camera?

Maybe instead of removing the data from the topic, I create a new one that just acts as a boolean that gets reset.

If a person is found a topic is created, i.e. double-take/cameras/driveway with the results of the recognition, then another topic is created to indicate a person is there, double-take/cameras/driveway/person = YES. After X seconds the double-take/cameras/driveway/person endpoint can reset back to NO.

I’ll have to think a bit more on the Frigate end event and how that can be tied in without making things too messy.

Glad you got it working. Since that’s an environment variable for DeepStack, it will need to be set when the container is created. I don’t think the current version of DeepStack requires an API KEY though, so it should be safe to remove.

I can probably add to the UI a way to validate if the detectors are configured correctly, similar to what you did by hitting the /api/recognize/test route.

Ok, clear.

it’s not the deepstack license api key, but it’s can be set a mysecret apikey too. That’s what i used

But it’s ok to avoid it. I’m in my local lan

Thank You, again!

1 Like

Ah I see. I didn’t realize DeepStack had a way to set an API key. I can add support for that in a future release. It should be pretty easy to include.

Mine is also just on my local LAN, so I’ve been running it with no key.

@zil0g, I pushed a new beta build v0.8.0 which includes a topic similar to what Frigate does when people are detected. When results are published to the camera MQTT topic, a new topic is also created which contains how many people were found, this currently includes unknown people too.

For example if one person is found by the driveway camera, then results are published to double-take/cameras/driveway and then the new topic double-take/cameras/driveway/person will have a value of 1. After 30 seconds this will be reset back to 0. I opted not to use the Frigate end event right now because I’m worried that an end event for a previous event will occur after a new event is processed which would overwrite the counter.

Let me know what you think and if something needs to be adjusted.

@ppluti007, I added support to the beta build for passing a DeepStack API key as well. The config would look something like this now.

detectors:
  deepstack:
    url: http://192.168.1.1:8001
    key: xxx-xxx-xxx-xxx-xxx # optional api key

I got this version: v0.8.0-ad2069b (with the horizontal menu matches|files|config) but i still get error using api-key

deepstack docker-compose.yaml

version: "3.7"
services:
  deepstack:
    container_name: deepstack
    restart: unless-stopped
    image: deepquestai/deepstack
    ports:
      - '8001:5000'
    environment:
      - VISION-FACE=True
      - API-KEY="xxx-xxx-xxx-xxx-xxx"
      - MODE="Medium"
      - TZ=Europe/Rome
    volumes:
      - /etc/localtime:/etc/localtime
      - /root/docker.config/deepstack/datastore:/datastore

double-take config:

detectors:
  deepstack:
    url: http://<deepstack-ip>:8001
    key: xxx-xxx-xxx-xxx-xxx # optional api key

this is the test:

root@cam:~# curl -X GET "http://localhost:3000/api/recognize/test" -H "Content-type: application/json"
[{"detector":"deepstack","status":401,"response":{"success":false,"error":"Incorrect api key","duration":0}}]

Weird, I tested last night and it was working. Let me figure out what I missed. Sorry about that. I’ll push up a fix this evening.

:smiley: don’t worry… the hard job of a developer…

Thank you again!!

Are you sure your environment section is right? Shouldn’t it be like this?

environment:
      VISION-FACE: 'True'
      API-KEY: 'xxx-xxx-xxx-xxx-xxx'
      MODE: 'Medium'
      TZ: 'Europe/Rome'

I was able to reproduce the error, then when I put in the API key into the config it worked. This is what my compose and config look like.

 deepstack:
    container_name: deepstack
    image: deepquestai/deepstack
    restart: unless-stopped
    ports:
      - 80:5000
    environment:
      VISION-FACE: 'True'
      VISION-DETECTION: 'True'
      MODE: High
      API-KEY: "123-456-789"
detectors:
  deepstack:
    url: http://<deepstack-ip>
    key: 123-456-789