blakeblackshear / frigate

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

[Support]: MQTT Events being sent every minute despite nothing in frame #7281

Closed Normanras closed 11 months ago

Normanras commented 1 year ago

Describe the problem you are having

This happens at least once a day and not always on the same camera. But if an object triggers Frigate to send an MQTT payload, even after the person has left the frame, MQTT payload continues to get sent every minute.

While I can understand if there is a lag between real life and frigate sending the payload, this will continue to 20-30 minutes or until I either restart the docker container and/or restart Frigate from the web UI.

Version

0.12.1-367D724

Frigate config file

mqtt:
  host: {{ mqtt-ip-address }}
  port: 1883
  client_id: frigate
  user: {{ mqtt-user }}
  password: {{ mqtt-password }}

detectors:
  coral:
    type: edgetpu
    device: usb

detect:
  width: 640
  height: 480
  enabled: True

birdseye:
  enabled: True
  mode: objects
  quality: 5

objects:
  track:
    - person
    - dog
    - cat
    - bear
    - horse

record:
  enabled: False
  retain:
    days: 30
    mode: all
  events:
    pre_capture: 5
    post_capture: 5

snapshots:
  enabled: True
  timestamp: False
  bounding_box: True
  retain:
    default: 30

rtmp:
  enabled: False

live:
  quality: 5

cameras:
  cam1:
    ffmpeg:
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
      inputs:
        - path: rtsp://USER:PASS*@IPADDRESS:554/h264Preview_01_main
          roles:
            - detect
    zones:
      z1:
        coordinates: 640,480,181,480,159,251,78,222,26,223,109,170,640,225
      z2:
        coordinates: 640,0,640,217,547,173,313,160,108,162,328,0
      z3:
        coordinates: 0,148,224,0,354,0,0,239
      z4:
        coordinates: 237,0,0,0,0,157
      z5:
        coordinates: 154,256,112,233,69,216,27,228,0,242,0,480,225,480
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True

  cam2:
    ffmpeg:
      inputs:
        - path: rtsp://USER:PASS*@IPADDRESS:554/h264Preview_01_main
          roles:
            - detect
    zones:
      z1:
        coordinates: 263,480,640,480,640,0,480,0,356,136,406,195,322,271
      z2:
        coordinates: 341,123,288,267,178,480,0,480,0,0,479,0
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True

  cam3:
    ffmpeg:
      inputs:
        - path: rtsp://USER:PASS*@IPADDRESS:554/h264Preview_01_main
          roles:
            - detect
    mqtt:
      enabled: True
      timestamp: True
      bounding_box: True

Relevant log output

I've attached a screenshot of the MQTT timestamps using debug nodes in node-red.

FFprobe output from your camera

Input #0, rtsp, from 'rtsp://USER:PASS*@IPADDRESS:554/h264Preview_01_main':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_main
  Duration: N/A, start: 0.000188, bitrate: N/A
  Stream #0:0: Video: hevc (Main), yuv420p(tv), 3840x2160, 24.92 tbr, 90k tbn, 90k tbc
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

Reolink 820a

Any other information that may be helpful

Debug screenshot in Nodered showing the MQTT payload being sent every minute.

Screenshot 2023-07-24 at 4 18 11 PM

NickM-27 commented 1 year ago

This is going to be due to a false positive where frigate still detects that object somewhere in the frame. Easiest way is next time it happens, check the debug live view

Normanras commented 1 year ago

Thanks! Am I looking for anything in particular?

I've been running Frigate for more than a year now with great success and have combed through the docs including the section about False Positives and thought I had dialed everything in. I guess something has changed.

NickM-27 commented 1 year ago

Just open the debug live view and enable bounding boxes, that will show what is being detected as a false positive

Normanras commented 1 year ago

I know what is being detected because I have the full MQTT payload. It is usually the last object that was detected and has since moved off the frame. I thought there was a piece of data in the debug that can help me prevent these future endless false positives. I don't mind that it happens, its that it is endless and the only way to stop it is to restart Frigate.

NickM-27 commented 1 year ago

A false positive is when an object is detected as a person but is not actually a person. In this case Frigate has detected a real person but when that person leaves the frame frigate detects something else as a person and assumes it is a person (thus, the event continues). So you simply need to figure out what is being detected as a person and then use filters as appropriate so it is not detected as a person

JeffWDH commented 1 year ago

I get MQTT events all the time for objects which don't create events because they're in zones that don't have those objects configured. I really wish there was a way to exclude from MQTT as well.

Example, cars should not trigger for neighbor_driveway_left and driveway_front but MQTT events still get sent:

    "before": {
        "id": "1690236259.880875-qyamb7",
        "camera": "garage_door",
        "frame_time": 1690240030.951496,
        "snapshot": {
            "frame_time": 1690240030.951496,
            "box": [
                278,
                44,
                330,
                75
            ],
            "area": 1612,
            "region": [
                194,
                0,
                402,
                208
            ],
            "score": 0.795812726020813,
            "attributes": []
        },
        "label": "car",
        "sub_label": null,
        "top_score": 0.9070988893508911,
        "false_positive": false,
        "start_time": 1690236259.880875,
        "end_time": null,
        "score": 0.795812726020813,
        "box": [
            278,
            44,
            330,
            75
        ],
        "area": 1612,
        "ratio": 1.6774193548387097,
        "region": [
            194,
            0,
            402,
            208
        ],
        "stationary": true,
        "motionless_count": 1343,
        "position_changes": 46,
        "current_zones": [],
        "entered_zones": [],
        "has_clip": false,
        "has_snapshot": false,
        "attributes": {},
        "current_attributes": []
    },
    "after": {
        "id": "1690236259.880875-qyamb7",
        "camera": "garage_door",
        "frame_time": 1690240052.457114,
        "snapshot": {
            "frame_time": 1690240052.457114,
            "box": [
                278,
                33,
                331,
                75
            ],
            "area": 2226,
            "region": [
                200,
                0,
                408,
                208
            ],
            "score": 0.7315577864646912,
            "attributes": []
        },
        "label": "car",
        "sub_label": null,
        "top_score": 0.9070988893508911,
        "false_positive": false,
        "start_time": 1690236259.880875,
        "end_time": null,
        "score": 0.7315577864646912,
        "box": [
            278,
            33,
            331,
            75
        ],
        "area": 2226,
        "ratio": 1.2619047619047619,
        "region": [
            200,
            0,
            408,
            208
        ],
        "stationary": true,
        "motionless_count": 1451,
        "position_changes": 46,
        "current_zones": [],
        "entered_zones": [],
        "has_clip": false,
        "has_snapshot": false,
        "attributes": {},
        "current_attributes": []
    },
    "type": "update"
}

-------------------------------------------------

garage_door:
    enabled: true
    audio:
      enabled: true
    detect:
      width: 1280
      height: 720
      enabled: true
    birdseye:
      enabled: True
      order: 1
    ui:
      order: 1
    motion:
      mask:
        - 356,0,357,27,0,27,0,4
    mqtt:
      enabled: true
      crop: True
      quality: 100
      height: 500
      timestamp: False
      bounding_box: False
      required_zones:
        - driveway_front
        - driveway_back
        - walkway
        - lawn_left
        - lawn_right
        - neighbor_driveway_left
        - road
    record:
      events:
        required_zones:
          - driveway_front
          - driveway_back
          - walkway
          - lawn_left
          - lawn_right
          - neighbor_driveway_left
          - road
    snapshots:
      required_zones:
          - driveway_front
          - driveway_back
          - walkway
          - lawn_left
          - lawn_right
          - neighbor_driveway_left
          - road
    zones:
      driveway_front:
        coordinates: 184,720,1006,720,1114,720,1111,330,1063,123,662,133,89,617
        objects:
          - person
          - backpack
          - handbag
          - suitcase
          - dog
          - cat
          - bird
      driveway_back:
        coordinates: 787,70,1043,56,1074,145,658,132
        objects:
          - car
          - truck
          - motorcycle
          - bus
          - bicycle
          - person
          - backpack
          - handbag
          - suitcase
          - dog
          - cat
          - bird
      walkway:
        coordinates: 5,492,102,618,470,293,412,287
        objects:
          - person
          - backpack
          - handbag
          - suitcase
          - dog
          - cat
          - bird
      lawn_left:
        coordinates: 167,403,305,351,408,292,464,306,787,72,576,89,313,205,139,310,0,420,2,496
        objects:
          - person
          - backpack
          - handbag
          - suitcase
          - dog
          - cat
          - bird
      lawn_right:
        coordinates: 1278,126,1217,65,1112,45,1043,49,1077,181,1097,275,1101,720,1280,720
        objects:
          - person
          - backpack
          - handbag
          - suitcase
          - dog
          - cat
          - bird
      neighbor_driveway_left:
        coordinates: 0,416,230,260,543,104,301,124,420,14,0,15
        objects:
          - dog
          - cat
          - bird
      road:
        coordinates: 1280,0,1277,85,1228,52,1122,33,1038,54,619,96,520,108,416,115,327,104,374,68,457,0
        objects:
          - dog
          - cat
          - bird
    live:
       stream_name: garage_door_detect
    ffmpeg:
      inputs:
        - path: "rtsp://127.0.0.1:8554/garage_door"
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: "rtsp://127.0.0.1:8554/garage_door_detect"
          input_args: preset-rtsp-restream
          roles:
            - detect
            - audio
    objects:
      track:
        - person
        - dog
        - cat
        - bird
        - car
        - motorcycle
        - bus
        - bicycle
        - backpack
        - handbag
        - suitcase
        - truck

There are legitimate cars detected but they're within zones that events are excluded.

NickM-27 commented 1 year ago

MQTT events is a raw topic. The exclusion happens on the side that consumes the MQTT topic like in HA or node red.

JeffWDH commented 1 year ago

It is what it is but it results in wasted cycles in HA if you don't have a need for those MQTT messages. I'd be willing to bet most people would have no need for them if they're not monitoring objects in specific zones.

Normanras commented 1 year ago

So I got it to happen again and think I figured it out. I didn't realize that type: update could be like that for such a long time. So as the Frigate UI shows "In Progress" for an event and processes it, it seems to send continual payloads.

In the web UI in both debug and regular mode, the event is no longer happening, so its obviously just lagging before real life (expected), it is processing the photo for longer than usual.

The constant notifications can easily be remedied by checking for type, but it is interesting how long or short certain events get processed.

NickM-27 commented 1 year ago

There's is some confusion here it seems. The type will be end as soon as the event is over (object stops being detected). If an object is stationary then an update is sent every minute until the object is not stationary.

Normanras commented 1 year ago

That makes sense, but there seem to be some false positives as well as the update/event processing will happen for 15+ minutes after the person has left the camera's view.

NickM-27 commented 1 year ago

but there seem to be some false positives as well as the update/event processing will happen for 15+ minutes after the person has left the camera's view.

After the person leaves there is a false positive. If the MQTT topic is being published to then frigate still sees a person there (even though there isn't one).

Frigate processes frames in real time and if it fails to do so it will stop the connection to the camera and reconnect; so there's no delayed processing going on here

alucryd commented 1 year ago

There's is some confusion here it seems. The type will be end as soon as the event is over (object stops being detected). If an object is stationary then an update is sent every minute until the object is not stationary.

Hijacking this since it seems related, how can I stop HA notifications for stationary objects ? My doorbell constantly generates notifications when a car is parked in front of the house which is quite annoying. Can't really make an exclusion as even though I and some of my neighbors regularly park there, a malicious individual could do the same.

NickM-27 commented 1 year ago

There's is some confusion here it seems. The type will be end as soon as the event is over (object stops being detected). If an object is stationary then an update is sent every minute until the object is not stationary.

Hijacking this since it seems related, how can I stop HA notifications for stationary objects ? My doorbell constantly generates notifications when a car is parked in front of the house which is quite annoying. Can't really make an exclusion as even though I and some of my neighbors regularly park there, a malicious individual could do the same.

Just don't send a notification when stationary == True

alucryd commented 1 year ago

That was easy, configured these so long ago that I completely forgot about the HA part. Thanks, and apologies for the dumb question.

github-actions[bot] commented 12 months 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.