Frigate high CPU for stationary objects detection

Hi all,

I have a few cameras setup, 1 of them overlooks a busy road, i setup the motion mask so the road should be completely ignored, this worked fine for a week, today however I see high CPU usage reports for that camera, I checked in debug and I see that its constantly detecting (re-detecting?) stationary objects, I am not sure if this is expected behaviour.

This is a screenshot of the debug and I uploaded a video to the following link screencast_31-10-24_13.44.59

I have decent hardware Ryzen 7 5825U, 16GB RAM with a Coral M.2 Dual Edge TPU.

My frigate.yaml below:


mqtt:
  host: core-mosquitto
  port: 1833
  user: frigate
  password: password

detectors:
  coral:
    type: edgetpu
    device: pci

cameras:
  FrontCenter:
    enabled: true
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://frigate:[email protected]:554/Preview_01_sub
          input_args: preset-rtsp-restream
          roles:
            - audio
            - detect
        - path: rtsp://frigate:[email protected]:554/Preview_01_main
          input_args: preset-rtsp-restream
          roles:
            - record
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
    zones:
      FrontGarden_centercam:
        coordinates: 0,0.839,0.29,0.309,0.44,0.198,0.489,0.167,0.73,0.21,0.803,0.279,0.907,0.483,1,0.353,1,1,0.002,0.997
        loitering_time: 0
        inertia: 3
        objects:
          - car
          - person
          - bicycle
          - motorcycle
    record:
      enabled: true
      retain:
        days: 3
        mode: all
      events:
        retain:
          default: 30
          mode: motion
    review:
      alerts:
        required_zones: FrontGarden_centercam
      detections:
        required_zones: FrontGarden_centercam
    motion:
      threshold: 30
      contour_area: 10
      improve_contrast: "true"
      mask: 0.002,0.82,0.003,0.006,0.997,0.006,0.996,0.35,0.906,0.467,0.804,0.272,0.732,0.201,0.492,0.155,0.284,0.31
  SideFront:
    enabled: true
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://frigate:[email protected]:554/Preview_01_sub
          input_args: preset-rtsp-restream
          roles:
            - audio
            - detect
        - path: rtsp://frigate:[email protected]:554/Preview_01_main
          input_args: preset-rtsp-restream
          roles:
            - record
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
    zones:
      sideFrontCam:
        coordinates: 0.996,0.993,0.997,0.148,0.48,0.029,0.481,0.093,0.463,0.138,0.407,0.094,0.376,0.098,0.378,0,0.012,0.003,0.003,0.986
        loitering_time: 0
        inertia: 3
        objects:
          - person
          - bicycle
          - motorcycle
    record:
      enabled: true
      retain:
        days: 3
        mode: all
      events:
        retain:
          default: 30
          mode: motion
    review:
      alerts:
        required_zones: sideFrontCam
      detections:
        required_zones: sideFrontCam
    motion:
      mask: 0.996,0.142,0.48,0.028,0.479,0.099,0.463,0.124,0.406,0.09,0.377,0.093,0.378,0.005,1,0
  SideBack:
    enabled: true
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://frigate:[email protected]:554/Preview_01_sub
          input_args: preset-rtsp-restream
          roles:
            - audio
            - detect

        - path: rtsp://frigate:[email protected]:554/Preview_01_main
          input_args: preset-rtsp-restream
          roles:
            - record
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
    zones:
      sideBackCam:
        coordinates: 0.002,0.183,0.366,0.127,0.521,0.147,0.516,0.268,0.589,0.265,0.587,0.178,0.586,0.07,0.639,0.009,0.799,0.02,0.782,0.981,0.726,0.991,0.002,0.997
        loitering_time: 0
        inertia: 3
        objects:
          - person
          - bicycle
          - motorcycle
    record:
      enabled: true
      retain:
        days: 3
        mode: all
      events:
        retain:
          default: 30
          mode: motion
    review:
      alerts:
        required_zones: sideBackCam
      detections:
        required_zones: sideBackCam
    motion:
      mask: 0.002,0.18,0.001,0,0.629,0.002,0.581,0.063,0.582,0.254,0.522,0.259,0.525,0.139,0.368,0.119
  BackCenter:
    enabled: true
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://frigate:[email protected]:554/Preview_01_sub
          input_args: preset-rtsp-restream
          roles:
            - audio
            - detect
        - path: rtsp://frigate:[email protected]:554/Preview_01_main
          input_args: preset-rtsp-restream
          roles:
            - record
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
    zones:
      backGarden:
        coordinates: 0.097,1,0.1,0.786,0.236,0.492,0.301,0.57,0.419,0.328,0.491,0.161,0.505,0.217,0.593,0.207,0.613,0.17,0.688,0.301,0.756,0.325,0.777,0.353,0.819,0.419,0.881,0.514,1,0.554,0.994,0.709,0.963,1
        loitering_time: 0
        inertia: 3
        objects:
          - person
          - motorcycle
          - bicycle
    record:
      enabled: true
      retain:
        days: 3
        mode: all
      events:
        retain:
          default: 30
          mode: motion
    review:
      alerts:
        required_zones: backGarden
      detections:
        required_zones: backGarden
    motion:
      threshold: 50
      contour_area: 10
      improve_contrast: "true"
      mask: 0.191,0.35,0.307,0.133,0.403,0.003,0.72,0.006,0.807,0.102,0.913,0.241,0.883,0.511,0.782,0.35,0.76,0.31,0.692,0.288,0.62,0.167,0.591,0.192,0.511,0.207,0.493,0.142,0.396,0.362,0.304,0.56,0.232,0.48,0.215,0.52
version: 0.14


All help appreciated, thanks.

Could it be something as simple as wind shaking the camera - possibly loosened screws on the mount etc. - ?

Boy do i wish it was that :stuck_out_tongue:
Just checked, all secure and not enough wind to shake the leaves in the tree!

Looks like min area filter is needed for car. Also, using motion mask like that is not recommended

Thanks for your response, I am new to HA and Frigate please excuse my ignorance

From what I see min_area is for false positives, however in my case the issue is that it keeps trying to detect stationary objects, also if i were to make a min area for a car based on the car parked closest to the camera it will never detect any car as they will all be smaller (according to my understanding of min_area).

Also can you please elaborate or point me to where to find what’s wrong with the way I use motion mask.

Many thanks

we can see quite a few very small cars detected, so that is the value you would use for min_area, because you have shown this image with the mask I can’t see if they are true cars or not, but this is likely what is running the tracking. I would suggest setting the min_area to 1000

Thank you for that.
Regarding the small cars the issue is that most of the cars its detecting are stationary, I have now set a min_area of 5000 for cars and there are less detection of moving cars but still the same stationary cars are detected every second.

Regarding the motion mask, i read that page, thanks, I am covering a busy 6 lane road with no way to access the small road near the camera (small wall in between) I did adjust my motion mask accordingly and also added a object mask, but this isn’t doing anything for the detection of the stationary objects.

        loitering_time: 0
        inertia: 3
        objects:
          - car
          - person
          - bicycle
          - motorcycle
        filters:
          car:
            min_area: 5000

I attach another screenshot without the mask cover, this screenshot is at night and the small red detection boxes are from light reflection of the passing cars (not sure if there is any way to stop those).

there is a lot of motion detected here, you likely need to tune motion detection

Yes, those are just light reflection of passing cars, i changed the detection threshold to 60 and contour to 20 and saw a massive improvement.

I am still confused/puzzled about the the detection of stationary objects

If an object is properly marked as stationary the object box will be gray

Yes, but the grey boxes keep changing the certainty %, the car on the right side in the last picture hasn’t moved in weeks, yet in the last picture i posted it’s blue (maybe because it’s night?) and it changes many times per minutes, from 90% all the way down to 62%, is it normal for frigate to keep evaluating stationary objects?

Same for the items in blue boxes, they are all stationary for hours, is it normal behaviour for frigate to continually try to identify them?

I have to conclude this issue was mostly config/tuning related as it now seems ok.
Thanks everyone for your help - issue resolved.

1 Like