blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
17.99k stars 1.64k forks source link

[Config Support]: Resize Error #7330

Closed twister36 closed 1 year ago

twister36 commented 1 year ago

Describe the problem you are having

Hey guys,

I am getting a resize error on the latest.jpg after moving the camera height and width setting from the main "detect" section to the "camera" section. I did this because not all my camera have the same resolution. However, after doing this I get this error in the logs.

Am I doing something wrong by moving the height and width to each camera?

Version

0.12.1-367d724

Frigate config file

mqtt:
  enabled: True
  host: [ip-address]
  user: [user]
  password: [password]

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
 hwaccel_args: preset-rpi-64-h264

#birdseye:
#  enabled: True
#  mode: continuous

cameras:
  front_door: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - detect
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=1&subtype=1
          roles:
            - record
    detect:
      enabled: True 
      fps: 2
      max_disappeared: 25
      width: 704
      height: 408
    objects:
      track:
        - person
        - dog
        - cat
        # - car
        # - motorcycle
    snapshots:
      enabled: True
      timestamp: False
      bounding_box: True
      retain:
        default: 10
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 480
    motion:
      mask:
        - 495,0,704,0,704,183,630,291,473,172   #waterfall
        - 418,0,390,128,273,133,263,0           #flag

  front_yard: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=6&subtype=1
          roles:
            - detect
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=6&subtype=1
          roles:
            - record
    detect:
      enabled: True 
      fps: 5
      max_disappeared: 25
      width: 704
      height: 408
    objects:
      track:
        - person
        - car
        - motorcycle
        - dog
        - cat
    snapshots:
      enabled: True
      timestamp: False
      bounding_box: True
      retain:
        default: 10
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 480
    motion:
      mask:
        - 0,480,136,480,155,413,160,344,143,309,160,278,186,195,145,90,0,95

  driveway: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=7&subtype=1
          roles:
            - detect
        - path: rtsp://[user]:[password]@[ip-address]:554/cam/realmonitor?channel=7&subtype=1
          roles:
            - record
    detect:
      enabled: True 
      fps: 5
      max_disappeared: 25
      width: 704
      height: 408
    objects:
      track:
        - person
        - car
        - motorcycle
        - dog
        - cat
    snapshots:
      enabled: True
      timestamp: False
      bounding_box: True
      retain:
        default: 10
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 480
    motion:
      mask:
        - 0,104,60,131,86,214,52,257,82,281,89,313,67,345,39,382,0,389,0,366

# detect:
#   enabled: True # moved to each camera
#   fps: 5 # moved to each camera
#   max_disappeared: 25 # moved to each camera
#   width: 704 # moved to each camera
#   height: 480 # moved to each camera

Relevant log output

2023-07-29 17:32:14.598314672  [INFO] Starting Frigate...
2023-07-29 17:32:17.676804106  [2023-07-29 17:32:17] frigate.app                    INFO    : Starting Frigate (0.12.1-367d724)
2023-07-29 17:32:17.772623460  [2023-07-29 17:32:17] peewee_migrate                 INFO    : Starting migrations
2023-07-29 17:32:17.784681552  [2023-07-29 17:32:17] peewee_migrate                 INFO    : There is nothing to migrate
2023-07-29 17:32:17.850105466  [2023-07-29 17:32:17] frigate.app                    INFO    : Output process started: 292
2023-07-29 17:32:17.857720132  [2023-07-29 17:32:17] detector.coral                 INFO    : Starting detection process: 290
2023-07-29 17:32:17.858432864  [2023-07-29 17:32:17] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-07-29 17:32:17.924516714  [2023-07-29 17:32:17] frigate.app                    INFO    : Camera processor started for front_door: 296
2023-07-29 17:32:17.996243107  [2023-07-29 17:32:17] frigate.app                    INFO    : Camera processor started for front_yard: 298
2023-07-29 17:32:17.997330260  [2023-07-29 17:32:17] frigate.app                    INFO    : Camera processor started for driveway: 301
2023-07-29 17:32:17.998106491  [2023-07-29 17:32:17] frigate.app                    INFO    : Capture process started for front_door: 302
2023-07-29 17:32:18.001513412  [2023-07-29 17:32:17] frigate.app                    INFO    : Capture process started for front_yard: 304
2023-07-29 17:32:18.021768902  [2023-07-29 17:32:18] frigate.app                    INFO    : Capture process started for driveway: 306
2023-07-29 17:32:20.709611696  [2023-07-29 17:32:20] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-07-29 18:09:55.775136404  [2023-07-29 18:09:55] frigate.http                   ERROR   : Exception on /driveway/latest.jpg [GET]
2023-07-29 18:09:55.775150978  Traceback (most recent call last):
2023-07-29 18:09:55.775166848    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2529, in wsgi_app
2023-07-29 18:09:55.775172700      response = self.full_dispatch_request()
2023-07-29 18:09:55.775177552    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
2023-07-29 18:09:55.775252107      rv = self.handle_user_exception(e)
2023-07-29 18:09:55.775257181    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
2023-07-29 18:09:55.775262292      rv = self.dispatch_request()
2023-07-29 18:09:55.775266292    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
2023-07-29 18:09:55.775377513      return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-07-29 18:09:55.775382327    File "/opt/frigate/frigate/http.py", line 897, in latest_frame
2023-07-29 18:09:55.775386531      frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)
2023-07-29 18:09:55.775393457  cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/resize.cpp:4055: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'
2023-07-29 18:09:55.775461567  
2023-07-29 18:09:55.937245019  [2023-07-29 18:09:55] frigate.http                   ERROR   : Exception on /front_door/latest.jpg [GET]
2023-07-29 18:09:55.937257704  Traceback (most recent call last):
2023-07-29 18:09:55.937260611    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2529, in wsgi_app
2023-07-29 18:09:55.937262723      response = self.full_dispatch_request()
2023-07-29 18:09:55.937265408    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
2023-07-29 18:09:55.937267130      rv = self.handle_user_exception(e)
2023-07-29 18:09:55.937269630    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
2023-07-29 18:09:55.937271204      rv = self.dispatch_request()
2023-07-29 18:09:55.937273648    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
2023-07-29 18:09:55.937275852      return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-07-29 18:09:55.937277833    File "/opt/frigate/frigate/http.py", line 897, in latest_frame
2023-07-29 18:09:55.937280074      frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)
2023-07-29 18:09:55.937283167  cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/resize.cpp:4055: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'
2023-07-29 18:09:55.937284333  
2023-07-29 18:09:55.972666924  [2023-07-29 18:09:55] frigate.http                   ERROR   : Exception on /front_yard/latest.jpg [GET]
2023-07-29 18:09:55.972678980  Traceback (most recent call last):
2023-07-29 18:09:55.972681943    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2529, in wsgi_app
2023-07-29 18:09:55.972684054      response = self.full_dispatch_request()
2023-07-29 18:09:55.972686776    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
2023-07-29 18:09:55.972688591      rv = self.handle_user_exception(e)
2023-07-29 18:09:55.972691128    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
2023-07-29 18:09:55.972692776      rv = self.dispatch_request()
2023-07-29 18:09:55.972695220    File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
2023-07-29 18:09:55.972697461      return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2023-07-29 18:09:55.972699479    File "/opt/frigate/frigate/http.py", line 897, in latest_frame
2023-07-29 18:09:55.972701739      frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)
2023-07-29 18:09:55.972704813  cv2.error: OpenCV(4.5.5) /io/opencv/modules/imgproc/src/resize.cpp:4055: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'
2023-07-29 18:09:55.972706016

Frigate stats

{"cpu_usages":{"%Cpu(s):":{"cpu":"id,","mem":"0.0"},"1":{"cpu":"0.0","mem":"0.0"},"1000":{"cpu":"0.0","mem":"0.0"},"102":{"cpu":"2.3","mem":"2.0"},"113":{"cpu":"0.0","mem":"0.2"},"134":{"cpu":"0.0","mem":"0.1"},"135":{"cpu":"0.0","mem":"0.1"},"136":{"cpu":"0.0","mem":"0.1"},"137":{"cpu":"0.0","mem":"0.1"},"15":{"cpu":"0.0","mem":"0.0"},"17":{"cpu":"0.0","mem":"0.0"},"24":{"cpu":"0.0","mem":"0.0"},"25":{"cpu":"0.0","mem":"0.0"},"26":{"cpu":"0.0","mem":"0.0"},"27":{"cpu":"0.0","mem":"0.0"},"28":{"cpu":"0.0","mem":"0.0"},"283":{"cpu":"0.0","mem":"1.0"},"289":{"cpu":"0.7","mem":"0.1"},"29":{"cpu":"0.0","mem":"0.0"},"290":{"cpu":"0.0","mem":"1.3"},"292":{"cpu":"1.3","mem":"1.2"},"296":{"cpu":"0.7","mem":"1.1"},"298":{"cpu":"1.3","mem":"1.2"},"30":{"cpu":"0.0","mem":"0.0"},"300":{"cpu":"0.0","mem":"0.5"},"301":{"cpu":"1.3","mem":"1.2"},"302":{"cpu":"0.7","mem":"1.0"},"303":{"cpu":"0.0","mem":"0.5"},"304":{"cpu":"2.0","mem":"1.0"},"306":{"cpu":"1.7","mem":"1.0"},"31":{"cpu":"0.0","mem":"0.0"},"311":{"cpu":"0.0","mem":"0.8"},"314":{"cpu":"22.6","mem":"0.6"},"315":{"cpu":"13.6","mem":"0.6"},"316":{"cpu":"0.0","mem":"0.8"},"318":{"cpu":"23.3","mem":"0.6"},"32":{"cpu":"0.0","mem":"0.0"},"40":{"cpu":"0.0","mem":"0.0"},"45":{"cpu":"0.0","mem":"0.0"},"79":{"cpu":"0.0","mem":"0.0"},"81":{"cpu":"0.0","mem":"0.0"},"83":{"cpu":"0.0","mem":"0.0"},"89":{"cpu":"0.0","mem":"0.2"},"99":{"cpu":"0.0","mem":"0.0"},"991":{"cpu":"0.0","mem":"0.0"},"MiB":{"cpu":"6875.8","mem":"avail"},"PID":{"cpu":"%CPU","mem":"%MEM"},"Tasks:":{"cpu":"stopped,","mem":"0"},"top":{"cpu":"users,","mem":"load"}},"detection_fps":0.0,"detectors":{"coral":{"detection_start":0.0,"inference_speed":14.87,"pid":290}},"driveway":{"camera_fps":5.0,"capture_pid":306,"detection_enabled":1,"detection_fps":0.0,"ffmpeg_pid":314,"pid":301,"process_fps":5.0,"skipped_fps":0.0},"front_door":{"camera_fps":2.0,"capture_pid":302,"detection_enabled":1,"detection_fps":0.0,"ffmpeg_pid":315,"pid":296,"process_fps":2.0,"skipped_fps":0.0},"front_yard":{"camera_fps":5.1,"capture_pid":304,"detection_enabled":1,"detection_fps":0.0,"ffmpeg_pid":318,"pid":298,"process_fps":5.1,"skipped_fps":0.0},"gpu_usages":{"rpi-v4l2m2m":{"gpu":-1,"mem":-1}},"service":{"last_updated":1690676265,"latest_version":"0.12.1","storage":{"/dev/shm":{"free":64.2,"mount_type":"tmpfs","total":67.1,"used":2.9},"/media/frigate/clips":{"free":234601.1,"mount_type":"ext4","total":251735.3,"used":6844.5},"/media/frigate/recordings":{"free":234601.1,"mount_type":"ext4","total":251735.3,"used":6844.5},"/tmp/cache":{"free":1000.0,"mount_type":"tmpfs","total":1000.0,"used":0.0}},"temperatures":{},"uptime":2727,"version":"0.12.1-367d724"}}

Operating system

Debian

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

This error isn't related to making that change, it is a known issue in 0.12.1 and has been fixed for 0.13

twister36 commented 1 year ago

@NickM-27 - ok? I am confused, because if I uncomment the main "detect" section I don't get the error in my logs.

NickM-27 commented 1 year ago

The issue is due to the webUI loading the image before it has the correct size information. It doesn't always happen because it depends when the webUI is loaded versus when frigate knows the size of the browser window.