Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

[feature request ]Track individual objects #182

Open
Minglarn opened this issue Jan 8, 2021 · 9 comments
Open

[feature request ]Track individual objects #182

Minglarn opened this issue Jan 8, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@Minglarn
Copy link

Minglarn commented Jan 8, 2021

Hi!
First a BIG thanks for this HASS-Deepstack add-on...
Great work and keep up the good job!
Been using for a couple of days now and realized that the object detection works great but it reacts on same objects all the time.

Let's say that my parking lot have 0 car parked.
1 car arrives and parks next to the already parked car -> Object detected and sends a trigger with boundary box
Then 2 car arrives and parks next to the already parked car --> Object detected and sends a trigger with BOTH cars with boundary boxes on both cars.

Object detection reacts on BOTH cars which is kinda overkill as we already detected the first car earlier.

Same thing happens if a bird flies bye and triggers my camera. Now object detection triggers with 2 cars in snapshot where in reality it's not new objects.. There have been there all time..

I would like to have some kind of threshold value so it compares if there really are a NEW object. If possible. :)

PS: Sorry for my bad english...

@koldogut
Copy link

koldogut commented Jan 9, 2021

A quick solution maybe to control it with a helper setting the number of cars with the latest detection and comparing with the previous value.

@robmarkcole
Copy link
Owner

@Minglarn events are fired with all info for each object, from these you can craft any behaviour you desire. Can you refine the feature request?

@Minglarn
Copy link
Author

Minglarn commented Jan 9, 2021

A quick solution maybe to control it with a helper setting the number of cars with the latest detection and comparing with the previous value.

That could help but it would not be accurate.
If the object changes quickly (probably not) it will still count as 3 cars.
I could be thinking wrong about this (just not good at programming at the moment 😕)..

If every image with objects have a "score" value its would bee easier to se if the objects are new or the same.
With that score you could compare the "possibilities" for new objects.

@robmarkcole
Copy link
Owner

robmarkcole commented Jan 10, 2021

Each object is given a 'confidence', but for a given object this might change between captures (e.g. due to changing lighting) so cannot be relied on to identify an object. I understand that you basically want to track individual objects but this is currently outside the scope of this integration. Given the event data you can try out your own solutions

@robmarkcole robmarkcole changed the title Threshold value to detect objects.... [feature request ]Track individual objects Jan 10, 2021
@robmarkcole robmarkcole added the enhancement New feature or request label Jan 10, 2021
@Minglarn
Copy link
Author

A quick solution maybe to control it with a helper setting the number of cars with the latest detection and comparing with the previous value.

Am pretty new with helpers (with HA actually). How would you accomplish a "comparison" helper?

@Minglarn
Copy link
Author

Minglarn commented Jan 24, 2021

Each object is given a 'confidence', but for a given object this might change between captures (e.g. due to changing lighting) so cannot be relied on to identify an object. I understand that you basically want to track individual objects but this is currently outside the scope of this integration. Given the event data you can try out your own solutions

Yes, you're right. It's kinda out of the scope :)
A possible solution would be a total score for the whole image?
Let's say that frame_1 have a score of 100
and frame_2 have a score of 92
The diff is 8.

Example:
frame_1 = 100
frame_2 = 92

if (frame_1 - frame_2) =< 10 then 
 ... do not send new notification. Frames are to equal
else
 ... send a notification. Frames are to not equal.

Hope I could explain this...

@robmarkcole
Copy link
Owner

robmarkcole commented Jan 25, 2021

@Minglarn thanks for putting thought into this. What would really assist the discussion is a demonstration of this algorithm on real data. I propose extracting a sequence of say 10 images, and applying this algorithm to them. The goal is to both demonstrate the algorithm and expose any edge cases early on. For this study you could make use of https://github.com/robmarkcole/deepstack-analytics

@koldogut
Copy link

A quick solution maybe to control it with a helper setting the number of cars with the latest detection and comparing with the previous value.

Am pretty new with helpers (with HA actually). How would you accomplish a "comparison" helper?

More or less this way:

    • First, create a helper (Configuration - helpers - add - numeric helper)
    • Create an automation based on event (deepstack.object_detected, object: car)
    • Add a condition to be launched if new value is different from previous value using templating (find some examples in the forums)
    • Add an action to do whatever you need (notification, call script, service, fire alarm, order a pizza...)
    • Add an action at the end to update the helper with the new value (calling service input_number.set_value)

(Writen from handheld, please excuse any inaccuracy)

@pops106
Copy link

pops106 commented May 28, 2021

This might be quite helpful actually, I have a similar thing 2 cars on the drive hardly ever move.

I believe when the image processing happens and it draws the boxes it has a centre X for a coordinate, could we use that to say if it hasn't moved or say within 5% it is an already detected object.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants