New Custom Compontent - Image Processing - Object Detection - DOODS

I am using 0.99,b1 and it doesnt seem to include the doods image processing code… Is this still targeted for inclusion in 0.99 ?

@andreasfelder - Did you ever get this working? I think I am stuck at the same place you were, whereas the logs seem to show detection but that change isnt reflected in the entity itself within Home Assistant

Yeah got mine to work. For troubleshooting start by removing the file out part of the config as mine had an incorrect path and that made the component error out and not update the state after the scanning. If that is the case you should also see an error in the main HA error log.

Hrm, I am seeing no error in my logs at all…

Hrm. were you able to figure this out? Can you share your config?
Just for giggles remove the file out portion. I actually copied most of the file processing code from the tensorflow component.
I believe they opted to include doods in the 0.100 release.

@snowzach, so far no luck, i see the entity but its always empty. I am running 0.99.b3 at this point just as an FYI.

There are no errors in the logs, only the following on startup

2019-09-18 12:44:46 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for doods which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-09-18 12:44:46 INFO (SyncWorker_81) [homeassistant.loader] Loaded crimereports from homeassistant.components.crimereports
2019-09-18 12:44:46 INFO (MainThread) [homeassistant.setup] Setting up image_processing

here is my config section


image_processing:
 - platform: doods
   scan_interval: 120
   url: "http://192.168.100.14:8082"
   detector: default
   #file_out:
   #  - "/tmp/{{ camera_entity.split('.')[1] }}_latest.jpg"
   source:
     - entity_id: camera.unifi_garage
   confidence: 40
   labels:
     - name: car
       confidence: 40
       area:
         # Exclude top 10% of image
         top: 0.30
         # Exclude left  40% of image
         left: 0.40

Here is the doods log when there is no car present

Sep 18 12:48:49 ubuntu.local docker[7575]: 2019-09-18T16:48:49.150Z        DEBUG        tflite/detector.go:165        Got Image        {"package": "detector.tflite", "id": "", "format": "jpeg", "width": 1920, "height": 1080}
Sep 18 12:48:49 ubuntu.local docker[7575]: 2019-09-18T16:48:49.150Z        DEBUG        tflite/detector.go:167        Resizing Image        {"package": "detector.tflite", "id": "", "format": "jpeg", "width": 300, "height": 300}
Sep 18 12:48:49 ubuntu.local docker[7575]: 2019-09-18T16:48:49.568Z        INFO        tflite/detector.go:266        Detection Complete        {"package": "detector.tflite", "id": "", "duration": 0.383354063, "detections": 0}
Sep 18 12:48:49 ubuntu.local docker[7575]: 2019-09-18T16:48:49.569Z        INFO        server/server.go:88        API Request        {"status": 200, "took": 0.514948324, "remote": "192.168.100.13:32788", "request": "/detect", "method": "POST", "package": "server.request", "request-id": "210e8d201d5a/GQwc9yqXbe-000492"}

and here are the hass logs ( in debug ) for image_processing when there is no car present

2019-09-18 12:48:49 DEBUG (SyncWorker_83) [custom_components.hassdoods.image_processing] The image aspect: 1.7777777777777777 and the detector aspect: 1.0 differ by more than 0.1
2019-09-18 12:48:49 DEBUG (SyncWorker_83) [custom_components.hassdoods.image_processing] doods detect: {'car': 40} response: {} duration: 0.5334815979003906

here is the template i am using to see the entity

root@ubuntu:/usr/share/hassio# cat cat.tmp
{{states.image_processing.doods_unifi_garage }}
root@ubuntu:/usr/share/hassio# hass-cli template cat.tmp
<template state image_processing.doods_unifi_garage=0; matches=, summary=, total_matches=0, friendly_name=Doods unifi_garage @ 2019-09-18T12:44:47.119057-04:00>
root@ubuntu:/usr/share/hassio#

Here are the same logs and template result when there is a car present

Template output

<template state image_processing.doods_unifi_garage=0; matches=, summary=, total_matches=0, friendly_name=Doods unifi_garage @ 2019-09-18T14:00:24.348956-04:00>
root@ubuntu:/usr/share/hassio#
```

### Doods log
```

Sep 18 14:02:26 ubuntu.local docker[7575]: 2019-09-18T18:02:26.934Z        DEBUG        tflite/detector.go:165        Got Image        {"package": "detector.tflite", "id": "", "format": "jpeg", "width": 1920, "height": 1080}
Sep 18 14:02:26 ubuntu.local docker[7575]: 2019-09-18T18:02:26.934Z        DEBUG        tflite/detector.go:167        Resizing Image        {"package": "detector.tflite", "id": "", "format": "jpeg", "width": 300, "height": 300}
Sep 18 14:02:27 ubuntu.local docker[7575]: 2019-09-18T18:02:27.392Z        DEBUG        tflite/detector.go:263        Detection        {"package": "detector.tflite", "id": "", "label": "car", "confidence": 46.09375, "location": "%!d(float32=0.16286317),%!d(float32=0.4303912),%!d(float32=0.9796839),%!d(float32=0.96346986)"}
Sep 18 14:02:27 ubuntu.local docker[7575]: 2019-09-18T18:02:27.392Z        INFO        tflite/detector.go:266        Detection Complete        {"package": "detector.tflite", "id": "", "duration": 0.421354624, "detections": 1}
Sep 18 14:02:27 ubuntu.local docker[7575]: 2019-09-18T18:02:27.393Z        INFO        server/server.go:88        API Request        {"status": 200, "took": 0.539632974, "remote": "192.168.100.13:34634", "request": "/detect", "method": "POST", "package": "server.request", "request-id": "210e8d201d5a/GQwc9yqXbe-000532"}
```

### HASS Log

```
2019-09-18 14:02:26 DEBUG (SyncWorker_121) [custom_components.hassdoods.image_processing] The image aspect: 1.7777777777777777 and the detector aspect: 1.0 differ by more than 0.1
2019-09-18 14:02:27 DEBUG (SyncWorker_121) [custom_components.hassdoods.image_processing] doods detect: {'car': 40} response: {'detections': [{'top': 0.16286317, 'left': 0.4303912, 'bottom': 0.9796839, 'right': 0.96346986, 'label': 'car', 'confidence': 46.09375}]} duration: 0.5558981895446777
```

It looks like your detection is falling outside your box so it’s getting excluded… The poorly formatted response from doods (I need to fix that) shows the box to be:

(float32=0.16286317),%!d(float32=0.4303912),%!d(float32=0.9796839),%!d(float32=0.96346986)

You have top and left set to 0.3 and 0.4 which is greater than the top and left of the detection.

@snowzach I thought that config was excluding / “ignoring” the top 30% and left 40% of the image… am I misunderstanding the intent of that config ?

Sort of, it does but it does it by excluding any detection that goes into that area.

@snowzach hrm, so I am still not sure I’m 100% clear on this… here are two stills from my feed…

Really what I am trying to do is not have it consider the jet ski or jeep which wiould be parked in the smaller garage ( near the top )

Any suggestions as to what measurements / tuning would best accomplish that?

are you trying to exlude left 60% or left 40%?
currently I belive you exclude left 60%.

without mask capability you will miss a lot since that is large portion of image. Maybe consider from perspective of what you need to capture and deal with false results by tuning confidence

How do I define more then one camera? I’d like to have one camera looking for cars in garages and another looking for people in another camera…

Yeah, that’s a tricky one because of the angle your camera is pointed. If any of the detection is included in there it will exclude it… I would guess you could say left 0.2 and top 0.1 and see if that is enough excluded to skip whatever you have in the other bay.

To define more than one camera, you can either supply more than one entity id under source or you can define another doods instance under image_processing

Really love the idea of this project and was hoping it would be included in 0.99. I’m new to Docker, so hoping someone can help me out. I’ve got docker and docker compose running on a fresh install of Ubuntu server 18.04.

I pulled the doods container, and executed the command:

~$ sudo docker run -it -p 8081:8081 snowzach/doods:latest

This seems to work, however it does not seem to detach(?), i.e. I don’t get the command prompt back. If I open a second terminal and execute the following:

~$ sudo docker container ls
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS                    PORTS                                                 NAMES
4b027baec0ba        snowzach/doods:latest            "/opt/doods/doods -c…"   6 seconds ago       Up 4 seconds              0.0.0.0:8081->8081/tcp                                thirsty_payne
09d7112cf2bd        bitwarden/nginx:1.32.0           "/entrypoint.sh"         12 hours ago        Up 45 minutes (healthy)   80/tcp, 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   bitwarden-nginx

… the doods container appears to be running and listening on 8081. However, I cannot seem to connect to it.

Any help would be appreciated.

Doods listens on 8080 by default… use -p 8080:8080

What strategy is in use with this kinds of object detection? If you use a NVR like blue iris to trigger the motion, that is a timeline of images. Would it be possible for doods to analyze a video or a timeframe (from trigger to alarm over) and inspect every photo on that timeline, to give a sum of the objects detected, eleminating doubles by analyzing the path taken? (if a person walks from left to right, thats still one person, even if its 10 or 20 photos in a series).

As I noticed today doing this as Blue Iris detects motion -> sends motion MQTT -> HA set bool to true -> doods analyze the video is a bad strategy as that say nothing about the alarm/motion sequence, just the first(ish) frame of the timeline that probably is nothing anyway

1 Like

That’s true, the motion detection is somewhat dumb as part of Home Assistant. It can only provide a count based on a single frame as of now. For me, it actually works pretty well right now. I use BlueIris to trigger motion detection and then it farms it off to Doods for additional analysis. I use one of the inception models as it generates pretty accurate results. The point of this right now is to replace what the Tensorflow detector does in Home Assistant. I have a longer term plan of something that sits in front of Doods and provides the intelligence that you mention. Something along the lines of https://github.com/blakeblackshear/frigate

I use nodered today to trigger image processing ever 1.5 seconds while motion is detected through blue Iris. This seems to work pretty well as I catch not only first frame but also later. Only issue seems to be with accuracy on the model. It often identifies a bush or similar object as a person and completely misses the person. Not sure how to switch to a more accurate model.
I would say I have about a 70-80% success rate. Good enough for me with local available resources.

I’ve been able to get the DOODS component to work… very nice. My question is on the Docker side: when I “run” the container I am unable to detach from it. How do I get the DOODS Docker container to “run” detached; even better, how do I get the container to auto-start in case of server reboot?

docker run --detach
or
docker run -d

docker run --restart=always

so all together you have
docker run -d --restart=always …snowzach:doods

Docker docs have details and Portainer is a handy tool

1 Like