neilenns / node-deepstackai-trigger

Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
MIT License
167 stars 28 forks source link

a prediction must be considered successful if the centroid of its box is within an activateRegions #411

Closed jbolanosg closed 3 years ago

jbolanosg commented 3 years ago

In the tests that I am reviewing it is happening to me many times that it says that a prediction is successful if the box of the same only touches the area defined for success .... reviewing the source code I find that you define that a prediction is successful if it has overlap .... see code in: https://github.com/danecreekphotography/node-deepstackai-trigger/blob/189132b4f13902306979dce0807b045850255d0f/src/Rect.ts#L20

It is more effective to use that the centroid of the prediction box is inside the activateRegions. This is more real to verify that an object is within a region. In the HASS-Deepstack-object component that has home assistant that uses Deepstack AI this is the method they use ... See code: https://github.com/robmarkcole/HASS-Deepstack-object/blob/f72a02f886af96938082f58032933a36ee2846eb/custom_components/deepstack_object/image_processing.py#L116

With this change, the report made by node-deepstack-trigger of a successful prediction would have more reliability.

neilenns commented 3 years ago

Are you referring to activateRegions regions for triggers?

jbolanosg commented 3 years ago

if that's what I'm referring to ... according to the definition of regions: imagen

What I'm asking you to analyze is to modify the overlaps method in the source code so that it works with the centroid of the detected object.

neilenns commented 3 years ago

Changing the way they work would be a breaking change and cause issues for anyone who has already deployed the system and uses it. As implemented and documented it's designed to trigger on any overlap.

What scenario are you dealing with where you need to use activateRegions? It's a relatively recent addition that is really only useful in limited circumstances.

jbolanosg commented 3 years ago

For example, the camera on the balcony watches over my car and watches that a person does not approach the car ... that's why I configure two regions, one (upper region in green) that only checks a car in the area and the lower one ( region in green) that checks that there are people near the street near the car.

With this separation I can know when my car is parked and when a person could approach it. Another use case is a camera that can see various sectors of the house (living room, hallway and kitchen) and depending on where the camera detects the person could turn on the lights in the living room or the kitchen. I attach real photos of example ... I do this from the home assistant side where I add the box in yellow where the object was detected and in green the area where its centroid was ... in this development in python integrate the requirements that I have asked you for your program:

  1. define for each activeregions a list of object types and confidence {car: 75, person: 55}
  2. Object detection is only effective if its centroid is included in the configured region.

I did this development while I wait for them to maybe be integrated into your system.

Photos: imagen imagen

neilenns commented 3 years ago

Closing old issues.