-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add "ignore_zone" param for monitors #37
Comments
I like this but I would suggest it conform to how the current zones are configured in the per-monitor overrides. New config file syntax is in YAML format BTW (objectconfig.yml, zmeventnotfication.yml, zm_secrets.yml, mlapiconfig.yml).
New 'Neo' YAML
I will implement this tonight and test it as much as I can. |
Here's one example where YOLOv4 detected a false car in front of the real car, the Another idea is to have separate |
I have already implemented per label filtering in the new code, I have also implemented a 'contained wihtin' filter ->
01/06/22 23:15:12.208026 zm_mlapi[7127] DBG2 detect_sequence:506 ['person (1/1)' has 262769.07 pixels (82.40%) inside 'back_yard'] |
Im wondering if the contained within filter would be enough for your specific situation already though. Technically you could specify your polygon zone 'parking_area' and then say you want at least 85% of the car to be within that zone to be a hit.
This means that a car must be detected and the area of its bounding box must have 85% within any polygon zone. I need to fine tune configs to allow per zone filtering as well but I think the contained within filter would cover your use case here. |
That would work! If I understand correctly, instead of defining an ignoring zone, I'd draw a polygon for the rest of the driveway as a valid zone for a car to be detected in. YAML is more structured, definitely a better way going forward for configuration (I work with Drupal 8/9 daily). Do you have the new codes available? I can set up another box for testing/development. BTW, let's not hard-code for "car", my driveway has "truck" and "bus" too often :-D We would also need a GUI tool to define the polygons. Currently I'm using the zone tool in ZM (saving the polygons as inactive zones), but it's tedious to copy the points manually to the config file. Maybe add an option in the zone tool to export the points as a comma-separated list (or whatever the new format is), in-browser Javascript should do. There's another problem that I don't have a solution yet: the road curves down across the frame, a long bus or truck would have its bounding box taking half of my driveway when it's near the right edge of the frame. I guess most detection algorithms (YOLO, Coral, ...) only draw vertical/horizontal rectangle boxes around the detected objects, so there's really no way around it. Maybe in the future we can think of a way to define rotation of the bounding boxes for specific areas. |
No hardcoding needed lol, it will be highly configurable. I may change how the polygon_zones are defined into their own data structure
I would recommend training YOLO models for your specific vehicles and people you want to detect, use that model as the first sequence and then pre-trained yolo as the 2nd sequence. There are probably some other ideas that could be used as well, YOLO only does rectangles and doesn't follow contours for the bounding boxes. There may be things we could do in the future, we will see. Neo repos are in my pinned repositories, might be some kinks as I just merged and haven't tested as of yet. I am just cleaning things up first and then testing before letting the team know its ready for review. I also have a working docker image for MLAPI that utilizes GPU/TPU and has ALPR/face-detection libs all installed.
|
I am leaving the current (legacy) way of defining polygon_zones and detection patterns and also adding the new way of defining zones as shown above. Priority will be DEFINED_ZONE, SEQUENCE and :general: for options pertaining to filters. |
@hqhoang - Would you be willing to test the new code base? I am testing myself but another user to test would be great as well. There is a helper script to convert the secrets .ini files to YAML and the zmeventnotification.ini to YAML but mlapiconfig and objectconfig will need to be switched to YAML manually. The helper script is in the 'hook' folder, its syntax is If you do not specify an output name it will take the current name of the file and simply change .ini to .yml. For object detection and mlapi there is the option to have all the keys on the 'base' level ()legacy/default) and an option to enable 'sections'. This means it is too hard to make a conversion script; technically the 'sections' are only for readability and editing the config file in something like Pycharm so you can collapse the sections or navigate them using the 'Structure' tab. Once the object detection config or mlapi config is parsed, sections are removed and all keys are on the 'base' level. This is still a WIP and things WILL change because I am currently rewriting the pyzm libs for something new that uses API and also allows accessing ZM via DB. Edit: Also if you have any other ideas let me know and I can try and implement if it makes sense, |
Sorry, I got busy, but finally able to try to swap to your code base. It's quite a mess on my end :-) Documenting a few things that I encountered so that we can try to address later:
Also, the neo-* packages are a little behind as well, so I'm symlinking directly to git cloned directories. I got mlapi to run, debugging and testing zm_detect.py at the moment. Will keep you updated. |
At the moment pull_req branch' of my repos is the one being considered to merge. The team is reviewing and will cherry-pick what to merge. Packages of neo are a mess as of now due to focusing on PR, it is recommended now to install and pull from pull_req branches to test until the merge is complete (Meaning I will need to make an alternate install.sh to pull from specific branch). The final code for merge may differ and some things may not work as expected, expect there to be some headaches and issues until the merge is complete and solid docs have been written up about all the changes and new features. Thank you for testing and reporting what issues and annoyances you find along the way, it is extremely helpful feedback! |
Scenario: car parks on driveway most of the time. With tree shadow, cloud, snow, rain, ...triggering the camera, it's easy to get the car detected and alerted over and over.
While
car_past_det_max_diff_area
param works for cars that park short-term, it doesn't work well for long-term parked cars. Sometimes the detected box is far left or far right of the actual car, especially when it snows. If the detection box is far left then far right, the diff is over the threshold and triggers an alert.What I'm doing for the above scenario is to tap into the websocket notification. In my script that handles the events from websocket, I have a polygon defined as "parking zone" where the car can be anywhere in it. The detected box is then compared against this parking zone:
The above logic works well that the detected box can jump around the actual car without triggering an alert. Sometimes YOLOv4 can even detect a fake car in front of the real car, but it's small and still fit into the parking zone, so that works well to avoid false positive, too (no car that small). While it ignores cars detected in that zone, it doesn't ignore other objects so a person walking into that zone will still get detected and alerted.
Maybe add a new generic param to the config to ignore objects detected in the zone, matching the defined labels with certain overlapping percentage, e.g.:
The text was updated successfully, but these errors were encountered: