New Custom Compontent - Image Processing - Object Detection - DOODS

I am trying to have 2 cameras that have independent areas for different labels. One for the driveway that only detects cars/trucks and then one over the front door that detects people.

I can have two separate doods platforms in my config yaml but can both platforms use the same docker container url or should they be directed to independent docker containers?

Thanks!

Yep, you can do that. Just point them at the same doods instance in docker.

Awesome. It has been working perfectly. Thank you!

Hey @snowzach ,
i’m tryng to figure out why i can’t connect to DOODS, i’m still getting connection refused:

Logger: homeassistant.components.image_processing
Source: components/doods/image_processing.py:83
Integration: Elaborazione immagini (documentation, issues)
First occurred: 23:37:51 (1 occurrences)
Last logged: 23:37:51
Error while setting up doods platform for image_processing
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 169, in _new_conn
conn = connection.create_connection(
File “/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py”, line 96, in create_connection
raise err
File “/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py”, line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File “/usr/local/lib/python3.9/http/client.py”, line 1253, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/local/lib/python3.9/http/client.py”, line 1299, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.9/http/client.py”, line 1248, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.9/http/client.py”, line 1008, in _send_output
self.send(msg)
File “/usr/local/lib/python3.9/http/client.py”, line 948, in send
self.connect()
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 200, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f1bcda45790>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py”, line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘192.168.178.9’, port=8080): Max retries exceeded with url: /detectors (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f1bcda45790>: Failed to establish a new connection: [Errno 111] Connection refused’))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 250, in _async_setup_platform
await asyncio.shield(task)
File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/doods/image_processing.py”, line 83, in setup_platform
doods = PyDOODS(url, auth_key, timeout)
File “/usr/local/lib/python3.9/site-packages/pydoods/init.py”, line 13, in init
self.get_detectors()
File “/usr/local/lib/python3.9/site-packages/pydoods/init.py”, line 20, in get_detectors
response = requests.get(self.url + “/detectors”, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/api.py”, line 76, in get
return request(‘get’, url, params=params, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘192.168.178.9’, port=8080): Max retries exceeded with url: /detectors (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0x7f1bcda45790>: Failed to establish a new connection: [Errno 111] Connection refused’))

Can be a firewall issue? My host machine is on Ubuntu, maybe i need to open the 8080 port?

Good day @snowzach first thank you for producing and sharing this component.
Got it running with a pcie Coral an inference is 3ms! Practically no cpu load.

I have a question and please excuse my ignorance if I’m oversimplyfing.
Would adding face recognition be relatively feasible?

This project seems to achieve that, but like I said I don’t know enough to understand the complexity.

Thank you

Any ideas why I don´t get any notifications when there is moving objects in camera picture? Doods seems to run fine and detects well due to the log. When I force the automation to run, I do get a notification with picture to my phone.

automation.yaml

- id: '1628623651862'
  alias: Rörelsenotifiering
  description: ''
  trigger:
  - platform: state
    entity_id: image_processing.doods_framsida
    attribute: total_matches
    from: '1'
    to: '999'
  condition:
  - condition: or
    conditions:
    - condition: template
      value_template: '{{ "car" in state_attr("image_processing.doods_framsida", "summary")
        }}'
    - condition: template
      value_template: '{{ "person" in state_attr("image_processing.doods_framsida","summary")
        }}'
    - condition: template
      value_template: '{{ "truck" in state_attr("image_processing.doods_framsida","summary")
        }}'
    - condition: template
      value_template: '{{ "cat" in state_attr("image_processing.doods_framsida","summary")
        }}'
    - condition: template
      value_template: '{{ "dog" in state_attr("image_processing.doods_framsida","summary")
        }}'
    - condition: template
      value_template: '{{ "motorcycle" in state_attr("image_processing.doods_framsida","summary")
        }}'
  action:
  - service: notify.mobile_app_thomas_mobil
    data:
      data:
        image: /local/doods.jpg
        clickAction: /lovelace-hemovervakning
      message: Rörelse på uppfarten
  mode: single

configuration.yaml

#
  - platform: generic
    name: Doods_cam
    still_image_url: http://192.168.0.11:8123/local/doods.jpg

image_processing:
  - platform: doods
    url: http://192.168.0.11:8081
    timeout: 180
    detector: default
    scan_interval: 7
    source:
      - entity_id: camera.Framsida
    file_out: /config/www/doods.jpg
    confidence: 40
    labels:
      - name: person
      - name: car
        confidence: 60
      - name: truck
        confidence: 50        
      - name: cat
      - name: dog
      - name: motorcycle

it may never be “1” so it will never transition “from” 1 and will likely never be 999
it is not range 1 to 999 it is looking for change from state 1 to state 999 and nothing in between and no consideration for when change is from state 0 (zero/zed/null)

if greater than is available use that else use from 0 and no need to put value for "to:
or use the labels from the condition as the trigger and eliminate the condition as its not needed

Thanks for answering. I changed “from” to 0 and deleted the “to” value.

Still no go :cry:

Is it anything else I need to set? Or did I get this all wrong?

You should trigger when car, person or other object is detected

The condition should be >2 or whatever value you want to use

I can’t get it to work, no matter what. It has to be something wrong…
If I manually run the automation it at least sends the notification.

This means the notification works.
This does not test the trigger or conditions

Look at the “show trace” for your automation
There you can see if it is being trigger and if triggered, whether the conditions are true/false to allow automation to run

Ultimately, I believe your trigger and conditions are wrong and causing you the problem. Try removing conditions and just run with a trigger for testing. Once trigger is OK, you may add a condition to limit the notifications sent.

1 Like

Hi there!
I have been playing around wiht Doods and it works great. I hope to be able to solve my “task” with it, but I am stuck…

I have a camera pointing towards my driveway and I want it to detect cars on it. However, there is a street also on the image, which has cars driving by (at a little bit more distance) that could be also “parked” cars on the driveway.

Is there a way to compare the detection of 2 pictures (scanned in e.g. 10 sec. interval) to correctly differentiate between a detected car on the road and a real stationary car on the driveway?

Thanks for any hints!
Florian

I tend to use Node Red… I am sure that Home Assistant can do it to. There’s a way where you can say the delta of the counted entities has changed. I use that so that when the count of cars goes up, it triggers the notification. It’s not perfect, but it works.

use frigate it has masks easily configurable

Are you running DOODS as add-on or use the separate docker instance manually.? I have the same problem when I was running add-on . I switch to using the docker (as I want to enable the DEBUG), The notification starts to work. The issue is that the notification requires the “summary” field. When I was using the Add-on, that is always empty even the image has detected with object. I haven’t gone back to retest the Add-on but just some data point which I want to share.
Another data point maybe related to amd64 vs latest. It seems like when I run the add-on, I am running with amd64 (with sse42). However, when I run with docker directly, I wasn’t using noavx. It maybe discrepancy in 2 different docker images. (amd64/sse42 one is a lot faster too) I went to to run the amd64(sse42) docker directly, I have the same empty summary issue. I did get some trigger from the amd64 docker after later. So I am not 100% sure what was the issue (yet)

Does specifying labels exclude all the other labels?

Yep. Use the asterisk to include other labels.

You legend! Spent ages trying to work this out on a camera stream!

Afternoon, great work! Got this running and have been tinkering.

Im a noob with Homeassistant, is anyone able to point me in the direction of any how tos for simple alerting, for example “person” detected.

Appreciate the help.

Hey Vispen74, did you ever get this working?