ZoneMinder / pyzm

Python API, Log, Event Server and Memory wrapper for ZoneMinder
GNU General Public License v2.0
31 stars 20 forks source link

past_det_max_diff_area not working #26

Closed ghost closed 3 years ago

ghost commented 3 years ago

If I dont have any overrides for past_det_max_diff_area then it completes the sequence. Once I add a person_past_det_max_diff_area to objectconfig.ini I get this error ->

03/29/21 19:08:19 zmesdetect_m6[584] DBG2 object.py:71 [Converted 90% to 324000.0]

03/29/21 19:08:19 zmesdetect_m6[584] DBG2 object.py:92 [Ignoring dog [653, 119, 683, 169] as conf. level 0.35663270950317383 is lower than 0.4]

03/29/21 19:08:19 zmesdetect_m6[584] DBG2 object.py:94 [Returning filtered list of 2 objects.]

03/29/21 19:08:19 zmesdetect_m6[584] DBG4 detect_sequence.py:637 [This model iteration inside object found: labels: ['person', 'boat'],conf:[0.9952523112297058, 0.4280830919742584]]

03/29/21 19:08:19 zmesdetect_m6[584] DBG3 detect_sequence.py:368 [Max object size found to be: 90%]

03/29/21 19:08:19 zmesdetect_m6[584] DBG2 detect_sequence.py:376 [Converted 90% to 324000.0]

03/29/21 19:08:19 zmesdetect_m6[584] FAT zm_detect.py:546 [Unrecoverable error:not enough values to unpack (expected 2, got 1) Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 541, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 412, in main_handler
    matched_data,all_data = m.detect_stream(stream=stream, options=stream_options)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 645, in detect_stream
    _b,_l,_c, _e = self._filter_detections(m, seq,_b,_l,_c, polygons, h, w)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 403, in _filter_detections
    polygons[:] = self._rescale_polygons(polygons, neww / oldw, newh / oldh)
  File "/usr/local/lib/python3.8/dist-packages/pyzm/ml/detect_sequence.py", line 200, in _rescale_polygons
    for x, y in p['value']:
ValueError: not enough values to unpack (expected 2, got 1)
]

Usage: es.debug.objdet <Event ID> <Monitor ID>

I am trying to debug it somewhat to see if I can get you better info.

ghost commented 3 years ago

03/29/21 19:30:08 zmesdetect_m6[1639] DBG1 detect_sequence.py:198 [Inside rescale polygons polygons = [{'name': 'parking_pad', 'value': [(988, 568), (1810, 293), (1920, 316), (1920, 1080), (0, 1080), (0, 845)], 'pattern': None}, {'name': 'person_det_max_diff_area', 'value': [(10,)], 'pattern': None}] xfactor = 0.4166666666666667 yfactor = 0.4166666666666667]

Is the polygon section being loaded with the past det max diff area when it shouldnt be? or should its 'name' and 'value' keys be named different then the masked area's keys?

ghost commented 3 years ago

I guess the problem is if you dont add % or px, it was set to 10 and fails with that error but 10% works fine.

ghost commented 3 years ago

I do however think there is an issue when it processes past detections or tries to. Core detections says it returned 3 filtered objects and then I can see its comparing the polygons. It finds that all 3 objects intersect the polygon mask and then it seems to bypass _past_detections (I put a g.logger.Debug(1,'Inside past detections, line 1' just to be sure) and just returns the person? I have frame strategy set to most and object detection strategy set to all. Here are the logs I have for the event in question. using freshly updated install with new pyzm and ES.

 zmadmin  zmlxc  SSH  ~  zmeventnotification  master  ✎  %  es.debug.objdet 735 6             
03/29/21 20:00:46 zmesdetect_m6[2764] INF ZMLog.py:225 [Setting up signal handler for logs]

03/29/21 20:00:46 zmesdetect_m6[2764] INF ZMLog.py:234 [Switching global logger to ZMLog]

03/29/21 20:00:47 zmesdetect_m6[2764] INF zm_detect.py:271 [---------| app:6.1.17, pyzm:0.3.41, ES:6.1.17 , OpenCV:4.5.1|------------]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 utils.py:406 [secret filename: /etc/zm/secrets.ini]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:379 [Secret token found in config: !ZM_PORTAL]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:379 [Secret token found in config: !ZM_USER]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:379 [Secret token found in config: !ZM_PASSWORD]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:379 [Secret token found in config: !ZM_API_PORTAL]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:379 [Secret token found in config: !PLATEREC_ALPR_KEY]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 utils.py:443 [strict SSL cert checking is on...]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 utils.py:451 [Now checking for monitor overrides]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 utils.py:482 [adding polygon: parking_pad [988,568 1810,293 1920,316 1920,1080 0,1080 0,845]]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 utils.py:469 [[monitor-6] overrides key:object_min_confidence with value:0.4]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 utils.py:484 [det_mode=object is not a polygon definition. Error was invalid literal for int() with base 10: 'object'. Ignoring.]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 utils.py:469 [[monitor-6] overrides key:object_detection_pattern with value:(person|car|dog|cat|truck)]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 utils.py:469 [[monitor-6] overrides key:match_past_detections with value:yes]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 utils.py:484 [car_past_det_max_diff_area=43% is not a polygon definition. Error was invalid literal for int() with base 10: '43%'. Ignoring.]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 utils.py:484 [truck_past_det_max_diff_area=43% is not a polygon definition. Error was invalid literal for int() with base 10: '43%'. Ignoring.]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 utils.py:484 [person_det_max_diff_area=10% is not a polygon definition. Error was invalid literal for int() with base 10: '10%'. Ignoring.]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 utils.py:514 [Finally, doing parameter substitution]

03/29/21 20:00:47 zmesdetect_m6[2764] INF zm_detect.py:296 [Importing local classes for Object/Face]

03/29/21 20:00:47 zmesdetect_m6[2764] INF zm_detect.py:319 [Connecting with ZM APIs]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 api.py:168 [using username/password for login]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 api.py:197 [Using new token API]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 api.py:204 [Access token expires on:2021-03-29 22:00:47.821766 [7200s]]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 api.py:208 [Refresh token expires on:2021-03-30 20:00:47.822734 [86400s]]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 api.py:131 [No need to relogin as access token still has 119.9999678 minutes remaining]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 api.py:267 [make_request called with url=h/api/host/gettimezone.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE3MDY5NjQ3LCJleHAiOjE2MTcwNzY4NDcsInVzZXIiOiJUeWxlciIsInR5cv9jiS8ido'}]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 zm_detect.py:327 [using ml_sequence]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 zm_detect.py:339 [using stream_sequence]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 detect_sequence.py:142 [Resetting models, will be loaded on next run]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 detect_sequence.py:575 [Using manual locking as we are only using one model]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 Media.py:53 [Media get SSL certificate check has been disbled]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 Media.py:101 [Using URL 735 for stream]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 Media.py:114 [We will only process frames: ['snapshot', 'alarm']]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG2 Media.py:137 [No need to start streams, we are picking images from https://tsp-zm.duckdns.org/zm/index.php?view=image&eid=735]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 Media.py:247 [Trying to convert snapshot to a real frame id]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 api.py:131 [No need to relogin as access token still has 119.99935918333334 minutes remaining]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 api.py:267 [make_request called with urm/api/events/735.json payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE3MDY5NjQ3LCJleHAiOjE2MTcwNzY4NDcsInVzZhY2Nlc3MifQ.iB5v9jhnkQO5LsLaeKmaZe47HLdgMmGcPsZ4NiS8ido'}]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 Media.py:252 [At the point of analysis, Event:735 snapshot frame id was:78,so using it]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 Media.py:263 [Reading httm/index.php?view=image&eid=735&fid=78]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG3 api.py:131 [No need to relogin as access token still has 119.99756668333333 minutes remaining]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG4 api.py:267 [make_request called with zm/index.php?view=image&eid=735&fid=78 payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE3MDY5NjQ3LCJleHAiOjE2MTcwNzY4NDcsInVzZXIiOiJUeWxlciIaeKmaZe4'}]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 detect_sequence.py:594 [perf: Starting for frame:78]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 detect_sequence.py:607 [============ Frame: 78 Running object model in sequence ==================]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG3 detect_sequence.py:150 [load_models (just init, actual load happens at first detect): ['object']]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG2 detect_sequence.py:159 [Initializing model  type:object with options:{'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.4, 'object_framework': 'opencv', 'object_processor': 'cpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'model_width': 512, 'model_height': 512, 'disable_locks': 'no'}]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG2 yolo.py:39 [portalock: max:3, name:pyzm_uid33_cpu_lock, timeout:100]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG2 yolo.py:51 [Waiting for pyzm_uid33_cpu_lock portalock...]

filenames [PosixPath('/tmp/pyzm_uid33_cpu_lock.00.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.01.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.02.lock')]
trying lock [PosixPath('/tmp/pyzm_uid33_cpu_lock.00.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.01.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.02.lock')]
trying lock for /tmp/pyzm_uid33_cpu_lock.00.lock
locked /tmp/pyzm_uid33_cpu_lock.00.lock
03/29/21 20:00:48 zmesdetect_m6[2764] DBG2 yolo.py:53 [Got pyzm_uid33_cpu_lock portalock]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG3 detect_sequence.py:627 [object has a same_model_sequence strategy of most]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG3 detect_sequence.py:638 [--------- Frame:78 Running variation: #1 -------------]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG2 yolo.py:48 [pyzm_uid33_cpu_lock portalock already acquired]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 yolo.py:85 [|--------- Loading Yolo model from disk ---------|]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 yolo.py:92 [perf: processor:cpu Yolo initialization (loading /var/lib/zmeventnotification/models/yolov4/yolov4.weights model from disk) took: 231.92 ms]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 yolo.py:105 [Using CPU for detection]

03/29/21 20:00:48 zmesdetect_m6[2764] DBG1 yolo.py:147 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 512w*512h) ----------|]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 yolo.py:69 [Released pyzm_uid33_cpu_lock portalock]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG1 yolo.py:173 [perf: processor:cpu Yolo detection took: 1887.96 ms]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 yolo.py:208 [perf: processor:cpu Yolo NMS filtering took: 2.83 ms]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 object.py:59 [core model detection over, got 3 objects. Now filtering]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 object.py:63 [Max object size found to be: 90%]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 object.py:71 [Converted 90% to 324000.0]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 object.py:92 [Ignoring dog [653, 119, 683, 169] as conf. level 0.35663270950317383 is lower than 0.4]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 object.py:94 [Returning filtered list of 2 objects.]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG4 detect_sequence.py:642 [This model iteration inside object found: labels: ['person', 'boat'],conf:[0.9952523112297058, 0.4280830919742584]]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:371 [Max object size found to be: 90%]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 detect_sequence.py:379 [Converted 90% to 324000.0]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:206 [resized polygons x=0.4166666666666667/y=0.4166666666666667: [{'name': 'parking_pad', 'value': [(411, 236), (754, 122), (800, 131), (800, 450), (0, 450), (0, 352)], 'pattern': None}]]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG1 detect_sequence.py:440 [obj.area = 17424.0 max_object_area = 324000.0]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:447 [intersection: comparing object:person,POLYGON ((414 119, 502 119, 502 317, 414 317, 414 119)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 detect_sequence.py:465 [Using global match pattern: (person|car|dog|cat|truck)]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:473 [parking_pad intersects object:person[[(414, 119), (502, 119), (502, 317), (414, 317)]]]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG1 detect_sequence.py:440 [obj.area = 177996.0 max_object_area = 324000.0]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:447 [intersection: comparing object:boat,POLYGON ((91 128, 637 128, 637 454, 91 454, 91 128)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG2 detect_sequence.py:465 [Using global match pattern: (person|car|dog|cat|truck)]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 detect_sequence.py:481 [parking_pad intersects object:boat[[(91, 128), (637, 128), (637, 454), (91, 454)]] but does NOT match your detect pattern filter]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 Media.py:263 [Reading m/index.php?view=image&eid=735&fid=alarm]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG3 api.py:131 [No need to relogin as access token still has 119.94798596666666 minutes remaining]

03/29/21 20:00:50 zmesdetect_m6[2764] DBG4 api.py:267 [make_request called with url=zm/index.php?view=image&eid=735&fid=alarm payload={} type=get query={'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJab25lTWluZGVyIiwiaWF0IjoxNjE3MDY5NjQ3LCJleHAiOjE2MTcwNzY4NDcsInVzZXIiOiJUeWxlciIsInR5cGUiOiJhY2Nlc47HLdgMmGcPsZ4NiS8ido'}]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG1 detect_sequence.py:594 [perf: Starting for frame:alarm]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG1 detect_sequence.py:607 [============ Frame: alarm Running object model in sequence ==================]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG3 detect_sequence.py:627 [object has a same_model_sequence strategy of most]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG3 detect_sequence.py:638 [--------- Frame:alarm Running variation: #1 -------------]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG2 yolo.py:51 [Waiting for pyzm_uid33_cpu_lock portalock...]

filenames [PosixPath('/tmp/pyzm_uid33_cpu_lock.00.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.01.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.02.lock')]
trying lock [PosixPath('/tmp/pyzm_uid33_cpu_lock.00.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.01.lock'), PosixPath('/tmp/pyzm_uid33_cpu_lock.02.lock')]
trying lock for /tmp/pyzm_uid33_cpu_lock.00.lock
locked /tmp/pyzm_uid33_cpu_lock.00.lock
03/29/21 20:00:51 zmesdetect_m6[2764] DBG2 yolo.py:53 [Got pyzm_uid33_cpu_lock portalock]

03/29/21 20:00:51 zmesdetect_m6[2764] DBG1 yolo.py:147 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 512w*512h) ----------|]

03/29/21 20:00:52 zmesdetect_m6[2764] DBG2 yolo.py:69 [Released pyzm_uid33_cpu_lock portalock]

03/29/21 20:00:52 zmesdetect_m6[2764] DBG1 yolo.py:173 [perf: processor:cpu Yolo detection took: 1450.83 ms]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 yolo.py:208 [perf: processor:cpu Yolo NMS filtering took: 2.14 ms]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 object.py:59 [core model detection over, got 3 objects. Now filtering]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 object.py:63 [Max object size found to be: 90%]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 object.py:71 [Converted 90% to 324000.0]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 object.py:94 [Returning filtered list of 3 objects.]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG4 detect_sequence.py:642 [This model iteration inside object found: labels: ['person', 'cat', 'car'],conf:[0.9909704327583313, 0.87347412109375, 0.8391774892807007]]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:371 [Max object size found to be: 90%]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 detect_sequence.py:379 [Converted 90% to 324000.0]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 detect_sequence.py:440 [obj.area = 20496.0 max_object_area = 324000.0]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:447 [intersection: comparing object:person,POLYGON ((348 100, 470 100, 470 268, 348 268, 348 100)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 detect_sequence.py:465 [Using global match pattern: (person|car|dog|cat|truck)]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:473 [parking_pad intersects object:person[[(348, 100), (470, 100), (470, 268), (348, 268)]]]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 detect_sequence.py:440 [obj.area = 6192.0 max_object_area = 324000.0]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:447 [intersection: comparing object:cat,POLYGON ((504 190, 576 190, 576 276, 504 276, 504 190)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 detect_sequence.py:465 [Using global match pattern: (person|car|dog|cat|truck)]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:473 [parking_pad intersects object:cat[[(504, 190), (576, 190), (576, 276), (504, 276)]]]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 detect_sequence.py:440 [obj.area = 173016.0 max_object_area = 324000.0]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:447 [intersection: comparing object:car,POLYGON ((107 128, 641 128, 641 452, 107 452, 107 128)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 detect_sequence.py:465 [Using global match pattern: (person|car|dog|cat|truck)]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG3 detect_sequence.py:473 [parking_pad intersects object:car[[(107, 128), (641, 128), (641, 452), (107, 452)]]]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG2 yolo.py:65 [pyzm_uid33_cpu_lock portalock already released]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 detect_sequence.py:767 [perf: TOTAL detection sequence (with image loads) took: 5232.98 ms  to process 735]

03/29/21 20:00:53 zmesdetect_m6[2764] INF zm_detect.py:465 [Prediction string:[x] detected:person:100% ]

03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 zm_detect.py:467 [Prediction string JSON:{"labels": ["person"], "boxes": [[414, 119, 502, 317]], "frame_id": "78", "confidences": [0.9952523112297058], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[x] detected:person:100% --SPLIT--{"labels": ["person"], "boxes": [[414, 119, 502, 317]], "frame_id": "78", "confidences": [0.9952523112297058], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
03/29/21 20:00:53 zmesdetect_m6[2764] DBG1 zm_detect.py:544 [Closing logs]

Here is the config for that run

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 zm_detect.py:409 [TYLER : ml_options = {'general': {'model_sequence': 'object', 'disable_locks': 'no'}, 'object': {'general': {'pattern': '(person|car|dog|cat|truck)', 'same_model_sequence_strategy': 'most'}, 'sequence': [{'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.4, 'object_framework': 'opencv', 'object_processor': 'cpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'model_width': 512, 'model_height': 512}]}, 'face': {'general': {'pattern': '.*', 'same_model_sequence_strategy': 'first'}, 'sequence': [{'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, 'face_detection_framework': 'dlib', 'known_images_path': '/var/lib/zmeventnotification/known_faces', 'unknown_images_path': '/var/lib/zmeventnotification/unknown_faces', 'face_model': 'cnn', 'face_train_model': 'cnn', 'face_recog_dist_threshold': '0.6', 'face_num_jitters': '1', 'face_upsample_times': '2', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800}]}, 'alpr': {'general': {'same_model_sequence_strategy': 'first', 'pre_existing_labels': ['car', 'motorbike', 'bus', 'truck', 'boat'], 'pattern': '.*'}, 'sequence': [{'alpr_api_type': 'cloud', 'alpr_service': 'plate_recognizer', 'alpr_key': 'your_plate_recognizer_api_key', 'platrec_stats': 'yes', 'platerec_min_dscore': 0.1, 'platerec_min_score': 0.2, 'max_size': 1600}]}}]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 zm_detect.py:410 [TYLER : global_config= {'pyzm_overrides': {'log_level_debug': 5}, 'secrets': '/etc/zm/secrets.ini', 'version': '1.2', 'cpu_max_processes': 3, 'gpu_max_processes': 1, 'tpu_max_processes': 1, 'cpu_max_lock_wait': 100, 'gpu_max_lock_wait': 100, 'tpu_max_lock_wait': 100, 'base_data_path': '/var/lib/zmeventnotification', 'portal': 'httpsxxxxxxxm', 'api_portal': 'htxxxxxxxi', 'user': 'xxxxx', 'password': C', 'basic_user': '', 'basic_password': '', 'image_path': '/var/lib/zmeventnotification/images', 'match_past_detections': 'yes', 'past_det_max_diff_area': '5%', 'max_detection_size': '90%', 'frame_id': 'bestmatch', 'bestmatch_order': 'a,s', 'wait': 0, 'resize': '800', 'delete_after_analyze': 'yes', 'show_percent': 'yes', 'allow_self_signed': 'no', 'write_image_to_zm': 'yes', 'write_debug_image': 'no', 'detection_sequence': ['object', 'face', 'alpr'], 'detection_mode': 'first', 'import_zm_zones': 'no', 'only_triggered_zm_zones': 'no', 'poly_color': (255, 255, 255), 'poly_thickness': 2, 'create_animation': 'no', 'animation_types': "'mp4,gif'", 'animation_width': 640, 'animation_retry_sleep': 15, 'animation_max_tries': 4, 'fast_gif': 'no', 'ml_gateway': None, 'ml_fallback_local': 'no', 'ml_user': None, 'ml_password': None, 'disable_locks': 'no', 'use_sequence': 'yes', 'ml_sequence': {'general': {'model_sequence': 'object', 'disable_locks': 'no'}, 'object': {'general': {'pattern': '(person|car|dog|cat|truck)', 'same_model_sequence_strategy': 'most'}, 'sequence': [{'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.4, 'object_framework': 'opencv', 'object_processor': 'cpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'model_width': 512, 'model_height': 512}]}, 'face': {'general': {'pattern': '.*', 'same_model_sequence_strategy': 'first'}, 'sequence': [{'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, 'face_detection_framework': 'dlib', 'known_images_path': '/var/lib/zmeventnotification/known_faces', 'unknown_images_path': '/var/lib/zmeventnotification/unknown_faces', 'face_model': 'cnn', 'face_train_model': 'cnn', 'face_recog_dist_threshold': '0.6', 'face_num_jitters': '1', 'face_upsample_times': '2', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_size': 800}]}, 'alpr': {'general': {'same_model_sequence_strategy': 'first', 'pre_existing_labels': ['car', 'motorbike', 'bus', 'truck', 'boat'], 'pattern': '.*'}, 'sequence': [{'alpr_api_type': 'cloud', 'alpr_service': 'plate_recognizer', 'alpr_key': 'your_plate_recognizer_api_key', 'platrec_stats': 'yes', 'platerec_min_dscore': 0.1, 'platerec_min_score': 0.2, 'max_size': 1600}]}}, 'stream_sequence': {'frame_strategy': 'most_models', 'frame_set': 'snapshot,alarm', 'contig_frames_before_error': 5, 'max_attempts': 3, 'sleep_between_attempts': 4, 'resize': 800, 'api': <pyzm.api.ZMApi object at 0x7f32a9f612b0>, 'polygons': [{'name': 'parking_pad', 'value': [(988, 568), (1810, 293), (1920, 316), (1920, 1080), (0, 1080), (0, 845)], 'pattern': None}]}, 'object_detection_pattern': '(person|car|dog|cat|truck)', 'object_framework': 'opencv', 'object_processor': 'cpu', 'object_config': '/var/lib/zmeventnotification/models/yolov3/yolov3.cfg', 'object_weights': '/var/lib/zmeventnotification/models/yolov3/yolov3.weights', 'object_labels': '/var/lib/zmeventnotification/models/yolov3/coco.names', 'object_min_confidence': 0.4, 'face_detection_pattern': '.*', 'face_detection_framework': 'dlib', 'face_recognition_framework': 'dlib', 'face_processor': 'cpu', 'face_num_jitters': 1, 'face_upsample_times': 2, 'face_model': 'cnn', 'face_train_model': 'cnn', 'face_recog_dist_threshold': 0.6, 'face_recog_knn_algo': 'ball_tree', 'known_images_path': '/var/lib/zmeventnotification/known_faces', 'unknown_images_path': '/var/lib/zmeventnotification/unknown_faces', 'unknown_face_name': 'Stranger', 'save_unknown_faces': 'yes', 'save_unknown_faces_leeway_pixels': 100, 'alpr_service': 'plate_recognizer', 'alpr_detection_pattern': '.*', 'alpr_url': None, 'alpr_key': 'your_plate_recognizer_api_key', 'alpr_use_after_detection_only': 'yes', 'alpr_api_type': 'cloud', 'platerec_stats': 'yes', 'platerec_regions': None, 'platerec_min_dscore': 0.1, 'platerec_min_score': 0.2, 'openalpr_recognize_vehicle': 0, 'openalpr_country': 'us', 'openalpr_state': None, 'openalpr_min_confidence': 0.3, 'openalpr_cmdline_binary': 'alpr', 'openalpr_cmdline_params': '-j -d', 'openalpr_cmdline_min_confidence': 0.3, 'yolo4_object_weights': '/var/lib/zmeventnotification/models/yolov4/yolov4.weights', 'yolo4_object_labels': '/var/lib/zmeventnotification/models/yolov4/coco.names', 'yolo4_object_config': '/var/lib/zmeventnotification/models/yolov4/yolov4.cfg', 'yolo4_object_framework': 'opencv', 'yolo4_object_processor': 'cpu', 'parking_pad': '988,568 1810,293 1920,316 1920,1080 0,1080 0,845', 'det_mode': 'object', 'car_past_det_max_diff_area': '43%', 'truck_past_det_max_diff_area': '43%', 'person_det_max_diff_area': '10%'}]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 zm_detect.py:411 [TYLER : stream= 735]

03/29/21 20:00:47 zmesdetect_m6[2764] DBG1 zm_detect.py:412 [TYLER : stream_options= {'frame_strategy': 'most_models', 'frame_set': 'snapshot,alarm', 'contig_frames_before_error': 5, 'max_attempts': 3, 'sleep_between_attempts': 4, 'resize': 800, 'api': <pyzm.api.ZMApi object at 0x7f32a9f612b0>, 'polygons': [{'name': 'parking_pad', 'value': [(988, 568), (1810, 293), (1920, 316), (1920, 1080), (0, 1080), (0, 845)], 'pattern': None}]}]
pliablepixels commented 3 years ago

Try again - you will have to update ES (the problematic code is not in pyzm)

ghost commented 3 years ago

I will try again tonight. I did clone the repo and do sudo ./install.sh for the new ES, pyzm and zmes helpers.

ghost commented 3 years ago

It seems to complete detections now using todays build but it isnt removing past detections. IDK if I should keep this issue open here or close it and open in zmeventnotification? gist of the log doing 3 back to back manual debug runs on same event. truck and car set to 43%, person set to 0% (I had it set up to skip removing an object if set to 0 in my old workaround). I dont see it saying "removing past detections" anymore either.

Fresh reinstall of es, pyzm and zmes_hook_helpers. https://gist.github.com/tylersprice84/7d3d999ba24a2f82ccf8f9e8c5c83a0b

ghost commented 3 years ago

pyzm was downgraded to 3.40 so I could reintegrate my old workaround for the time being.

pliablepixels commented 3 years ago

They need to be inside ML sequence https://github.com/pliablepixels/mlapi/blob/master/mlapiconfig.ini#L277

ghost commented 3 years ago
04/01/21 23:25:02 zmesdetect_m6[2464] DBG2 zm_detect.py:327 [using ml_sequence]

04/01/21 23:25:02 zmesdetect_m6[2464] FAT zm_detect.py:542 [Unrecoverable error:invalid syntax (<unknown>, line 25) Traceback:Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 537, in <module>
    main_handler()
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 331, in main_handler
    ml_options = ast.literal_eval(ml_options)
  File "/usr/lib/python3.8/ast.py", line 59, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/usr/lib/python3.8/ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 25
    'person_past_det_max_diff_area': '13%',
                                   ^
SyntaxError: invalid syntax
]
pliablepixels commented 3 years ago

Recheck how you added it. It’s likely you missed a comma above it or something else. Also did not understand your comment on pyzm downgrade. Make sure you are on the latest versions so I’m not trying to figure out hybrid library version effects.

ghost commented 3 years ago

The pyzm comment; I downgraded from pyzm 0.3.41 back to 3.40 so I could still run my old workaround stuff in between testing the new commits. So when I reinstall ES it upgrades me to new zmes_helpers and pyzm. Just wanted to clarify why it said going from 3.40 to 3.41. There was a missing comma in the last error.

I have my ML setup as so and am still not seeing "Removing past detections" and all objects are allowed through.

# Very important: Make sure final ending brace is indented 
stream_sequence = {
        'frame_strategy': 'most',
        'frame_set': 'snapshot,alarm',
        'contig_frames_before_error': 5,
        'max_attempts': 3,
        'sleep_between_attempts': 4,
        'resize':800

    }

# Chain of ML models to use
# See https://zmeventnotification.readthedocs.io/en/latest/guides/hooks.html#understanding-detection-configuration
# Also see https://pyzm.readthedocs.io/en/latest/source/pyzm.html#pyzm.ml.detect_sequence.DetectSequence
# Very important: Make sure final ending brace is indented 
ml_sequence= {
        'general': {
            'model_sequence': '{{det_mode}}',
            'disable_locks': '{{disable_locks}}',

        },
        'object': {
            'general':{
                'pattern':'{{object_detection_pattern}}',
                'same_model_sequence_strategy': 'most' # also 'most', 'most_unique's
            },
            'sequence': [{
                # YoloV4 on GPU and CPU
                'object_config':'{{yolo4_object_config}}',
                'object_weights':'{{yolo4_object_weights}}',
                'object_labels': '{{yolo4_object_labels}}',
                'object_min_confidence': {{object_min_confidence}},
                'object_framework':'{{yolo4_object_framework}}',
                'object_processor': '{{yolo4_object_processor}}',
                'gpu_max_processes': {{gpu_max_processes}},
                'gpu_max_lock_wait': {{gpu_max_lock_wait}},
                'cpu_max_processes': {{cpu_max_processes}},
                'cpu_max_lock_wait': {{cpu_max_lock_wait}},
                                'max_detection_size':'{{max_detection_size}}',
                                'match_past_detections':'yes',
                'person_past_det_max_diff_area': '13%',

                                'model_width': 512, 
                                'model_height': 512

            }]
        },
        'face': {
            'general':{
                'pattern': '{{face_detection_pattern}}',
                'same_model_sequence_strategy': 'first'
            },
            'sequence': [{
                'save_unknown_faces':'{{save_unknown_faces}}',
                'save_unknown_faces_leeway_pixels':{{save_unknown_faces_leeway_pixels}},
                'face_detection_framework': '{{face_detection_framework}}',
                'known_images_path': '{{known_images_path}}',
                'unknown_images_path': '{{unknown_images_path}}',
                'face_model': '{{face_model}}',
                'face_train_model': '{{face_train_model}}',
                'face_recog_dist_threshold': '{{face_recog_dist_threshold}}',
                'face_num_jitters': '{{face_num_jitters}}',
                'face_upsample_times':'{{face_upsample_times}}',
                'gpu_max_processes': {{gpu_max_processes}},
                'gpu_max_lock_wait': {{gpu_max_lock_wait}},
                'cpu_max_processes': {{cpu_max_processes}},
                'cpu_max_lock_wait': {{cpu_max_lock_wait}},
                'max_size':800
            }]
        },

        'alpr': {
            'general':{
                'same_model_sequence_strategy': 'first',
                'pre_existing_labels':['car', 'motorbike', 'bus', 'truck', 'boat'],
                'pattern': '{{alpr_detection_pattern}}'

            },
            'sequence': [{
                'alpr_api_type': '{{alpr_api_type}}',
                'alpr_service': '{{alpr_service}}',
                'alpr_key': '{{alpr_key}}',
                'platrec_stats': '{{platerec_stats}}',
                'platerec_min_dscore': {{platerec_min_dscore}},
                'platerec_min_score': {{platerec_min_score}},
                'max_size':1600
            }]
        }
    }   
04/02/21 13:12:20 zmesdetect_m6[11495] DBG1 yolo.py:147 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 512w*512h) ----------|]

04/02/21 13:12:21 zmesdetect_m6[11495] DBG2 yolo.py:69 [Released pyzm_uid33_cpu_lock portalock]

04/02/21 13:12:21 zmesdetect_m6[11495] DBG1 yolo.py:173 [perf: processor:cpu Yolo detection took: 1431.29 ms]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 yolo.py:208 [perf: processor:cpu Yolo NMS filtering took: 2.68 ms]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 object.py:59 [core model detection over, got 3 objects. Now filtering]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 object.py:63 [Max object size found to be: 90%]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 object.py:71 [Converted 90% to 324000.0]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 object.py:94 [Returning filtered list of 3 objects.]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG4 detect_sequence.py:636 [This model iteration inside object found: labels: ['person', 'cat', 'car'],conf:[0.9909704327583313, 0.87347412109375, 0.8391774892807007]]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:367 [Max object size found to be: 90%]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 detect_sequence.py:375 [Converted 90% to 324000.0]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:441 [intersection: comparing object:person,POLYGON ((348 100, 470 100, 470 268, 348 268, 348 100)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 detect_sequence.py:459 [Using global match pattern: (person|car|dog|cat|truck)]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:467 [parking_pad intersects object:person[[(348, 100), (470, 100), (470, 268), (348, 268)]]]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:441 [intersection: comparing object:cat,POLYGON ((504 190, 576 190, 576 276, 504 276, 504 190)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 detect_sequence.py:459 [Using global match pattern: (person|car|dog|cat|truck)]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:467 [parking_pad intersects object:cat[[(504, 190), (576, 190), (576, 276), (504, 276)]]]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:441 [intersection: comparing object:car,POLYGON ((107 128, 641 128, 641 452, 107 452, 107 128)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 detect_sequence.py:459 [Using global match pattern: (person|car|dog|cat|truck)]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG3 detect_sequence.py:467 [parking_pad intersects object:car[[(107, 128), (641, 128), (641, 452), (107, 452)]]]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG2 yolo.py:65 [pyzm_uid33_cpu_lock portalock already released]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG1 detect_sequence.py:759 [perf: TOTAL detection sequence (with image loads) took: 5599.06 ms  to process 735]

04/02/21 13:12:22 zmesdetect_m6[11495] INF zm_detect.py:459 [Prediction string:[a] detected:person:99% cat:87% car:84% ]

04/02/21 13:12:22 zmesdetect_m6[11495] DBG1 zm_detect.py:461 [Prediction string JSON:{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[a] detected:person:99% cat:87% car:84% --SPLIT--{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
04/02/21 13:12:22 zmesdetect_m6[11495] DBG1 zm_detect.py:538 [Closing logs]
ghost commented 3 years ago
04/02/21 14:11:06 zmesdetect_m6[13357] DBG4 detect_sequence.py:653 [REMOVE ME: Self m options: {'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.5, 'object_framework': 'opencv', 'object_processor': 'cpu', 'gpu_max_processes': 1, 'gpu_max_lock_wait': 100, 'cpu_max_processes': 3, 'cpu_max_lock_wait': 100, 'max_detection_size': '90%', 'match_past_detections': 'yes', 'past_det_max_diff_area': '13%', 'show_models': 'yes', 'model_width': 512, 'model_height': 512, 'disable_locks': 'no'}]

04/02/21 14:11:06 zmesdetect_m6[13357] DBG4 detect_sequence.py:655 [TYLER : mpd = yes]
04/02/21 14:14:14 zmesdetect_m6[13425] DBG4 detect_sequence.py:655 [TYLER : mpd = yes self.stream_options.get('mid') = None]

seems to be the mid number getting lost somewhere.

04/02/21 14:20:03 zmesdetect_m6[13567] DBG4 detect_sequence.py:655 [TYLER : mpd = yes self.stream_options = {'frame_strategy': 'most', 'frame_set': 'snapshot,alarm', 'contig_frames_before_error': 5, 'max_attempts': 3, 'sleep_between_attempts': 4, 'resize': 800, 'api': <pyzm.api.ZMApi object at 0x7f49bcb002b0>, 'polygons': [{'name': 'parking_pad', 'value': [(988, 568), (1810, 293), (1920, 316), (1920, 1080), (0, 1080), (0, 845)], 'pattern': None}]}]
vikmaks1 commented 3 years ago

I am struggling with the same problem - past detection does not work at all (no data in debug logs about it even trying). Found out the problem is also missing Monitor id in detect_sequence.py (656), just as @tylersprice84 mentions if mpd == 'yes' and self.stream_options.get('mid'):

pliablepixels commented 3 years ago

Yup it is - looks like I did not update objectconfig handing code with mid. However, there are other things that are broken as well in match_past, working on it.

pliablepixels commented 3 years ago

Okay give master versions a try please. I've tested with both mlapi and without. I've not made formal releases yet - will do after you confirm

mlapi: 2.2.13 pyzm: 0.3.44 es: 6.1.19

Note that all the match_past_detection/etc stuff now need to be in the general section of ml_sequence

ml_sequence= {
        'general': {
            'model_sequence': 'object,face,alpr',
                          'disable_locks': '{{disable_locks}}',
            'match_past_detections': '{{match_past_detections}}',
            'past_det_max_diff_area': '5%',
            'car_past_det_max_diff_area': '10%'

        },
ghost commented 3 years ago

Still isnt trying to remove past detections ml as so ->

ml_sequence= {
        'general': {
            'model_sequence': '{{det_mode}}',
                        'match_past_detections':'yes',
                    'car_past_det_max_diff_area': '43%',
            'disable_locks': '{{disable_locks}}',

        },
        'object': {
            'general':{
                'pattern':'{{object_detection_pattern}}',
                'same_model_sequence_strategy': 'most' # also 'most', 'most_unique's
            },
            'sequence': [{
                # YoloV4 on GPU and CPU
                'object_config':'{{yolo4_object_config}}',
                'object_weights':'{{yolo4_object_weights}}',
                'object_labels': '{{yolo4_object_labels}}',
                'object_min_confidence': {{object_min_confidence}},
                'object_framework':'{{yolo4_object_framework}}',
                'object_processor': '{{yolo4_object_processor}}',
                'gpu_max_processes': {{gpu_max_processes}},
                'gpu_max_lock_wait': {{gpu_max_lock_wait}},
                'cpu_max_processes': {{cpu_max_processes}},
                'cpu_max_lock_wait': {{cpu_max_lock_wait}},
                                'max_detection_size':'{{max_detection_size}}',
#               'show_models':'yes',

                                'model_width': 512, 
                                'model_height': 512

            }]
        },
        'face': {
            'general':{
                'pattern': '{{face_detection_pattern}}',
                'same_model_sequence_strategy': 'first'
            },
            'sequence': [{
                'save_unknown_faces':'{{save_unknown_faces}}',
                'save_unknown_faces_leeway_pixels':{{save_unknown_faces_leeway_pixels}},
                'face_detection_framework': '{{face_detection_framework}}',
                'known_images_path': '{{known_images_path}}',
                'unknown_images_path': '{{unknown_images_path}}',
                'face_model': '{{face_model}}',
                'face_train_model': '{{face_train_model}}',
                'face_recog_dist_threshold': '{{face_recog_dist_threshold}}',
                'face_num_jitters': '{{face_num_jitters}}',
                'face_upsample_times':'{{face_upsample_times}}',
                'gpu_max_processes': {{gpu_max_processes}},
                'gpu_max_lock_wait': {{gpu_max_lock_wait}},
                'cpu_max_processes': {{cpu_max_processes}},
                'cpu_max_lock_wait': {{cpu_max_lock_wait}},
                'max_size':800
            }]
        },

        'alpr': {
            'general':{
                'same_model_sequence_strategy': 'first',
                'pre_existing_labels':['car', 'motorbike', 'bus', 'truck', 'boat'],
                'pattern': '{{alpr_detection_pattern}}'

            },
            'sequence': [{
                'alpr_api_type': '{{alpr_api_type}}',
                'alpr_service': '{{alpr_service}}',
                'alpr_key': '{{alpr_key}}',
                'platrec_stats': '{{platerec_stats}}',
                'platerec_min_dscore': {{platerec_min_dscore}},
                'platerec_min_score': {{platerec_min_score}},
                'max_size':1600
            }]
        }
    }          

debug output of run #1 ->

04/03/21 11:13:02 zmesdetect_m6[10147] DBG1 yolo.py:148 [|---------- YOLO (input image: 800w*450h, model resize dimensions: 512w*512h) ----------|]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 yolo.py:69 [Released pyzm_uid33_cpu_lock portalock]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG1 yolo.py:174 [perf: processor:cpu Yolo detection took: 1249.68 ms]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 yolo.py:209 [perf: processor:cpu Yolo NMS filtering took: 2.65 ms]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 object.py:59 [core model detection over, got 3 objects. Now filtering]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 object.py:63 [Max object size found to be: 90%]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 object.py:71 [Converted 90% to 324000.0]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 object.py:94 [Returning filtered list of 3 objects.]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG4 detect_sequence.py:646 [This model iteration inside object found: labels: ['person', 'cat', 'car'],conf:[0.9909704327583313, 0.87347412109375, 0.8391774892807007]]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:376 [Max object size found to be: 90%]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 detect_sequence.py:384 [Converted 90% to 324000.0]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:450 [intersection: comparing object:person,POLYGON ((348 100, 470 100, 470 268, 348 268, 348 100)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:476 [parking_pad intersects object:person[[(348, 100), (470, 100), (470, 268), (348, 268)]]]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:450 [intersection: comparing object:cat,POLYGON ((504 190, 576 190, 576 276, 504 276, 504 190)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:476 [parking_pad intersects object:cat[[(504, 190), (576, 190), (576, 276), (504, 276)]]]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:450 [intersection: comparing object:car,POLYGON ((107 128, 641 128, 641 452, 107 452, 107 128)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG3 detect_sequence.py:476 [parking_pad intersects object:car[[(107, 128), (641, 128), (641, 452), (107, 452)]]]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG2 yolo.py:65 [pyzm_uid33_cpu_lock portalock already released]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG1 detect_sequence.py:774 [perf: TOTAL detection sequence (with image loads) took: 4832.97 ms  to process 735]

04/03/21 11:13:04 zmesdetect_m6[10147] INF zm_detect.py:462 [Prediction string:[a] detected:person:99% cat:87% car:84% ]

04/03/21 11:13:04 zmesdetect_m6[10147] DBG1 zm_detect.py:464 [Prediction string JSON:{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[a] detected:person:99% cat:87% car:84% --SPLIT--{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
04/03/21 11:13:04 zmesdetect_m6[10147] DBG1 zm_detect.py:541 [Closing logs]

Run #2 ->

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 yolo.py:69 [Released pyzm_uid33_cpu_lock portalock]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG1 yolo.py:174 [perf: processor:cpu Yolo detection took: 1237.69 ms]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 yolo.py:209 [perf: processor:cpu Yolo NMS filtering took: 2.57 ms]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 object.py:59 [core model detection over, got 3 objects. Now filtering]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 object.py:63 [Max object size found to be: 90%]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 object.py:71 [Converted 90% to 324000.0]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 object.py:94 [Returning filtered list of 3 objects.]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG4 detect_sequence.py:646 [This model iteration inside object found: labels: ['person', 'cat', 'car'],conf:[0.9909704327583313, 0.87347412109375, 0.8391774892807007]]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:376 [Max object size found to be: 90%]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 detect_sequence.py:384 [Converted 90% to 324000.0]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:450 [intersection: comparing object:person,POLYGON ((348 100, 470 100, 470 268, 348 268, 348 100)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:476 [parking_pad intersects object:person[[(348, 100), (470, 100), (470, 268), (348, 268)]]]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:450 [intersection: comparing object:cat,POLYGON ((504 190, 576 190, 576 276, 504 276, 504 190)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:476 [parking_pad intersects object:cat[[(504, 190), (576, 190), (576, 276), (504, 276)]]]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:450 [intersection: comparing object:car,POLYGON ((107 128, 641 128, 641 452, 107 452, 107 128)) to polygon:parking_pad,POLYGON ((411 236, 754 122, 800 131, 800 450, 0 450, 0 352, 411 236))]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 detect_sequence.py:468 [Using global match pattern: (person|car|dog|cat|truck)]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG3 detect_sequence.py:476 [parking_pad intersects object:car[[(107, 128), (641, 128), (641, 452), (107, 452)]]]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG2 yolo.py:65 [pyzm_uid33_cpu_lock portalock already released]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG1 detect_sequence.py:774 [perf: TOTAL detection sequence (with image loads) took: 4998.51 ms  to process 735]

04/03/21 11:13:29 zmesdetect_m6[10214] INF zm_detect.py:462 [Prediction string:[a] detected:person:99% cat:87% car:84% ]

04/03/21 11:13:29 zmesdetect_m6[10214] DBG1 zm_detect.py:464 [Prediction string JSON:{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}]

[a] detected:person:99% cat:87% car:84% --SPLIT--{"labels": ["person", "cat", "car"], "boxes": [[348, 100, 470, 268], [504, 190, 576, 276], [107, 128, 641, 452]], "frame_id": "alarm", "confidences": [0.9909704327583313, 0.87347412109375, 0.8391774892807007], "image_dimensions": {"original": [1080, 1920], "resized": [450, 800]}}
04/03/21 11:13:29 zmesdetect_m6[10214] DBG1 zm_detect.py:541 [Closing logs]
ghost commented 3 years ago

Nvm, I pulled pyzm and now it works. The only thing I ask is to add a bypass mode. Say If I want to only remove past detections of cars and not person. Currently if I set person to 0% it still removes the object. Also is there any chance of using this same system for per object confidence filtering? Again say I have a camera at a weird angle that detects people well (usually 75+ % condfidence) and car is usally (35-45 % confidence), If i have the confidence down that low globally I get alot of false positives. I have implemented something that works for my use case but I can see it being useful for others.

pliablepixels commented 3 years ago

Currently if I set person to 0% it still removes the object.

Do you mean person_past_det_max_diff_area? If so, that is not how it is supposed to work. This refers to the difference in area between a previous detection and the new one. When set to 0 all it does is make the match exact.

Say If I want to only remove past detections of cars and not person.

Possible use-case. I may add this.

Also is there any chance of using this same system for per object confidence filtering

Not as of now. I don't want to keep adding all sorts of variations.

ghost commented 3 years ago

I noticed sometimes due to per monitor variable settings, {{variable}} was getting passed without a value set. Just a small thing to catch it and set to global default if that happens ->

          g.logger.Debug(4, 'Found {}={}'.format(label_max_diff_area, mda))
               if str(mda).startswith('{{') and str(mda).endwith('}}'):
                   g.logger.Debug(4, '{{variable}} detected but it is not set with a value, using global default')
                   mda = str(global_max_diff_area)
               _m = re.match('(\d+)(px|%)?$',mda,re.IGNORECASE)
pliablepixels commented 3 years ago

This is not the right way to fix it. If {{ is being passed after process_config, then some variable substitution has failed. It needs to be fixed there. What did you try and put and what did not get changed?

ghost commented 3 years ago

I didnt have a global person_past_det_max_diff_area set. Only had it set per monitor but only certain monitors. The ml_sequence is 'person_past_det_max_diff_area': '{{person_past_det_max_diff_area}}', and on some monitors because of no global it sent the {{variable}} unset and failed due to misformatted. Just thought it might be useful to keep the filter going.

pliablepixels commented 3 years ago

I'll take a look. That should not be happening, and if it is, it is a bug that needs to be fixed during parameter substitution. This may well be another thing I did not fix in zm_detect but did it in mlapi.

pliablepixels commented 3 years ago

Please update to master version of ES, I've added some logs I'd like to see in your situation where you see {{.

pliablepixels commented 3 years ago

ARGH I should read and think more. I finally understood what you said. Hmm. Agree.

pliablepixels commented 3 years ago

try now (master)

ghost commented 3 years ago

Yes it solves that issue.