Object detection

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Object detection

Post by tlundste » Sun Jun 20, 2021 12:04 am

I'm starting out small. I have 1.36 working for basic motion detection on one camera. I'm trying to start down the object detection path, and stepping through the config files there. When I start up (and as I continue to run) zoneminder, it lists errors in the log about "No known faces found to train, encoding file not created" and "Error loading KNN model: [Errno 2] No such file or directory: '/var/lib/zmeventnotification/known_faces/faces.dat' ". So, I went to the config file and change the detection_sequence from "object,face,alpr" to be just "object,alpr", yet the same errors come up. Is that expected, and / or is that an error I can remove without putting a .jpg out in that known_faces folder?

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Sun Jun 20, 2021 6:05 am

I can’t say I’ve tried it, but I’d expect the error to go away once you took face out of the config. I’d suggest putting it at least one face and training, so you can get on and sort the next problem. If it turns out to be a bug, raise it once you’ve confirmed.

tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Re: Object detection

Post by tlundste » Mon Jun 21, 2021 6:00 pm

Thank you, Magic919. I added random face .jpgs to the known_faces folder, and tried to train, again. This time, there were no ERR messages... just a "killed" before it would finish. I watched a few other things on the VM when it happened, and noticed some high memory usage, so I shut down the VM, gave it 2GB more memory, and tried again... this time it completed, an the "detect" stuff started working, too.
Now... to figure out how to get it to actually "alarm" in zoneminder when it detects a dog, or car, or whatever I want. Then I'll move on to faces I actually know.

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Mon Jun 21, 2021 6:24 pm

The event server you are using, ZMES, can send alerts. I have mine sent using Pushover. You could have a filter in ZM and have it send an email.

tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Re: Object detection

Post by tlundste » Mon Jun 21, 2021 8:17 pm

It's a windy day, here, so the moving shadows are causing alarms. That's normal for me, in my prod setup. In my test setup, I'm trying to get to the point where a person, or a car (or dog, or whatever I choose) causes the alarm and starts the recording instead of just pixel/blob motion. Am I on the correct path to do that?
(and, to be clear, any motion in my selected zones right now will start the recording on my test server, and object detection will grab some frame and identify the parked cars, parked trucks (not dogs, yet) that happen to be in frame... so, I feel it is partially working for me... just gotta get to the point where relevant motion is the part that triggers the modect recording)

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Tue Jun 22, 2021 7:30 am

It's a good idea, but it can't really work. ZMES only 'knows' there is an alarm when ZM detects one.

tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Re: Object detection

Post by tlundste » Tue Jun 22, 2021 5:29 pm

Sooo... those really cool videos I see on the internet here and there that show a moving video with a box around them and a label of "Person 81%" or "Car 99%" or "Dog 55%" is not really possible with Zoneminder and ZMES?

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Tue Jun 22, 2021 6:04 pm

If you want to run ML against a video that’s not anything that ZM could do. ZMES adds the machine learning, but on stills.

However, the person behind ZMES and ZMNinja wrote MLAPI. https://github.com/pliablepixels/mlapi You could use that.

Depends what you want to achieve. I use ZM and will alert when I have no people present. I use ZMES to filter those and just tell me when a person is there.

You could buy a Jetson and a camera if you just want to see boxes around objects.

tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Re: Object detection

Post by tlundste » Tue Jun 22, 2021 6:58 pm

So... right now in my live system, no ML going on, just one camera.
I take a low-res feed from that camera recording that 24/7 with each video at 10 minutes, and I have a filter that automatically deletes the oldest entries in that list that are not set at "archive" in ZM. It is just set to mocord, I think, so it always recording, and tagging motion in files if I want to look at them.
I also take a high-res feed from the same camera, and it is set to modect, only recording files for however long it needs to when there is motion in one of my four or five defined areas (zones? polygons?).

In my test system, I'm taking baby steps to get to a point where it would only record video if there was a relevant object (person, car, dog, cat, whatever I list). Part of what I eventually want to do with ZM and HomeAssistant is if ZM (ZMES, MLAPI, whatever) sees a dog in my front yard, to turn on a sprinkler system zone... several neighborhood pups come to my yard to do their business... getting tired of walking through it while mowing.

While building this... I've noticed the "still" thing you mentioned.. any "person" it detects is usually someone so far away it can't yet detect a "face" or do any facial recognition. So, it's not working well for that, yet. I also haven't yet figured out how to include "dog" as an object to detect (or bird, or cat, or whatever). I'm still looking for the place to specify what objects I want to detect.

So... when you say ZM alerts, even though there is no people present.. and ZMES filters those to just tell when a person is there... that means you are still recording a lot of those "no people" motion events in your list. Is that correct? If so, is there a specific filter to get rid of files that don't have "person" or "car" in them? (for me, every file would have a "car" detected, cuz the neighbor also parks his vehicles in full view of my camera... and if a still is all that is analyzed, I'm going to get them every time motion is detected in my polygons (my driveway, my walkway, my porch).

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Tue Jun 22, 2021 7:37 pm

There is no specific ZM filter, but you can create one. Where the alarm lacks ‘person’ or whatever it’ll run a delete, for example.

I don’t care that it records unwanted things. I just get the alerts I want from ZMES.

ZMES config is where you tell it what objects to look for. You can constrain the areas within each camera image, so as to avoid detection of parked cars at the side, perhaps.

tlundste
Posts: 19
Joined: Sun Nov 15, 2020 3:41 am

Re: Object detection

Post by tlundste » Tue Jun 22, 2021 7:54 pm

Sadly, my neighbors park their cars in front of my house, directly in a line from my camera down my walkway.... and, on the other side of the street, almost on the same line. It's going to be difficult to determine a polygon that can get the areas I want, without getting the areas where they park. Regardless... if I do, it will still identify there to be a car in the frame when motion is detected within the polygons... I already see it doing that. ZM records on motion in the polygons, and then ZMES analyzes and detects cars everywhere in the frame. Right?

With regard to the ZMES config... (I'm not at home right now, so I can't look to be sure), I remember seeing a sequence entry that listed object,face,alpr (the default list); that's just for sequence of processing, right. I don't recall seeing an entry for listing what objects you want to identify. So far, I have had two dogs wandering around in front of my camera yesterday, and because of the motion, the camera recorded several events, but it didn't identify them... it only identified the cars and trucks parked nearby. Where do I specify what objects (car, truck, dog, cat, bird, llama, etc) it detects?

Magic919
Posts: 548
Joined: Wed Sep 18, 2013 6:56 am

Re: Object detection

Post by Magic919 » Wed Jun 23, 2021 7:46 am

ZM records having seen pixel change. This may or may not be motion.

Have a look at the docs. https://zmeventnotification.readthedocs ... index.html You probably want object_detection_pattern.

Post Reply

Who is online

Users browsing this forum: fmeili1 and 2 guests