Frigate Motion Detection

Hi everyone,

So I’ve got frigate working and it occasionally detects objects. I’m using a coral via USB. I had this working at my last house with a Dell server and a coral pcie card. Since I moved last year I haven’t put my servers back online so that is why I’m using Frigate with the HA Add-On. My host is a HP Nuc with 4 x AMD GX-415GA SOC with Radeon™ HD Graphics (1 Socket) as its processor and it I gave the NUC 12GB of ram most of which is allocated to HA since I’m running under proxmox.
Here is some of my config but it pretty much repeats itself for all 6 cameras

birdseye:
  enabled: True
  mode: continuous

detectors:
  coral:
    type: edgetpu
    device: usb

database:
  path: /config/frigate.db

detect:
  # Optional: desired fps for your camera for the input with the detect role (default: shown below)
  # NOTE: Recommended value of 5. Ideally, try and reduce your FPS on the camera.
  fps: 10
  # Optional: enables detection for the camera (default: True)
  # This value can be set via MQTT and will be updated in startup based on retained value
  enabled: True
  # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
  max_disappeared: 50
  # Optional: Configuration for stationary object tracking
  stationary:
    # Optional: Frequency for confirming stationary objects (default: shown below)
    # When set to 0, object detection will not confirm stationary objects until movement is detected.
    # If set to 10, object detection will run to confirm the object still exists on every 10th frame.
    interval: 10
    # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s)
    threshold: 50
    # Optional: Define a maximum number of frames for tracking a stationary object (default: not set, track forever)
    # This can help with false positives for objects that should only be stationary for a limited amount of time.
    # It can also be used to disable stationary object tracking. For example, you may want to set a value for person, but leave
    # car at the default.
    # WARNING: Setting these values overrides default behavior and disables stationary object tracking.
    #          There are very few situations where you would want it disabled. It is NOT recommended to
    #          copy these values from the example config into your config unless you know they are needed.
    max_frames:
      # Optional: Default for all object types (default: not set, track forever)
      default: 3000
      # Optional: Object specific values
      objects:
        person: 1000
      
# Optional: Configuration for the jpg snapshots written to the clips directory for each event
# NOTE: Can be overridden at the camera level
snapshots:
  # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
  # This value can be set via MQTT and will be updated in startup based on retained value
  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: False
  # Optional: draw bounding box on the snapshots (default: shown below)
  bounding_box: False
  # Optional: crop the snapshot (default: shown below)
  crop: False
  # Optional: height to resize the snapshot to (default: original size)
  # Optional: Camera override for retention settings (default: global values)
  retain:
    # Required: Default retention days (default: shown below)
    default: 10
    # Optional: Per object retention days
    objects:
      person: 15

#Global Object Settings
objects:
  track:
    - person
    - cat
    - dog
    - car        


cameras:
  Front_Gate:
    birdseye:
      mode: objects
    ffmpeg:
      hwaccel_args:
        - -hwaccel_output_format
        - yuv420p
      input_args:
        - -avoid_negative_ts
        - make_zero 
      inputs:
        - path: http://192.168.x.x/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=oper&password=password
          roles:
            - detect
        - path: http://192.168.x.x/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=oper&password=password
          roles:
            - rtmp
    zones:
      Front_Gate_Driveway:
        coordinates: 201,0,0,480,640,480,640,145,339,0
        objects:
          - person
          - car
          - dog
          - cat
          - horse
    rtmp:
      enabled: True # <-- RTMP should be disabled if your stream is not H264
    detect:
      width: 640
      height: 480

This camera sits down at my gate and it looks like this
image
But it rarely ever detects that there is an object down there. I am using Reolink 520 cameras and I have the ext stream set to 10FPS
The Add-On consistently reports that its using 60+% of the CPU for it, so I’ve been trying to tweak what I can to reduce that. I have the height/width in the config set to match what the camera is pushing out so that way Frigate isn’t having to scale the image.
Here is an example from yesterday where there was clearly a vehicle down there but nothing was ever detected
image
I’m not sure what I’m doing wrong with this. I have other cameras as well that occasionally detect a dog or a person walking by them but its rare.
Sometimes I feel like it works really good after I restart the add-on but then it feels like it gives up after a bit.
Thank you all for your help with getting this drilled down

I see a lot of issues with your config. You are overriding the input_args but not including the default ones which are necessary. You also are setting hwaccel args incorrectly. You also copied the max_frames part of the reference config which is really discouraged and could be part of your issue as well.

Thank you for your reply. What are good hwaccel and input_args that should be set for this? Been digging around trying to find the optimal configs for this and this was the last bit that I found. I’m lowering the max frames to 100 to see what this does for me.

hwaccel args: Hardware Acceleration | Frigate
your input args you should probably just delete that config and let it use the default ones unless you have problems

Do you know what that actually does though? Seeing that your problem is objects not being detected, this setting will CAUSE that not fix it.

I thought it had to do with the stationary object detection. I don’t want it to always track a car if its parked for example in my driveway. I guess I don’t fully understand it from what I read.

why not? if the car isn’t tracked then motion around it will get it to be detected again and frigate will think it is a whole different car. Meanwhile if it is continuously tracked then frigate will always know it is the car in the driveway that has been there for X hours. An object being tracked and being recorded are of course different things: Recording | Frigate

Ok so I think that I’ve figured out part of my issue at the moment
image
I am not sure why this is so ridiculously high. As stated I am using proxmox and I do have it plugged into a USB3.0 port and I’m using a good cable for it. But based on this


My streams are just super slow and I think it has to do with this interface speed. So I’m going to have to try and solve this and get this to a lower value because as I understand a speed of this value is just silly.

yes that is bad, it should be ~10 ms inference times

Ok so good news I rebuild my frigate as a LXC container in my host and my interface speed is down to 100ms. So still not where I’d like it to be but at least its in a better state. Going to monitor it and see how it does here. I might have to speed up my server deployment and get my Dell back online with the m2 coral in it.

Ok got a new USB cable and I can confirm that I now inference less than 20ms which is a nice improvement compared to where I was sitting at. THank you @crzynik for your help with this.

1 Like