Page 1 of 1

Object recognition

Posted: Wed Nov 24, 2021 12:03 pm
by hahobson
Hello, I have installed ZM and the Event Server. How would I add a simple HAAR Cascade application? This is what I have working:

Code: Select all

import numpy as np
import cv2
dog_cascade = cv2.CascadeClassifier("cascade.xml")
cap = cv2.VideoCapture("rtsp://")

while 1:
    ret, img =
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    dog = dog_cascade.detectMultiScale(gray, 1.05, 11)

    for (x,y,w,h) in dog:
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]

    k = cv2.waitKey(30) & 0xff
    if k == 27:

I have looked at the objectconfig.ini file, but not sure how to add code to Zoneminder. Thank you!

Re: Object recognition

Posted: Thu Nov 25, 2021 12:03 pm
by asker
This is not something you can turn on via a config - will require code level integration.
Here is the high level flow to get you started:

1. You will need to make these changes in pyzm
2. pyzm/ml/ is the wrapper for all things object detection related (person is an object in this context)
3. You will need to add a new 'object_framework' type called, say, 'hog' and invoke your class there (in
4. Write your hog class similar to other classes
5. Make sure it is installed as part of

To make this more concrete, take a look at this pull request, where a contributor added AWS rekognition support.

Note that at one point, I had hog support built in, but removed it. You'll see inside pyzm/ml which you can modify.