Object recognition

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
Posts: 21
Joined: Mon Jul 19, 2021 8:00 am

Object recognition

Post by hahobson » Wed Nov 24, 2021 12:03 pm

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 = cap.read()
    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!

User avatar
Posts: 1534
Joined: Sun Mar 01, 2015 12:12 pm

Re: Object recognition

Post by asker » Thu Nov 25, 2021 12:03 pm

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/object.py 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 object.py)
4. Write your hog class similar to other classes
5. Make sure it is installed as part of setup.py

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 hog.py inside pyzm/ml which you can modify.
Please don't ask me questions via PM. Please post in these forums or GitHub.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests