blakeblackshear / frigate

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

[Support]: Bug With Zone Filters Not Filtering After Becoming Active #2620

Closed NickM-27 closed 2 years ago

NickM-27 commented 2 years ago

Describe the problem you are having

I have my front doorbell with 3 zones setup. I have a filter setup on the street zone which will only detect a car if it has a min_area of 16000 or more (trying to look only for delivery trucks). It seems that this works for starting the zone detection, but once the zone is active the neighbors car parked in the street (2000 area) will keep the recording / zone going long after the truck has driven by.

The confusing part is that this doesn't happen every time, at some point the clip will stop while the neighbor car is still there.

Version

0.10.0-DB1255A

Frigate config file

{
  "birdseye": {
    "enabled": false,
    "height": 720,
    "mode": "objects",
    "quality": 8,
    "width": 1280
  },
  "cameras": {
    "backyard_cam": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 5,
        "height": 480,
        "max_disappeared": 25,
        "stationary_interval": 50,
        "width": 640
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [
          "-hwaccel",
          "vaapi",
          "-hwaccel_device",
          "/dev/dri/renderD128"
        ],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "+genpts+discardcorrupt",
          "-rtsp_transport",
          "tcp",
          "-stimeout",
          "5000000",
          "-use_wallclock_as_timestamps",
          "1"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://admin:Backyardbrick8@192.168.50.152:554/cam/realmonitor?channel=1&subtype=0",
            "roles": [
              "record",
              "rtmp"
            ]
          },
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://admin:Backyardbrick8@192.168.50.152:554/cam/realmonitor?channel=1&subtype=1",
            "roles": [
              "detect"
            ]
          }
        ],
        "output_args": {
          "detect": [
            "-f",
            "rawvideo",
            "-pix_fmt",
            "yuv420p"
          ],
          "record": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac",
          "rtmp": [
            "-c",
            "copy",
            "-f",
            "flv"
          ]
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:Backyardbrick8@192.168.50.152:554/cam/realmonitor?channel=1&subtype=0 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac /tmp/cache/backyard_cam-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/backyard_cam",
          "roles": [
            "record",
            "rtmp"
          ]
        },
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:pw@ip.ad.dr.ss:554/cam/realmonitor?channel=1&subtype=1 -r 5 -s 640x480 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 4
      },
      "motion": {
        "contour_area": 30,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 50,
        "mask": [
          "640,480,574,480,569,432,609,378,640,339",
          "0,0,0,71,391,62,640,67,640,0"
        ],
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "quality": 70,
        "required_zones": [],
        "timestamp": true
      },
      "name": "backyard_cam",
      "objects": {
        "filters": {
          "cat": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.4,
            "threshold": 0.5
          },
          "dog": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.4,
            "threshold": 0.5
          },
          "person": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": "",
        "track": [
          "cat",
          "dog",
          "person"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 180,
          "objects": null,
          "post_capture": 5,
          "pre_capture": 3,
          "required_zones": [
            "backyard"
          ],
          "retain": {
            "default": 4,
            "mode": "active_objects",
            "objects": {}
          }
        },
        "retain": {
          "days": 2,
          "mode": "motion"
        },
        "retain_days": null
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [
          "backyard"
        ],
        "retain": {
          "default": 4,
          "mode": "active_objects",
          "objects": {}
        },
        "timestamp": false
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%m/%d/%Y %H:%M:%S",
        "position": "tl",
        "thickness": 2
      },
      "zones": {
        "backyard": {
          "coordinates": "0,480,569,480,605,407,640,346,640,240,607,197,456,113,243,105,0,323",
          "filters": {},
          "objects": [
            "cat",
            "dog",
            "person"
          ]
        }
      }
    },
    "doggo_cam": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": false,
        "fps": 5,
        "height": 1080,
        "max_disappeared": 25,
        "stationary_interval": 50,
        "width": 1920
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [
          "-hwaccel",
          "vaapi",
          "-hwaccel_device",
          "/dev/dri/renderD128"
        ],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "+genpts+discardcorrupt",
          "-rtsp_transport",
          "tcp",
          "-stimeout",
          "5000000",
          "-use_wallclock_as_timestamps",
          "1"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://doggocam:Dewycam@192.168.50.150/live",
            "roles": [
              "record",
              "rtmp",
              "detect"
            ]
          }
        ],
        "output_args": {
          "detect": [
            "-f",
            "rawvideo",
            "-pix_fmt",
            "yuv420p"
          ],
          "record": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac",
          "rtmp": [
            "-c",
            "copy",
            "-f",
            "flv"
          ]
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:pw@ip.ad.dr.ss/live -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac /tmp/cache/doggo_cam-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/doggo_cam -r 5 -s 1920x1080 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "record",
            "rtmp",
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 4
      },
      "motion": {
        "contour_area": 30,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 50,
        "mask": [
          "28,202,147,202,135,374,29,378"
        ],
        "threshold": 80
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "quality": 70,
        "required_zones": [],
        "timestamp": true
      },
      "name": "doggo_cam",
      "objects": {
        "filters": {
          "dog": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "person": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": "",
        "track": [
          "dog",
          "person"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 300,
          "objects": [
            "person"
          ],
          "post_capture": 5,
          "pre_capture": 5,
          "required_zones": [],
          "retain": {
            "default": 1,
            "mode": "active_objects",
            "objects": {}
          }
        },
        "retain": {
          "days": 2,
          "mode": "all"
        },
        "retain_days": null
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [],
        "retain": {
          "default": 1,
          "mode": "active_objects",
          "objects": {}
        },
        "timestamp": false
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%m/%d/%Y %H:%M:%S",
        "position": "tl",
        "thickness": 2
      },
      "zones": {}
    },
    "front_doorbell_cam": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 5,
        "height": 576,
        "max_disappeared": 25,
        "stationary_interval": 50,
        "width": 720
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [
          "-hwaccel",
          "vaapi",
          "-hwaccel_device",
          "/dev/dri/renderD128"
        ],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "+genpts+discardcorrupt",
          "-rtsp_transport",
          "tcp",
          "-stimeout",
          "5000000",
          "-use_wallclock_as_timestamps",
          "1"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "rtsp://admin:Doorbellbrick8@192.168.50.151:554/cam/realmonitor?channel=1&subtype=0&authbasic=64",
            "roles": [
              "record",
              "rtmp"
            ]
          },
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "admin:pw@ip.ad.dr.ss:554/cam/realmonitor?channel=1&subtype=1&authbasic=64",
            "roles": [
              "detect"
            ]
          }
        ],
        "output_args": {
          "detect": [
            "-f",
            "rawvideo",
            "-pix_fmt",
            "yuv420p"
          ],
          "record": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac",
          "rtmp": [
            "-c",
            "copy",
            "-f",
            "flv"
          ]
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:Doorbellbrick8@192.168.50.151:554/cam/realmonitor?channel=1&subtype=0&authbasic=64 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac /tmp/cache/front_doorbell_cam-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/front_doorbell_cam",
          "roles": [
            "record",
            "rtmp"
          ]
        },
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:Doorbellbrick8@192.168.50.151:554/cam/realmonitor?channel=1&subtype=1&authbasic=64 -r 5 -s 720x576 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 4
      },
      "motion": {
        "contour_area": 30,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 50,
        "mask": [
          "720,0,720,214,591,252,397,251,277,0"
        ],
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": false,
        "enabled": true,
        "height": 270,
        "quality": 100,
        "required_zones": [],
        "timestamp": false
      },
      "name": "front_doorbell_cam",
      "objects": {
        "filters": {
          "car": {
            "mask": [
              "298,315,404,322,406,306,306,302"
            ],
            "max_area": 24000000,
            "min_area": 1000,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "cat": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "dog": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          },
          "person": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": "",
        "track": [
          "car",
          "cat",
          "dog",
          "person"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 180,
          "objects": null,
          "post_capture": 5,
          "pre_capture": 3,
          "required_zones": [
            "driveway",
            "front_yard",
            "street"
          ],
          "retain": {
            "default": 7,
            "mode": "active_objects",
            "objects": {
              "car": 7,
              "cat": 4,
              "dog": 4,
              "person": 10
            }
          }
        },
        "retain": {
          "days": 2,
          "mode": "all"
        },
        "retain_days": null
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [
          "driveway",
          "front_yard",
          "street"
        ],
        "retain": {
          "default": 7,
          "mode": "active_objects",
          "objects": {
            "car": 7,
            "cat": 4,
            "dog": 4,
            "person": 10
          }
        },
        "timestamp": false
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%m/%d/%Y %H:%M:%S",
        "position": "tl",
        "thickness": 2
      },
      "zones": {
        "driveway": {
          "coordinates": "224,399,0,367,0,363,0,550",
          "filters": {
            "car": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 8000,
              "min_score": 0.5,
              "threshold": 0.7
            }
          },
          "objects": [
            "car",
            "cat",
            "dog",
            "person"
          ]
        },
        "front_yard": {
          "coordinates": "0,576,720,576,720,425,613,382,447,406,227,401,0,552",
          "filters": {},
          "objects": [
            "cat",
            "dog",
            "person"
          ]
        },
        "street": {
          "coordinates": "268,303,549,308,720,285,720,303,615,321,610,361,286,373,0,327,0,300",
          "filters": {
            "car": {
              "mask": null,
              "max_area": 24000000,
              "min_area": 16000,
              "min_score": 0.5,
              "threshold": 0.7
            }
          },
          "objects": [
            "car"
          ]
        }
      }
    }
  },
  "database": {
    "path": "/media/frigate/frigate.db"
  },
  "detect": {
    "enabled": true,
    "fps": 5,
    "height": 720,
    "max_disappeared": null,
    "stationary_interval": null,
    "width": 1280
  },
  "detectors": {
    "coral": {
      "device": "usb",
      "num_threads": 3,
      "type": "edgetpu"
    }
  },
  "environment_vars": {},
  "ffmpeg": {
    "global_args": [
      "-hide_banner",
      "-loglevel",
      "warning"
    ],
    "hwaccel_args": [
      "-hwaccel",
      "vaapi",
      "-hwaccel_device",
      "/dev/dri/renderD128"
    ],
    "input_args": [
      "-avoid_negative_ts",
      "make_zero",
      "-fflags",
      "+genpts+discardcorrupt",
      "-rtsp_transport",
      "tcp",
      "-stimeout",
      "5000000",
      "-use_wallclock_as_timestamps",
      "1"
    ],
    "output_args": {
      "detect": [
        "-f",
        "rawvideo",
        "-pix_fmt",
        "yuv420p"
      ],
      "record": [
        "-f",
        "segment",
        "-segment_time",
        "10",
        "-segment_format",
        "mp4",
        "-reset_timestamps",
        "1",
        "-strftime",
        "1",
        "-c",
        "copy",
        "-an"
      ],
      "rtmp": [
        "-c",
        "copy",
        "-f",
        "flv"
      ]
    }
  },
  "live": {
    "height": 720,
    "quality": 4
  },
  "logger": {
    "default": "info",
    "logs": {}
  },
  "model": {
    "height": 320,
    "labelmap": {},
    "labelmap_path": null,
    "path": null,
    "width": 320
  },
  "motion": null,
  "mqtt": {
    "client_id": "frigate",
    "host": "192.168.50.106",
    "password": "@MQTTbrick8",
    "port": 1883,
    "stats_interval": 60,
    "tls_ca_certs": null,
    "tls_client_cert": null,
    "tls_client_key": null,
    "tls_insecure": null,
    "topic_prefix": "frigate",
    "user": "nickmowen"
  },
  "objects": {
    "filters": null,
    "mask": "",
    "track": [
      "person"
    ]
  },
  "record": {
    "enabled": false,
    "events": {
      "max_seconds": 300,
      "objects": null,
      "post_capture": 5,
      "pre_capture": 5,
      "required_zones": [],
      "retain": {
        "default": 10,
        "mode": "active_objects",
        "objects": {}
      }
    },
    "retain": {
      "days": 0,
      "mode": "all"
    },
    "retain_days": null
  },
  "rtmp": {
    "enabled": true
  },
  "snapshots": {
    "bounding_box": true,
    "clean_copy": true,
    "crop": false,
    "enabled": false,
    "height": null,
    "quality": 70,
    "required_zones": [],
    "retain": {
      "default": 10,
      "mode": "active_objects",
      "objects": {}
    },
    "timestamp": false
  },
  "timestamp_style": {
    "color": {
      "blue": 255,
      "green": 255,
      "red": 255
    },
    "effect": null,
    "format": "%m/%d/%Y %H:%M:%S",
    "position": "tl",
    "thickness": 2
  }
}

Relevant log output

N/A

FFprobe output from your camera

N/A

Frigate stats

{"backyard_cam":{"camera_fps":5.4,"capture_pid":228,"detection_fps":0.0,"pid":223,"process_fps":5.4,"skipped_fps":0.0},"detection_fps":4.9,"detectors":{"coral":{"detection_start":1641859071.396633,"inference_speed":8.52,"pid":9960}},"doggo_cam":{"camera_fps":5.0,"capture_pid":230,"detection_fps":0.0,"pid":225,"process_fps":0.0,"skipped_fps":0.0},"front_doorbell_cam":{"camera_fps":5.1,"capture_pid":236,"detection_fps":4.9,"pid":226,"process_fps":5.0,"skipped_fps":0.0},"service":{"storage":{"/dev/shm":{"free":5358.6,"mount_type":"tmpfs","total":5368.7,"used":10.1},"/media/frigate/clips":{"free":171713.1,"mount_type":"fuse.shfs","total":256059.5,"used":81339.2},"/media/frigate/recordings":{"free":171713.1,"mount_type":"fuse.shfs","total":256059.5,"used":81339.2},"/tmp/cache":{"free":6239.5,"mount_type":"rootfs","total":7223.5,"used":984.0}},"temperatures":{},"uptime":73901,"version":"0.10.0-db1255a"}}

Operating system

UNRAID

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

Amcrest AD410

Any other information that may be helpful

This is the vehicle that started the clip:

image

This is the snapshot and vehicle that passed by before the clip stopped:

image

Here is the zone layout:

image

NickM-27 commented 2 years ago

It occurred to me that odds are, the min_area is just a filter for an object starting the zone due to the scenario where an object would move away from the camera and may be smaller but should continue to be tracked. Perhaps a config option is necessary so in my case the object must always satisfy the min_area requirement to be considered apart of that zone

vakilando commented 2 years ago

@NickM-27 it seems that you have left your real passwords in the config files? if this ist the case yout should change them.

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.