blakeblackshear / frigate

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

[Config Support]: help for objects to track and zones #9099

Closed CrashOverride-Git closed 8 months ago

CrashOverride-Git commented 8 months ago

Describe the problem you are having

Hello, I am having problem with the zones and the object to track. For this camera, what I want to achieve is to track (record, snapshot etc) only people in the orange zone "zona_corsello_box" and cars + people on the yellow one "zona_corsello_box_strada". What I get instead is the detection and tracking only into the orange zone, the yellow one is completely ignored.

The result is that if a car is parked there, all the people behind it are invisible for the google coral unless they move on front of the car (but maybe this is an hardware limitation of the google coral.. I am not an expert). Other cameras are ok, since have only to detect people (but maybe are affected by the same issue).

Could you help me?

Screenshot 2023-12-28 alle 12 31 47

this is an example of the secondary problem I have.

Screenshot 2023-12-28 alle 12 45 06

Only the person in front of the camera is detected, the car and a third person near the corner of the house are ignored.

Screenshot 2023-12-28 alle 12 59 20

Here instead it detects the car (nearest to the camera) and totally ignore the two persons

Version

0.12.1-367D724

Frigate config file

mqtt:
  enabled: True
  host: artemide.zerocinque.local #192.168.207.11
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: "{FRIGATE_MQTT_USER}"
  password: "{FRIGATE_MQTT_PASSWORD}"

detectors:
  coral:
    type: edgetpu
    device: usb

go2rtc:
  streams:
    portico:
      - rtsp://frigate:password@172.16.220.5:11554/Streaming/Channels/101   # 2560x1440 - 20fps
      - "ffmpeg:portico#audio=opus"
    portico_detect:
      - rtsp://frigate:password@172.16.220.5:11554/Streaming/Channels/102   # 640x360 - 6fps
    soggiorno:
      - rtsp://frigate:password@172.16.220.7:554/s0                         # 1920x1080 - 25fps
      - "ffmpeg:soggiorno#audio=opus"
    soggiorno_detect:
      - rtsp://frigate:password@172.16.220.7:554/s1                         # 640x360 - 6fps 
    soggiorno_medium:
      - rtsp://frigate:password@172.16.220.7:554/s2                         # 1024x576 (non usato) - 25 fps
    corsello_box:
      - rtsp://frigate:password@172.16.220.6:11554/Streaming/Channels/101   # 2560x1440 - 20 fps
    corsello_box_detect:
      - rtsp://frigate:password@172.16.220.6:11554/Streaming/Channels/102   # 640x360 - 6fps
  webrtc:
    candidates:
      - argos.zerocinque.local:8555
      - stun:8555

ui: 
  live_mode: webrtc
  time_format: 24hour
  date_style: short
  time_style: short
#  strftime_fmt: "%d.%m.%Y %H:%M"

database:
  path: /db/frigate.db

logger:
  default: info
  logs:
    frigate.event: debug

birdseye:
  enabled: False
  restream: False
  width: 1920
  height: 1080
  quality: 8
  mode: objects

ffmpeg:
  global_args: -hide_banner -loglevel warning -threads 2
#  hwaccel_args: preset-intel-qsv-h264
  input_args: preset-rtsp-generic
  output_args:
#    detect: -threads 2 -f rawvideo -pix_fmt yuv420p
    record: preset-record-generic-audio-aac
    rtmp: preset-rtmp-generic

detect:
  enabled: True
  width: 640
  height: 360
  fps: 6
  max_disappeared: 25
  stationary:
    interval: 0
    threshold: 60
    max_frames:
      default: 360        # 1 minuto
      objects:
        person: 1800      # 10 minuti

objects:
  track:
    - person
    - cat
    - dog
    - car
  filters:
    person:
      min_score: 0.6
      threshold: 0.7
      min_area: 2000
    car:
      min_score: 0.6
      threshold: 0.8
      min_area: 20000     

record:
  enabled: true
  expire_interval: 15
  retain:
    days: 5
    mode: all
  events:
    pre_capture: 5
    post_capture: 15
#    objects:
#      - person
#      - cat
#      - dog
#      - car
    retain:
      default: 5
      mode: motion
      objects:
        person: 10
        cat: 5
        dog: 5
        car: 5

snapshots:
  enabled: true
  clean_copy: True
  timestamp: False
  bounding_box: true
  crop: False
  retain:
    default: 10
    objects:
      person: 10

rtmp:
  enabled: False

telemetry:
  version_check: True

cameras:

  # ---------------------------------
  # portico
  # ---------------------------------
  portico:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/portico
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/portico_detect
          input_args: preset-rtsp-restream
          roles:
            - detect
    zones:
      zona_portico:
        coordinates: 51,337,82,360,361,360,484,360,545,281,564,172,552,149,557,99,438,47,335,124
      zona_portico_fioriera_confine:
        coordinates: 0,138,0,89,90,41,213,0,276,0,322,0,323,22,210,63,94,125,58,156,37,117
      zona_portico_prato:
        coordinates: 249,184,176,239,57,328,0,284,0,192,140,115,284,39,344,23,439,42
    mqtt:
      enabled: True
      timestamp: False
      bounding_box: True
      crop: False
      quality: 100
    detect:
      width: 640
      height: 360
      fps: 6
    objects:
      track:
        - person

  # ---------------------------------
  # soggiorno
  # ---------------------------------  
  soggiorno:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/soggiorno
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/soggiorno_detect
          input_args: preset-rtsp-restream
          roles:
            - detect
    zones:  
      divano:
        coordinates: 257,360,422,360,313,274,300,249,271,251,243,250,238,237,221,239,209,258
      ingresso:
        coordinates: 227,36,296,42,288,175,221,189
      finestra:
        coordinates: 0,0,65,35,79,188,73,255,0,293   
    mqtt:
      enabled: True
      timestamp: False
      bounding_box: True
      crop: False
      quality: 100
    detect:
      width: 640
      height: 360
      fps: 6
      stationary: 
        max_frames: 
          objects:
            person: 360      
    objects:
      track:
        - person
    record:
      events:
        retain:
          default: 2
          mode: active_objects

  # ---------------------------------
  # corsello box
  # ---------------------------------  
  corsello_box:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/corsello_box
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/corsello_box_detect
          input_args: preset-rtsp-restream
          roles:
            - detect
    zones:
      zona_corsello:
        coordinates: 453,122,357,111,305,41,265,46,0,167,0,318,0,360,499,360,532,136
        objects:
          - person 
      zona_corsello_strada:
        coordinates: 343,106,349,65,385,66,431,70,537,81,519,134
        objects:
          - person
          - car
    mqtt:
      enabled: True
      timestamp: False
      bounding_box: True
      crop: False
      quality: 100                
    detect:
      width: 640
      height: 360
      fps: 6
      stationary: 
        max_frames: 
          objects:
            person: 360
            car: 100
#    objects:
#      track:
#        - person
#        - car

Relevant log output

this is the code of the camera:

  # ---------------------------------
  # corsello box
  # ---------------------------------  
  corsello_box:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/corsello_box
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/corsello_box_detect
          input_args: preset-rtsp-restream
          roles:
            - detect
    zones:
      zona_corsello:
        coordinates: 453,122,357,111,305,41,265,46,0,167,0,318,0,360,499,360,532,136
        objects:
          - person 
      zona_corsello_strada:
        coordinates: 343,106,349,65,385,66,431,70,537,81,519,134
        objects:
          - person
          - car
    mqtt:
      enabled: True
      timestamp: False
      bounding_box: True
      crop: False
      quality: 100                
    detect:
      width: 640
      height: 360
      fps: 6
      stationary: 
        max_frames: 
          objects:
            person: 360
            car: 100
#    objects:
#      track:
#        - person
#        - car


### Frigate stats

_No response_

### Operating system

Debian

### Install method

Docker Compose

### Coral version

USB

### Any other information that may be helpful

_No response_
NickM-27 commented 8 months ago

you are misunderstanding how frigate works, each "event" correlates to a specific object. So when you look at the snapshot for the car event only the car will have a box, the people will have their own separate events.

CrashOverride-Git commented 8 months ago

Ciao and thank you for the reply the problem is that in that zone I only have a snapshot/recoding (example) only of the object closer to the camera, so everything behind that is ignored. For example, if I park the car in front of my garage door (close to the camera), behind I could even have the Rio's carnival parade and I will never know that because frigate (or google coral) will never detect a single dancer.... at least with my config

That is why I want detect cars only in the street side (yellow zone) - my first issue - but with the above config it doesn't work because it only detects persons and cars on the main zone..

could you help me to fixup the config?

NickM-27 commented 8 months ago

the fact that a car is in the driveway will not affect whether or not a person is detected. If a person event is not created then that would be due to the person not scoring high enough for an event.

I'd suggest watching the debug live view by opening the camera page then pressing debug in the top right, then using the options part enable the bounding boxes. This will show all objects that are detected

CrashOverride-Git commented 8 months ago

Thank you, I think I found the error that was causing the first problem.

I created the zones using the ground surface, like shown here img da frigate

Instead, I have to draw the lines - I don't know how to explain it in english -, like if drawing the areas on the camera lens (what camera sees, flat on 2D not 3D as I tought). So I changed the lines and I have added masks to my neighbor's house.

For the second issue you where right, the camera didn't detect me because of the threshold values. Even in the yellow zone, it detect movement but the filter is too aggressive and everything is ingored.

Screenshot 2023-12-29 alle 12 40 42

Screenshot 2023-12-29 alle 12 41 01

I know that is a little bit OT, but, can I set different filters for each zone?

Something like this:

  corsello_box:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/corsello_box
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/corsello_box_detect
          input_args: preset-rtsp-restream
          roles:
            - detect
    zones:
      zona_corsello:
        coordinates: 453,122,357,111,305,41,265,46,0,167,0,318,0,360,499,360,532,136
# --------------   
# new section
# --------------   
        objects:
          track:
            - person
          filters:
            person:
              min_score: 0.5
              threshold: 0.65
              min_area: 2000
# --------------   
      zona_corsello_strada:
        coordinates: 343,106,349,65,385,66,431,70,537,81,519,134
# --------------   
# new section 
# --------------   
        objects:
          track:
            - person
            - car
          filters:
            person:
              min_score: 0.4  # need to be adjusted
              threshold: 0.55 # need to be adjusted
              min_area: 500  # need to be adjusted
            car:
              min_score: 0.5  # need to be adjusted
              threshold: 0.65 # need to be adjusted
              min_area: 500  # need to be adjusted
# --------------       
    mqtt:
      enabled: True
      timestamp: False
      bounding_box: True
      crop: False
      quality: 100                
    detect:
      width: 640
      height: 360
      fps: 6
      stationary: 
        max_frames: 
          objects:
            person: 360
            car: 100
NickM-27 commented 8 months ago

for now I would suggest removing all filters and seeing how it works, then start adding filters when at least what you want to be detected is detected.

filters on the zone level only apply to whether or not the object is detected in the zone, not how it is detected from a tracking standpoint

CrashOverride-Git commented 8 months ago

thank you again ;), I will do the tests you suggest and then I will apply the filters to remove false positive. I mark this post as solved