ZoneMinder / zmeventnotification

Machine Learning powered Secure Websocket & MQTT based ZoneMinder event notification server
412 stars 128 forks source link

running detect_wrapper.sh gives ImportError: No module named zmes_hook_helpers.log #133

Closed komzi2920 closed 5 years ago

komzi2920 commented 5 years ago

Hello ! I'm trying to implement hooking ,but no success after to many install , uninstall and re-install and really don't understand the root of the cause. I'm using zmeventnotification version 3.9 and zminder 1.32.3 ,but when I try manually the detect_wrapper.sh: sudo -u www-data /usr/bin/detect_wrapper.sh 3374 1

I get this error: Traceback (most recent call last): File "/usr/bin/detect.py", line 20, in import zmes_hook_helpers.log as log ImportError: No module named zmes_hook_helpers.log

I checked if the log.py exist and it is located in the same python repository where other packages are as command ls -l shows below: ls -l /usr/local/lib/python3.5/dist-packages/zmes_hook_helpers/ total 68 -rw-r--r-- 1 root staff 4159 Jul 13 23:53 alpr.py -rw-r--r-- 1 root staff 6551 Jul 13 23:53 common_params.py -rw-r--r-- 1 root staff 4475 Jul 13 23:53 face.py -rw-r--r-- 1 root staff 1072 Jul 13 23:53 hog.py -rw-r--r-- 1 root staff 8890 Jul 13 23:53 image_manip.py -rw-r--r-- 1 root staff 42 Jul 13 23:53 init.py -rw-r--r-- 1 root staff 527 Jul 13 23:53 log.py drwxr-sr-x 2 root staff 4096 Jul 13 23:53 pycache -rw-r--r-- 1 root staff 10072 Jul 13 23:53 utils.py -rw-r--r-- 1 root staff 3340 Jul 13 23:53 yolo.py

Please help me how to fix that. Thanks !

I have changed the first row of python file /usr/bin/detect.py from #!/usr/bin/python to #!/usr/bin/python3 and now it is ok, no more error showing. I'll try it with zmninja desktop now and let's hope everything will work as expected.

Thanks !

I tried with zmninja desktop and I got notifications on motions ,but there is no any bounding frame over detected person. Is that maybe related with this error in the log file as shown below: ERROR [Could not write image to ZoneMinder as eventpath not present]

Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [|--> model:hog detection took: 0.257539s] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [intersection: polygon in process=[(462, 142), (67, 142), (67, 134), (462, 134)]] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [full_image intersects object:person[[(462, 142), (67, 142), (67, 134), (462, 134)]]] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [intersection: polygon in process=[(290, 102), (87, 102), (87, 175), (290, 175)]] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [full_image intersects object:person[[(290, 102), (87, 102), (87, 175), (290, 175)]]] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [ALPR not in use, no need for look aheads in processing] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [labels found: ['person', 'person']] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [match found in /var/lib/zmeventnotification/images/3597.jpg, breaking file loop...] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [detection mode is set to first, breaking out of model loop...] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [Writing out debug bounding box image to /var/lib/zmeventnotification/images/3597-bbox.jpg...] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: ERROR [Could not write image to ZoneMinder as eventpath not present] Jul 14 13:40:56 deb9zimnd detect:[9894][monitor_m1]: DEBUG [Prediction string:[x] detected:person:100% ] Jul 14 13:40:56 deb9zimnd zma_m1[6761]: INF [zma_m1] [In overload mode, 1 frames of 2 remaining] Jul 14 13:40:56 deb9zimnd zmeventnotification[9890]: INF [For Monitor:1 event:3597, hook script returned with text:[x] detected:person:100% exit:0] Jul 14 13:40:56 deb9zimnd zmeventnotification[9890]: INF [Matching alarm to connection rules...]

pliablepixels commented 5 years ago

So the problem is resolved then? If you are manually invoking detect.py you will need to specify ZM event path. Use detect_wrapper.sh instead - see docs

komzi2920 commented 5 years ago

Thanks for your answer ! The detect.py is not running manually,it is called by detect_wrapper.sh as hook specified in zmeventnotification.ini. All alert notification I get in my zmninja desktop are not showing any bounding frame while all pictures files created by motion events, *-bbox.jpg ,are showing them. Thanks !

pliablepixels commented 5 years ago

Not quite sure what you mean.

  1. In the desktop version, there is no push notification only a websocket message. When you tap on an event, the first image you will see in the carousel will be the bounding box image like this:
Screen Shot 2019-07-14 at 9 35 17 AM
  1. If you are getting ERROR [Could not write image to ZoneMinder as eventpath not present] then maybe hook_pass_image_path = yes is set to no in zmeventnotification.ini

  2. Just noticed - you need ZM 1.33.x to get this to work actually (see the config file that say so above the entry)

komzi2920 commented 5 years ago

Thanks again for your quick answer and your time during the wee-end ! Really appreciated it ! So, as far as I understand to have the photo/video frames with bounding frames I have to use mobile zmninja and upgrade zoneminder from 1.32 to 1.33 ? Is that I should have to do ? I'm providing also to you my zmeventnotification.ini file. Thanks ! Port .......................... 9000 Address ....................... 0.0.0.0 Event check interval .......... 5 Monitor reload interval ....... 300

Auth enabled .................. yes Auth timeout .................. 20

Use FCM ....................... yes FCM API key ................... (defined) Token file .................... /var/lib/zmeventnotification/push/tokens.txt

Use MQTT .......................no MQTT Server ....................127.0.0.1 MQTT Username ..................(undefined) MQTT Password ..................(undefined)

SSL enabled ................... no SSL cert file ................. (undefined) SSL key file .................. (undefined)

Verbose ....................... yes Read alarm cause .............. yes Tag alarm event id ............ yes Use custom notification sound . no

Hook .......................... '/usr/bin/detect_wrapper.sh' Use Hook Description........... yes Keep frame match type.......... yes Skipped monitors............... 8 Store Frame in ZM...............yes

Picture URL ................... http://192.168.1.10/zm/index.php?view=image&eid=EVENTID&fid=alarm&width=600&username=admin&password=xxxxx Include picture................ yes

pliablepixels commented 5 years ago

Some notes:

  1. Your picture URL has fid=alarm -> that will always send the alarmed frame, even if the object detection was on snapshot. It would be better if you changed it to either fid=BESTMATCH (needs ZM 1.33+) or fid=objdetect (needs ZM 1.33+). Basically, if you use BESTMATCH you will get a notification on whichever frame was used for object detection. If you use objdetect you will get a notification with the actual bounding boxes drawn. Note this is only for mobile. Desktop doesn't get picture notifications

  2. Yes, the "event path" was added to 1.33, so if you update your ZM, you should see ZM console showing the bounding boxes as well as get those to zmNinja

komzi2920 commented 5 years ago

Thanks again ! Based on that I should install zoneminder 1.33 and try again, but I have to setup another instance using Ubuntu since the current one I'm using is on Debian 9 and for Debian 10 it is not available yet.