Person & Object Detection

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
zmki_jego
Posts: 3
Joined: Sun Aug 20, 2023 3:04 pm

Re: Person & Object Detection

Post by zmki_jego »

asker wrote: Sun Aug 20, 2023 1:08 pm Looks like a few things going on.

Code: Select all

 File "/usr/local/lib/python3.6/dist-packages/mysql/connector/abstracts.py", line 33
    from __future__ import annotations
                                     ^
SyntaxError: future feature annotations is not defined
First, your version of python (3.6) seems to be incompatible with some of the package imports.
Two areas to investigate:
a) Try this solution to see if you can overcome the import error
b) If not, try and use a more recent version of python

There are some other errors but this seems to be the big one.
Thanks for your support, asker. Very much appreciated. Option a) doesn‘t seem to work. Going for option b) means that I also have to re-compile opencv, am I correct? Or can I also proceed without?
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Person & Object Detection

Post by asker »

zmki_jego wrote: Sun Aug 20, 2023 4:22 pm Thanks for your support, asker. Very much appreciated. Option a) doesn‘t seem to work. Going for option b) means that I also have to re-compile opencv, am I correct? Or can I also proceed without?
I suspect you'll have to redo the openCV compilation, at least the python bindings. I'm sure there are smart ways to just do the python part and not have to redo all of it, but I've not investigated.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

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
zmki_jego
Posts: 3
Joined: Sun Aug 20, 2023 3:04 pm

Re: Person & Object Detection

Post by zmki_jego »

Hi asker, meanwhile I was able to recompile openCV again with python3.7 bindings. But I still cannot get object detection working. The output looks as follows now. Do you have an idea what I could do now? Thanks a lot for your support.

Code: Select all


jetson@nano:~$ sudo -u www-data /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini  --eventid 550 --monitorid 1 --debug
08/27/23 00:10:21 zmesdetect_m1[7527] INF ZMLog.py:292 [Setting up signal handler for logs]

08/27/23 00:10:21 zmesdetect_m1[7527] INF ZMLog.py:301 [Switching global logger to ZMLog]

08/27/23 00:10:22 zmesdetect_m1[7527] INF zm_detect.py:283 [---------| app:6.1.28, pyzm:0.3.62, ES:6.1.28
 , OpenCV:4.5.0|------------]

08/27/23 00:10:22 zmesdetect_m1[7527] INF utils.py:404 [Reading config from: /etc/zm/objectconfig.ini]

08/27/23 00:10:22 zmesdetect_m1[7527] INF utils.py:409 [Reading secrets from: /etc/zm/secrets.ini]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ZM_PORTAL]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ZM_USER]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ZM_PASSWORD]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ZM_API_PORTAL]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ML_USER]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !ML_PASSWORD]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:381 [Secret token found in config: !PLATEREC_ALPR_KEY]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG1 utils.py:444 [allowing self-signed certs to work...]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG2 utils.py:454 [Now checking for monitor overrides]

08/27/23 00:10:22 zmesdetect_m1[7527] DBG3 utils.py:521 [Finally, doing parameter substitution]

08/27/23 00:10:22 zmesdetect_m1[7527] INF zm_detect.py:308 [Importing local classes for Object/Face]

08/27/23 00:10:24 zmesdetect_m1[7527] INF zm_detect.py:333 [Connecting with ZM APIs]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 api.py:69 [API SSL certificate check has been disbled]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 api.py:173 [using username/password for login]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 api.py:202 [Using new token API]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 zm_detect.py:341 [using ml_sequence]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 zm_detect.py:353 [using stream_sequence]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 detect_sequence.py:160 [Resetting models, will be loaded on next run]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG3 detect_sequence.py:634 [Using automatic locking as we are switching between models]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 Media.py:51 [Media get SSL certificate check has been disbled]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 Media.py:99 [Using URL 550 for stream]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 Media.py:114 [We will only process frames: ['snapshot', 'alarm']]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 Media.py:137 [No need to start streams, we are picking images from http://192.168.178.170/zm/index.php?view=image&eid=550]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG3 Media.py:271 [Reading http://192.168.178.170/zm/index.php?view=image&eid=550&fid=snapshot]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG3 api.py:263 [make_request called with url=http://192.168.178.170/zm/index.php?view=image&eid=550&fid=snapshot payload={} type=get query={'token': None}]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 detect_sequence.py:654 [perf: Starting for frame:snapshot]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running object detection type in sequence ==================]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 detect_sequence.py:174 [Skipping TPU object detection as it is disabled]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 detect_sequence.py:178 [Loading sequence: YoloV4 GPU/CPU]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 detect_sequence.py:179 [Initializing model  type:object with options:{'name': 'YoloV4 GPU/CPU', 'enabled': 'yes', 'object_config': '/var/lib/zmeventnotification/models/yolov4/yolov4.cfg', 'object_weights': '/var/lib/zmeventnotification/models/yolov4/yolov4.weights', 'object_labels': '/var/lib/zmeventnotification/models/yolov4/coco.names', 'object_min_confidence': 0.3, 'object_framework': 'opencv', 'object_processor': 'gpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'disable_locks': 'no'}]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 yolo.py:55 [portalock: max:1, name:pyzm_uid33_gpu_lock, timeout:100]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 detect_sequence.py:701 [--------- Frame:snapshot Running variation: #1 -------------]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 yolo.py:152 [detect extracted image dimensions as: 800wx450h]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 yolo.py:68 [Waiting for pyzm_uid33_gpu_lock portalock...]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG2 yolo.py:70 [Got pyzm_uid33_gpu_lock portalock]

08/27/23 00:10:24 zmesdetect_m1[7527] DBG1 yolo.py:102 [|--------- Loading "YoloV4 GPU/CPU" model from disk -------------|]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG1 yolo.py:117 [perf: processor:gpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 852.94 ms]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG2 yolo.py:130 [Setting CUDA backend for OpenCV]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG3 yolo.py:132 [If you did not set your CUDA_ARCH_BIN correctly during OpenCV compilation, you will get errors during detection related to invalid device/make_policy]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG1 yolo.py:177 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG2 yolo.py:86 [Released pyzm_uid33_gpu_lock portalock]

08/27/23 00:10:25 zmesdetect_m1[7527] ERR detect_sequence.py:713 [Error running model: OpenCV(4.5.0) /home/jetson/nano_build_opencv/workspace/opencv-4.5.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'
]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/object.py", line 71, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/yolo.py", line 189, in detect
    outs = self.net.forward(ln)
cv2.error: OpenCV(4.5.0) /home/jetson/nano_build_opencv/workspace/opencv-4.5.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'

]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: snapshot]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running face detection type in sequence ==================]

08/27/23 00:10:25 zmesdetect_m1[7527] DBG2 detect_sequence.py:190 [Skipping TPU face detection as it is disabled]

08/27/23 00:10:27 zmesdetect_m1[7527] ERR detect_sequence.py:196 [Error loading same model variation for face:No module named 'face_recognition']

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:197 [Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/detect_sequence.py", line 194, in _load_models
    self.models[seq].append(FaceDetect.Face(options=face_seq))
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face.py", line 14, in __init__
    import pyzm.ml.face_dlib as face_dlib
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face_dlib.py", line 3, in <module>
    import pyzm.ml.face_train_dlib as train
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face_train_dlib.py", line 18, in <module>
    import face_recognition
ModuleNotFoundError: No module named 'face_recognition'
]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: snapshot]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: snapshot Running alpr detection type in sequence ==================]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG3 Media.py:271 [Reading http://192.168.178.170/zm/index.php?view=image&eid=550&fid=alarm]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG3 api.py:263 [make_request called with url=http://192.168.178.170/zm/index.php?view=image&eid=550&fid=alarm payload={} type=get query={'token': None}]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:654 [perf: Starting for frame:alarm]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:664 [Sequence of detection types to execute: ['object', 'face', 'alpr']]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: alarm Running object detection type in sequence ==================]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG3 detect_sequence.py:689 [object has a same_model_sequence strategy of first]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:701 [--------- Frame:alarm Running variation: #1 -------------]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 yolo.py:152 [detect extracted image dimensions as: 800wx450h]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 yolo.py:68 [Waiting for pyzm_uid33_gpu_lock portalock...]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 yolo.py:70 [Got pyzm_uid33_gpu_lock portalock]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 yolo.py:177 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 416w*416h) ----------|]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 yolo.py:86 [Released pyzm_uid33_gpu_lock portalock]

08/27/23 00:10:27 zmesdetect_m1[7527] ERR detect_sequence.py:713 [Error running model: OpenCV(4.5.0) /home/jetson/nano_build_opencv/workspace/opencv-4.5.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'
]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:714 [Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/detect_sequence.py", line 710, in detect_stream
    _b,_l,_c,_m = m.detect(image=frame)
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/object.py", line 71, in detect
    b,l,c,_model_names = self.model.detect(image)
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/yolo.py", line 189, in detect
    outs = self.net.forward(ln)
cv2.error: OpenCV(4.5.0) /home/jetson/nano_build_opencv/workspace/opencv-4.5.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'

]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:770 [We did not find any object matches in frame: alarm]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: alarm Running face detection type in sequence ==================]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:190 [Skipping TPU face detection as it is disabled]

08/27/23 00:10:27 zmesdetect_m1[7527] ERR detect_sequence.py:196 [Error loading same model variation for face:No module named 'face_recognition']

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:197 [Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/detect_sequence.py", line 194, in _load_models
    self.models[seq].append(FaceDetect.Face(options=face_seq))
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face.py", line 14, in __init__
    import pyzm.ml.face_dlib as face_dlib
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face_dlib.py", line 3, in <module>
    import pyzm.ml.face_train_dlib as train
  File "/usr/local/lib/python3.7/dist-packages/pyzm/ml/face_train_dlib.py", line 18, in <module>
    import face_recognition
ModuleNotFoundError: No module named 'face_recognition'
]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG3 detect_sequence.py:689 [face has a same_model_sequence strategy of union]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:770 [We did not find any face matches in frame: alarm]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:669 [============ Frame: alarm Running alpr detection type in sequence ==================]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG2 detect_sequence.py:672 [Making sure we have matched one of ['car', 'motorbike', 'bus', 'truck', 'boat'] in [] before we proceed]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:674 [Did not find pre existing labels, not running detection type]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 detect_sequence.py:831 [perf: TOTAL detection sequence (with image loads) took: 2699.40 ms  to process 550]

08/27/23 00:10:27 zmesdetect_m1[7527] DBG1 zm_detect.py:556 [Closing logs]

jetson@nano:~$ 

I see that it says something about a missing cuda device here:

Code: Select all


cv2.error: OpenCV(4.5.0) /home/jetson/nano_build_opencv/workspace/opencv-4.5.0/modules/dnn/src/cuda4dnn/csl/memory.hpp:54: error: (-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'

But when I check it directly a cuda device should be there:

Code: Select all


jetson@nano:~$ python
Python 3.7.5 (default, Dec  9 2021, 17:04:37) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.0'
>>> count = cv2.cuda.getCudaEnabledDeviceCount()
>>> print(count)
1
>>> 

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

Re: Person & Object Detection

Post by asker »

I'm afraid you are on your own here as I don't use jetson - looks like that is your target platform. However, when I did a google for your error:

Code: Select all

(-217:Gpu API call) no CUDA-capable device is detected in function 'ManagedPtr'
The very first link was this post that seems to indicate you need OpenCV 4.4 or below, if you are using Jetpack 4.4. I have no idea what jetpack is but it seems the OpenCV version you have may not be compatible with the environment (i.e. it may install, but may not work for all things). You may want to sharpen your google search efforts a bit because I'm guessing here. You could of course also try to just use cpu instead of gpu, but I suspect you want the GPU.

(It also looks like you haven't installed face recognition but your config is invoking it - but that is a different error. You may want to turn off face recognition in your objectconfig.ini here)
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

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