blakeblackshear / frigate

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

[Detector Support]: process frigate.detector.coral High CPU usage #6873

Closed KCH0000 closed 1 year ago

KCH0000 commented 1 year ago

Describe the problem you are having

In the latest update, frigate uses a lot of CPU. hardware acceleration for ffmpeg works fine, but the detector is high cpu usage. Сhanging the resolution of the image does not change the load on the processor

Version

0.12.1-367d724

Frigate config file

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args: preset-vaapi 
objects:
  # Optional: list of objects to track from labelmap.txt (default: shown below)
  track:
    - person
    - car
birdseye:
  enabled: False 
  mode: continuous

snapshots:
  enabled: True
  # Optional: save a clean PNG copy of the snapshot image (default: shown below)
  clean_copy: True
  # Optional: print a timestamp on the snapshots (default: shown below)
  timestamp: True
  bounding_box: True

cameras:
  observation_camera: # <------ Name the camera
      ffmpeg:
        inputs:
          - path: rtsp://admin:admin@192.168.104.21:554/live/main # <----- Update for your camera
            roles:
              - detect
              - record
      rtmp:
        enabled: False # <-- RTMP should be disabled if your stream is not H264
      detect:
        width: 1920 # <---- update for your camera's resolution
        height: 1080 # <---- update for your camera's resolution
        enabled: True
        fps: 5
      zones:
        in_front_trash_can_zone:
          coordinates: 1920,492,1920,1080,1208,1080,796,465,1310,377,1366,168
          objects:
            - person
        inside_snt_zone:
          coordinates: 575,393,846,507,1208,1023,1920,1019,1583,619,1439,461,1314,345,1291,241,1199,200,932,163,342,203
          objects:
            - car
            - person
        in_front_gate_zone:
          coordinates: 1321,343,773,339,758,184,1204,188,1335,238
          objects:
            - car 
      snapshots:
        required_zones:
          - in_front_trash_can_zone
          - inside_snt_zone
      motion:
        mask:
          - 0,291,315,1080,439,337,514,365,628,411,779,512,945,736,1000,1080,0,1080
          - 688,0,1920,0,1920,352,1920,472,1506,218,1268,116,1090,81,973,58,854,58,703,46,684,0      
      record:
        enabled: True
        retain:
          days: 7
          mode: motion
        events:
          required_zones:
            - in_front_trash_can_zone
            - inside_snt_zone
          retain:
            default: 14
            mode: active_objects
  camera_in_gabage: # <------ Name the camera
      ffmpeg:
        inputs:
          - path: rtsp://admin:admin@192.168.104.22:554/live/main # <----- Update for your camera
            roles:
              - detect
              - record
      rtmp:
        enabled: False # <-- RTMP should be disabled if your stream is not H264
      detect:
        width: 1920 # <---- update for your camera's resolution
        height: 1080 # <---- update for your camera's resolution
        enabled: True
        fps: 5
      zones: 
        inside_gabage_zone:
          coordinates: 323,337,393,323,560,302,558,146,722,123,1264,363,1374,466,1051,1080,168,1080,195,770
          objects:
            - person
      snapshots:
        required_zones:
          - inside_gabage_zone     
      record:
        enabled: True
        retain:
          days: 7
          mode: motion
        events:
          required_zones:
            - inside_gabage_zone     
          retain:
            default: 14
            mode: active_objects
  camera_outside_snt: # <------ Name the camera
      ffmpeg:
        inputs:
          - path: rtsp://admin:admin@192.168.104.23:554/live/main # <----- Update for your camera
            roles:
              - detect
              - record
      rtmp:
        enabled: False # <-- RTMP should be disabled if your stream is not H264
      detect:
        width: 1920 # <---- update for your camera's resolution
        height: 1080 # <---- update for your camera's resolution
        enabled: True
        fps: 5
      zones: 
        outside_gate_zone:
          coordinates: 851,104,1127,127,1505,345,1920,676,1802,797,1383,1080,546,1080,555,311
          objects:
            - person
            - car  
      motion:
        mask:
          - 627,362,845,344,936,340,982,281,838,186,855,131,1100,133,1520,331,1745,449,1834,512,1920,576,1920,0,0,0,0,349,383,369
      snapshots:
        required_zones:
          - outside_gate_zone
      record:
        enabled: True
        retain:
          days: 7
          mode: motion 
        events:
          required_zones:
            - outside_gate_zone     
          retain:
            default: 14

docker-compose file or Docker CLI command

version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:dev-7c1568f-tensorrt 
    shm_size: "128mb" # update for your cameras based on calculation above
    devices:
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
      - /dev/dri:/dev/dri 
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config/config.yml:/config/config.yml:ro
      - ./db:/db
      - /mnt/regstorage:/media/frigate
    ports:
      - "5000:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      - LIBVA_DRIVER_NAME=i965

Relevant log output

2023-06-21 17:20:38.003644762  [INFO] Preparing Frigate...
2023-06-21 17:20:38.062448274  [INFO] Starting Frigate...
2023-06-21 17:20:40.305795752  [2023-06-21 17:20:40] frigate.app                    INFO    : Starting Frigate (0.13.0-7c1568f)
2023-06-21 17:20:40.305843375  [2023-06-21 17:20:40] frigate.app                    INFO    : Creating directory: /tmp/cache
2023-06-21 17:20:40.305882007  [2023-06-21 17:20:40] frigate.app                    INFO    : Creating directory: /config/model_cache
2023-06-21 17:20:40.412942534  [2023-06-21 17:20:40] peewee_migrate.logs            INFO    : Starting migrations
2023-06-21 17:20:40.416353081  [2023-06-21 17:20:40] peewee_migrate.logs            INFO    : There is nothing to migrate
2023-06-21 17:20:45.541232906  [2023-06-21 17:20:45] frigate.app                    INFO    : Recording process started: 435
2023-06-21 17:20:45.543572236  [2023-06-21 17:20:45] frigate.app                    INFO    : go2rtc process pid: 89
2023-06-21 17:20:45.560343051  [2023-06-21 17:20:45] detector.coral                 INFO    : Starting detection process: 444
2023-06-21 17:20:45.564142419  [2023-06-21 17:20:45] frigate.app                    INFO    : Output process started: 446
2023-06-21 17:20:45.568464515  [2023-06-21 17:20:45] frigate.app                    INFO    : Camera processor started for observation_camera: 452
2023-06-21 17:20:45.573047714  [2023-06-21 17:20:45] frigate.app                    INFO    : Camera processor started for camera_in_gabage: 453
2023-06-21 17:20:45.577758988  [2023-06-21 17:20:45] frigate.app                    INFO    : Camera processor started for camera_outside_snt: 456
2023-06-21 17:20:45.583048852  [2023-06-21 17:20:45] frigate.app                    INFO    : Capture process started for observation_camera: 458
2023-06-21 17:20:45.587972911  [2023-06-21 17:20:45] frigate.app                    INFO    : Capture process started for camera_in_gabage: 461
2023-06-21 17:20:45.593589242  [2023-06-21 17:20:45] frigate.app                    INFO    : Capture process started for camera_outside_snt: 465
2023-06-21 17:20:48.763834531  [2023-06-21 17:20:45] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-06-21 17:20:48.780412909  [2023-06-21 17:20:48] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found

Operating system

Other Linux

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

OS: Ubuntu server 22.04.2 LTS

Docker version 20.10.12, build e91ed57 изображение

NickM-27 commented 1 year ago

So it looks like you used 0.13 and then went back? that of course means the database is corrupt, like it shows in the logs. It is not clear what version you are referring to

KCH0000 commented 1 year ago

So it looks like you used 0.13 and then went back? that of course means the database is corrupt, like it shows in the logs. It is not clear what version you are referring to

yes, I tried to roll back the version, but it didn't change the situation. Now I have returned to the latest version and updated the issue

NickM-27 commented 1 year ago

Okay then this is a duplicate of https://github.com/blakeblackshear/frigate/issues/6861 and is related to motion settings being too sensitive which the next dev image should fix

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.