ZoneMinder / pyzm

Python API, Log, Event Server and Memory wrapper for ZoneMinder
GNU General Public License v2.0
32 stars 21 forks source link

past detections should be checked inside media loop? #35

Open hqhoang opened 2 years ago

hqhoang commented 2 years ago

Scenario: I have a car parked most of the time on my driveway, thus I have the setting match_past_detections enabled. At night, before my wife's car turns into the driveway, its headlight triggers a motion, the car is not in the frame until later (e.g. frame 220).

To be efficient, I set frame_strategy=first. But the parked car got detected first, breaking out of the media loop. The parked car is then compared against past detections, and the whole event is dropped. It would be better to have the parked car compared against past detections inside the media loop, then proceed to other frames until it finds the first frame with object not matching past detections (the coming car).

I can work around by setting frame_strategy=most, but that would defeat the efficiency: it could stop processing the remaining frames once it found an object that doesn't match past detections.

Maybe we can add another frame_strategy option, e.g. "first_new"? That would check the detected objects against past detections inside the media loop, while still allow breaking out of the loop at the first frame that doesn't match past detections. The later call to _process_past_detections can then be skipped for this option.

(for reference, I'm talking about the codes near the bottom of detect_sequence.py)

baudneo commented 2 years ago

I am working on a solution to these problems that you are describing, this is an idea I will explore. I have reworked the logic to evaluate inside of the media loop via the filter function that is called every sequence. I need to test some more but there is work being actively done to make this a better experience.