Hooked on hooks

cute kitty, but spare me the ping
TL;DR — If you want to use Object Detection with ZoneMinder, then:
Step 1: Install the event server, get it working first by reading this
Step 2: Get object detection working by reading this

I just released version 1.5 of the zmeventnotification server that lets you invoke a custom “hook” script that can decide if you want to send out alarms or not.

You know, all those times when you don’t want a swaying tree shadow to ping your phone ? Wouldn’t it be nice if you could only get alarms that you care about ? Well, that is what the “hook” does. It lets you invoke your own script, and you can write logic on how to process the alarm. If your script returns 0 the alarm will be sent out. If it returns any other value, the notification server will not send out an alarm (ZM will still record, of course).

Wait. Thats it? That’s like saying “I’ve created an interface that could potentially detect, say, people, but you figure out how to detect people in real time”

Yeah lame. So I’ve helped you a little further. I’ve added two sample hook scripts that uses openCV to detect people and/or objects in a new event.

There are two detection scripts:

detect_hog.py: It is not super accurate but reasonably so. And its very fast, which makes it workable with the notification server because its also semi realtime.

detect_yolo.py: Uses YOLOv3. Quite accurate, detects multiple objects. Slower.

On a Intel Xeon 3.16GHz 4Core machine, with no GPU (i.e CPU only), detect_hog takes 0.2s while detect_yolo takes 2 seconds. Given it is only run when motion is triggered by ZM, I’m currently using the yolo approach on my server.

You need to configure both and get all the python deps installed. Basically, openCV and a few others. Please figure it out. Please read the comments in the script files.

But this gives you a good idea — I’m already using it and its very fast (less than 0.2 seconds on a non GPU machine). Please read the comments to understand how to use it/tweak it.

A few notes:

  1. This gives you a generic hook — person detection is just one example of how you can use it.
  2. There is an open feature request for ZM to incorporate person detection (using a similar OpenCV based HOG Detection algorithm) directly into ZM. When that is done, you don’t need to use a hook to detect objects, obviously. Please add to the bounty to see it in ZM sooner than later or never.

So here is an example of a useful notification that got pushed to my phone:

Notification using fast HOG script
using YOLOv3
YOLOv3 on my watch