Difference between revisions of "ZMES"
(7 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
In plain terms, why would you want to use ZMES? Because it avoids false positives associated with weather, automobiles, nature, and a number of other factors. ZMES will get motion detection to detect correctly in the 90-99% range. To do this with Zoneminder's built in motion detection is more difficult. Be warned that while ZMES is good, it is not perfect and there is room for improvement. However, '''object detection''' via tools like Yolo is still an emerging field, there is likely to be improvement in the near future. | In plain terms, why would you want to use ZMES? Because it avoids false positives associated with weather, automobiles, nature, and a number of other factors. ZMES will get motion detection to detect correctly in the 90-99% range. To do this with Zoneminder's built in motion detection is more difficult. Be warned that while ZMES is good, it is not perfect and there is room for improvement. However, '''object detection''' via tools like Yolo is still an emerging field, there is likely to be improvement in the near future. | ||
You can also use external scripts (such as https://github.com/pjreddie/darknet) independently from ZM, as well as do custom object detection (search online) for other tasks such as automation, bird watching, insect monitoring, etc... All these scripts need is an image frame (which are easily obtained in ZM). | You can also use external scripts (such as https://github.com/pjreddie/darknet or https://github.com/lbdc/zm-alarm) independently from ZM, as well as do custom object detection (search online) for other tasks such as automation, bird watching, insect monitoring, etc... All these scripts need is an image frame (which are easily obtained in ZM). | ||
== Setup == | == Setup == | ||
Line 28: | Line 28: | ||
==== Email Alert on events via filters ==== | ==== Email Alert on events via filters ==== | ||
Please see [[Filters]] | Please see [[Filters]] | ||
==== Face Recognition ==== | |||
* One approach: https://forums.zoneminder.com/viewtopic.php?t=32652 | |||
==== Only activate ZMES on certain cameras ==== | |||
This is handled under the skip_monitors option in zmeventnotification.ini. | |||
If you have a high number of cameras, but only need ZMES on certain ones, then you will want to use this. | |||
=== Troubleshooting === | === Troubleshooting === | ||
Line 62: | Line 69: | ||
</pre> | </pre> | ||
==== error: (-215:Assertion failed) preferableBackend != DNN_BACKEND_CUDA || IS_DNN_CUDA_TARGET(preferableTarget) in function 'validateBackendAndTarget' ==== | |||
See: https://forums.zoneminder.com/viewtopic.php?p=135777 | |||
====This environment is externally managed... To install Python packages system-wide, ==== | |||
I recently got the following error with Debian 12 (Devuan 5). | |||
<pre> | |||
ModuleNotFoundError: No module named 'pyzm' | |||
Failed to detect hooks version. | |||
error: externally-managed-environment | |||
× This environment is externally managed | |||
╰─> To install Python packages system-wide, try apt install | |||
python3-xyz, where xyz is the package you are trying to | |||
install. | |||
If you wish to install a non-Debian-packaged Python package, | |||
create a virtual environment using python3 -m venv path/to/venv. | |||
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make | |||
sure you have python3-full installed. | |||
If you wish to install a non-Debian packaged Python application, | |||
it may be easiest to use pipx install xyz, which will manage a | |||
virtual environment for you. Make sure you have pipx installed. | |||
See /usr/share/doc/python3.11/README.venv for more information. | |||
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. | |||
hint: See PEP 668 for the detailed specification. | |||
ERROR:python hooks setup failed | |||
</pre> | |||
My hack (fast) solution: | |||
edit install script and add | |||
--break-system-packages to the pip3 command line. | |||
reference: https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3 | |||
Of course, you do this at your own risk. Given that my ZM machines are used only for ZM, it's not so much of a danger to have pip | |||
override packages. | |||
==See Also== | ==See Also== | ||
Line 68: | Line 110: | ||
* https://pypi.org/project/openimages | * https://pypi.org/project/openimages | ||
* https://pypi.org/project/yolo34py/ and https://github.com/madhawav/YOLO3-4-Py | * https://pypi.org/project/yolo34py/ and https://github.com/madhawav/YOLO3-4-Py | ||
* https://github.com/lbdc/zm-alarm |
Latest revision as of 00:31, 10 October 2024
From the github: The Event Notification Server sits along with ZoneMinder and offers real time notifications, support for push notifications as well as Machine Learning powered recognition. As of today, it supports:
- detection of 80 types of objects (persons, cars, etc.) - face recognition - deep license plate recognition
I will add more algorithms over time. Ref: https://github.com/ZoneMinder/zmeventnotification
In plain terms, why would you want to use ZMES? Because it avoids false positives associated with weather, automobiles, nature, and a number of other factors. ZMES will get motion detection to detect correctly in the 90-99% range. To do this with Zoneminder's built in motion detection is more difficult. Be warned that while ZMES is good, it is not perfect and there is room for improvement. However, object detection via tools like Yolo is still an emerging field, there is likely to be improvement in the near future.
You can also use external scripts (such as https://github.com/pjreddie/darknet or https://github.com/lbdc/zm-alarm) independently from ZM, as well as do custom object detection (search online) for other tasks such as automation, bird watching, insect monitoring, etc... All these scripts need is an image frame (which are easily obtained in ZM).
Setup
Refer to https://zmeventnotification.readthedocs.io/en/latest/guides/install.html and then after that page: https://zmeventnotification.readthedocs.io/en/latest/guides/hooks.html
Make sure you look through and configure the three files
- secrets.ini
- zmeventnotification.ini
- objectconfig.ini
Test it is working with
sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --eventid 2 --monitorid 1 --debug
Tips
Email Alert on events via filters
Please see Filters
Face Recognition
- One approach: https://forums.zoneminder.com/viewtopic.php?t=32652
Only activate ZMES on certain cameras
This is handled under the skip_monitors option in zmeventnotification.ini. If you have a high number of cameras, but only need ZMES on certain ones, then you will want to use this.
Troubleshooting
Missed events in Mocord
If you run the above command:
sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini --eventid 2 --monitorid 1 --debug
You will see the debug information of what ZMES is trying to do. By default, it runs on either a frame:snapshot or an alarm frame. This means that it takes one picture of the video, and runs the neural net detection on that. If for some reason, e.g. a shadow instead of a person is on that alarm frame, then it may fail to detect a person. If you have a long mocord video (say 10 minutes) then there will be only one alarm frame analyzed. The solution appears to be to use modect, where there will be more alarm frames to test or adjust the zones.
I installed opencv per the zmeventnotification docs, but import cv2 doesn't work...?
This happens to me following the default guides. I'm probably missing a step, but the below solves it for me (debian 11):
the install path is local to the build folder, but the module is further down a few directories. so the shared object / module needs to be copied to the path... therefore: root@zmes:/home/user/build# python3 -m site sys.path = [ '/home/user/build', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', ] USER_BASE: '/root/.local' (exists) USER_SITE: '/root/.local/lib/python3.9/site-packages' (doesn't exist) ENABLE_USER_SITE: True root@zmes:/home/user/build# cp lib/python3/cv2.cpython-39-x86_64-linux-gnu.so /usr/local/lib/python3.9/dist-packages/. root@zmes:/home/user/build# python3 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> quit()
error: (-215:Assertion failed) preferableBackend != DNN_BACKEND_CUDA || IS_DNN_CUDA_TARGET(preferableTarget) in function 'validateBackendAndTarget'
See: https://forums.zoneminder.com/viewtopic.php?p=135777
This environment is externally managed... To install Python packages system-wide,
I recently got the following error with Debian 12 (Devuan 5).
ModuleNotFoundError: No module named 'pyzm' Failed to detect hooks version. error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. ERROR:python hooks setup failed
My hack (fast) solution:
edit install script and add --break-system-packages to the pip3 command line.
Of course, you do this at your own risk. Given that my ZM machines are used only for ZM, it's not so much of a danger to have pip override packages.