blakeblackshear / frigate

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

[Support]: Stationary objects feature in 0.10.0 #2842

Closed lee-costa closed 2 years ago

lee-costa commented 2 years ago

Describe the problem you are having

Thanks for the awesome release!

I have a very interesting setup in my driveway where two cars are usually always parked when we are home but want to avoid being notified of them when stationary so I created two zones as described in the documentation. It works fairly well for the most part but due to how my camera is positioned, I usually always miss events due to all the masking as the camera also faces the street. I originally had the street mask and I believe that is the reason for the missed events since Frigate can't track the objects as they approach the zone.

Here's an image of my driveway with the street unmasked for reference:

Image

I used to deal with the stationary objects with two zones: Yellow only detected person and orange detected person and car.

Now that we have a way to tune stationary objects, I was wondering if I should merge the two zones into one and use the new detect: option to properly deal with the cars that are usually there.

Should this work? if so, any recommendations?

Version

0.10.0

Frigate config file

# mqtt
mqtt:
  host: 192.168.141.21
  user: REDACTED
  password: REDACTED

detectors:
  coral:
    type: edgetpu
    device: usb

database:
  path: /db/frigate.db

snapshots:
  enabled: True
  timestamp: True
  bounding_box: True
  crop: False
  required_zones: []
  retain:
    default: 14

model:
  labelmap:
    15: animal
    16: animal
    17: animal
    18: animal
    19: animal
    20: animal
    21: animal
    22: animal
    23: animal
    24: animal

birdseye:
  enabled: True
  width: 1920
  height: 1080
  quality: 8
  mode: motion  

### Driveway ###

cameras:
  driveway_cam:
    rtmp:
      enabled: False
    objects:
      track:
        - person
        - car
        - dog
    ffmpeg:
      inputs:
        - path: rtsp://REDACTED:REDACTED$@192.168.141.14:554/cam/realmonitor?channel=1&subtype=0
          roles:
            - detect
#            - rtmp
            - record

    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True

    record:
      enabled: True
      retain:
        days: 14
        mode: motion
      events:
        max_seconds: 240
        pre_capture: 5
        post_capture: 5
        retain:
          default: 14
          mode: active_objects
        objects:
          - person
          - car
          - animal
        required_zones:
          - street_driveway
          - main_driveway

    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      crop: False
      required_zones:
        - street_driveway
        - main_driveway
      retain:
        default: 14

    motion:
      mask:
         - 1920,0,1920,610,863,432,846,687,1053,941,677,1080,0,1080,0,0

    zones:
      street_driveway:
        coordinates: 1856,763,1821,871,871,575,902,538
        objects:
          - person
          - car
      main_driveway:
        coordinates: 1328,1080,1136,983,852,575,1920,929,1920,1080
        objects:
          - person
          - dog

    objects:
      filters:
        car:
          mask:
            - 1920,0,1920,610,863,432,846,687,1053,941,677,1080,0,1080,0,0
        dog:
          mask:
            - 1920,0,1920,610,863,432,846,687,248,803,0,865,0,0
        person:
          mask:
            - 1920,0,1920,610,863,432,846,687,248,803,0,865,0,0

Relevant log output

NA

FFprobe output from your camera

NA

Frigate stats

No response

Operating system

Debian

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

AMCREST 4K

Any other information that may be helpful

No response

blakeblackshear commented 2 years ago

A couple of pointers that would probably be helpful.

Masking the street would definitely prevent objects from being tracked as they approach your zones, so that's likely why things are missed.

Zones are evaluated based on the bottom center of the bounding box (green dot in screenshot below), not how much the object overlaps with the zone. Based on the angle of your camera, your bounding boxes may be in areas you aren't expecting when cars drive diagonally down the street. image

In 0.10.0, parked cars will stay tracked forever. This will help prevent frigate from getting confused and swapping cars in the driveway with cars driving by. Your zone based approach should still work with this version. You could also try merging the zones into one and comparing the before and after values of the new position_changes property on the mqtt topic to only be notified when an object actually changes position.

You may want to look at the updated notification blueprint for ideas: https://github.com/blakeblackshear/frigate/discussions/2748#discussioncomment-2152948

lee-costa commented 2 years ago

Thanks for the suggestions. So I noticed that when that car leaves and comes back, even a few hours later Frigate will show in progress under events but ideally, I would like for that to expire. I believe its related to this:

I expect this to disrupt the way a few people are using Frigate. For example, a car that enters the driveway, parks, and then leaves 5 hours later will be one continuous event. The zones will stay with the tracked object over this lifetime, so when the car leaves, it will still have zones associated from when it first arrived. Ensure you use the right retain mode to ensure you only capture the segments you want.

Since I have my retain set to active_objects, I assume that none of this footage will be recorded and the object is only being tracked? Sorry as I am a little confused on this part.

blakeblackshear commented 2 years ago

The event will stay in progress. When you watch video of the event, you should only see portions of video where any object actually moves. You won't be storing video of a parked car unless something else is moving.

lee-costa commented 2 years ago

So while playing around with stationary objects, I noticed that sometimes either the sun or another car headlights at night would shine against the stationary object, in this case, a vehicle, making it appears that it has moved again. This ends up causing various alerts for the same object.

Any idea what to tweak in order to help this issue?

blakeblackshear commented 2 years ago

That shouldn't cause the object to become non stationary. It is based on the location of the bounding box, not motion (determined by change in pixel values).

lee-costa commented 2 years ago

So in that case, it may be that Frigate ends the ‘in progress’ recording and it starts a new one. I did see it happen on multiple occasions.

blakeblackshear commented 2 years ago

Yes. That would happen if the stationary object was lost. The lighting change will trigger frigate to start checking to make sure the object is still in the same location. If the scores drop too low, it will be lost. That will end the event and the object may be detected again later as a new event.

lee-costa commented 2 years ago

So making any adjustments here is unnecessary since this is more related to my environment?

blakeblackshear commented 2 years ago

Frigate tries to only retain events for objects that have changed positions at least once. If an object is detected and never moves, it shouldn't result in recordings or snapshots. It will find it and watch it indefinitely, but only store snapshots/video if it thinks it actually moved. Sometimes it will think the object has moved when it hasn't. If you are getting notifications about these objects, you can use conditions to only be notified when you want.

stale[bot] commented 2 years 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.