blakeblackshear / frigate

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

[Support]: Motion detection by camera device, not Frigate/Tensorflow #2505

Closed zoltanszalontay closed 2 years ago

zoltanszalontay commented 2 years ago

Describe the problem you are having

Hi, I could not find it on the UI and in the docs so I am asking here if motion detection supported by the camera device itself (e.g. Reolink person or car detection) is supported or there is no choice: all ML code must run on the server?

Version

0.9.4-26AE608

Frigate config file

{
  "birdseye": {
    "enabled": true,
    "height": 720,
    "mode": "objects",
    "quality": 8,
    "width": 1280
  },
  "cameras": {
    "Nyugati oldal": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 5,
        "height": 720,
        "max_disappeared": 25,
        "width": 1280
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "nobuffer+genpts+discardcorrupt",
          "-flags",
          "low_delay",
          "-strict",
          "experimental",
          "-analyzeduration",
          "1000M",
          "-probesize",
          "1000M",
          "-rw_timeout",
          "5000000"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "http://192.168.1.12/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=****",
            "roles": [
              "record",
              "rtmp"
            ]
          },
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "http://192.168.1.12/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=***",
            "roles": [
              "detect"
            ]
          }
        ],
        "output_args": {
          "detect": "-f rawvideo -pix_fmt yuv420p",
          "record": "-f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an",
          "rtmp": "-c copy -f flv -c:v copy -c:a aac"
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000 -i http://192.168.1.12/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=**** -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/Nyugati oldal-%Y%m%d%H%M%S.mp4 -c copy -f flv -c:v copy -c:a aac rtmp://127.0.0.1/live/Nyugati oldal",
          "roles": [
            "record",
            "rtmp"
          ]
        },
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000 -i http://192.168.1.12/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=admin&password=**** -r 5 -s 1280x720 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 8
      },
      "motion": {
        "contour_area": 99,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 180,
        "mask": "",
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "quality": 70,
        "required_zones": [],
        "timestamp": true
      },
      "name": "Nyugati oldal",
      "objects": {
        "filters": {
          "bird": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "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": [
          "person",
          "cat",
          "dog",
          "bird"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 300,
          "objects": [
            "person",
            "cat",
            "dog",
            "bird"
          ],
          "post_capture": 5,
          "pre_capture": 5,
          "required_zones": [],
          "retain": {
            "default": 10,
            "objects": {}
          }
        },
        "retain_days": 7
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [],
        "retain": {
          "default": 7,
          "objects": {}
        },
        "timestamp": true
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%-/%m-%d %H:%M:%S",
        "position": "br",
        "thickness": 2
      },
      "zones": {}
    },
    "Terasz": {
      "best_image_timeout": 60,
      "detect": {
        "enabled": true,
        "fps": 5,
        "height": 720,
        "max_disappeared": 25,
        "width": 1280
      },
      "ffmpeg": {
        "global_args": [
          "-hide_banner",
          "-loglevel",
          "warning"
        ],
        "hwaccel_args": [],
        "input_args": [
          "-avoid_negative_ts",
          "make_zero",
          "-fflags",
          "nobuffer+genpts+discardcorrupt",
          "-flags",
          "low_delay",
          "-strict",
          "experimental",
          "-analyzeduration",
          "1000M",
          "-probesize",
          "1000M",
          "-rw_timeout",
          "5000000"
        ],
        "inputs": [
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "http://192.168.1.11/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=zoltansz&password=****",
            "roles": [
              "record",
              "rtmp"
            ]
          },
          {
            "global_args": [],
            "hwaccel_args": [],
            "input_args": [],
            "path": "http://192.168.1.11/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=zoltansz&password=****",
            "roles": [
              "detect"
            ]
          }
        ],
        "output_args": {
          "detect": "-f rawvideo -pix_fmt yuv420p",
          "record": "-f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an",
          "rtmp": "-c copy -f flv -c:v copy -c:a aac"
        }
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000 -i http://192.168.1.11/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=zoltansz&password=**** -f segment -segment_time 60 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/Terasz-%Y%m%d%H%M%S.mp4 -c copy -f flv -c:v copy -c:a aac rtmp://127.0.0.1/live/Terasz",
          "roles": [
            "record",
            "rtmp"
          ]
        },
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000 -i http://192.168.1.11/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=zoltansz&password=**** -r 5 -s 1280x720 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        }
      ],
      "live": {
        "height": 720,
        "quality": 8
      },
      "motion": {
        "contour_area": 99,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 180,
        "mask": "",
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "quality": 70,
        "required_zones": [],
        "timestamp": true
      },
      "name": "Terasz",
      "objects": {
        "filters": {
          "bird": {
            "mask": null,
            "max_area": 24000000,
            "min_area": 0,
            "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": [
          "person",
          "cat",
          "dog",
          "bird"
        ]
      },
      "record": {
        "enabled": true,
        "events": {
          "max_seconds": 300,
          "objects": [
            "person",
            "cat",
            "dog",
            "bird"
          ],
          "post_capture": 5,
          "pre_capture": 5,
          "required_zones": [],
          "retain": {
            "default": 10,
            "objects": {}
          }
        },
        "retain_days": 7
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": true,
        "clean_copy": true,
        "crop": false,
        "enabled": true,
        "height": null,
        "quality": 70,
        "required_zones": [],
        "retain": {
          "default": 7,
          "objects": {}
        },
        "timestamp": true
      },
      "timestamp_style": {
        "color": {
          "blue": 255,
          "green": 255,
          "red": 255
        },
        "effect": null,
        "format": "%-/%m-%d %H:%M:%S",
        "position": "br",
        "thickness": 2
      },
      "zones": {}
    }
  },
  "database": {
    "path": "/media/frigate/frigate.db"
  },
  "detect": {
    "enabled": true,
    "fps": 5,
    "height": 720,
    "max_disappeared": null,
    "width": 1280
  },
  "detectors": {
    "cpu1": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    },
    "cpu2": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    }
  },
  "environment_vars": {},
  "ffmpeg": {
    "global_args": [
      "-hide_banner",
      "-loglevel",
      "warning"
    ],
    "hwaccel_args": [],
    "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": 8
  },
  "logger": {
    "default": "info",
    "logs": {}
  },
  "model": {
    "height": 320,
    "labelmap": {},
    "labelmap_path": null,
    "path": null,
    "width": 320
  },
  "motion": null,
  "mqtt": {
    "client_id": "frigate",
    "host": "192.168.1.113",
    "password": "****",
    "port": 1883,
    "stats_interval": 60,
    "tls_ca_certs": null,
    "tls_client_cert": null,
    "tls_client_key": null,
    "tls_insecure": null,
    "topic_prefix": "frigate",
    "user": "mqtt"
  },
  "objects": {
    "filters": null,
    "mask": "",
    "track": [
      "person"
    ]
  },
  "record": {
    "enabled": true,
    "events": {
      "max_seconds": 300,
      "objects": [
        "person",
        "cat",
        "dog",
        "bird"
      ],
      "post_capture": 5,
      "pre_capture": 5,
      "required_zones": [],
      "retain": {
        "default": 10,
        "objects": {}
      }
    },
    "retain_days": 7
  },
  "rtmp": {
    "enabled": true
  },
  "snapshots": {
    "bounding_box": true,
    "clean_copy": true,
    "crop": false,
    "enabled": true,
    "height": null,
    "quality": 70,
    "required_zones": [],
    "retain": {
      "default": 7,
      "objects": {}
    },
    "timestamp": true
  },
  "timestamp_style": {
    "color": {
      "blue": 255,
      "green": 255,
      "red": 255
    },
    "effect": null,
    "format": "%-/%m-%d %H:%M:%S",
    "position": "br",
    "thickness": 2
  }
}

Relevant log output

frigate      | [2021-12-23 13:36:01] frigate.app                    INFO    : Starting Frigate (0.9.4-26ae608)
frigate      | Starting migrations
frigate      | [2021-12-23 13:36:01] peewee_migrate                 INFO    : Starting migrations
frigate      | There is nothing to migrate
frigate      | [2021-12-23 13:36:01] peewee_migrate                 INFO    : There is nothing to migrate
frigate      | [2021-12-23 13:36:02] frigate.mqtt                   INFO    : MQTT connected
frigate      | [2021-12-23 13:36:02] frigate.app                    INFO    : Output process started: 215
frigate      | [2021-12-23 13:36:02] frigate.app                    INFO    : Camera processor started for Terasz: 217
frigate      | [2021-12-23 13:36:02] detector.cpu1                  INFO    : Starting detection process: 213
frigate      | [2021-12-23 13:36:02] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
frigate      | [2021-12-23 13:36:02] ws4py                          INFO    : Using epoll
frigate      | [2021-12-23 13:36:02] frigate.app                    INFO    : Camera processor started for Nyugati oldal: 219
frigate      | [2021-12-23 13:36:02] frigate.app                    INFO    : Capture process started for Terasz: 221
frigate      | [2021-12-23 13:36:02] detector.cpu2                  INFO    : Starting detection process: 214
frigate      | [2021-12-23 13:36:02] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
frigate      | [2021-12-23 13:36:02] frigate.app                    INFO    : Capture process started for Nyugati oldal: 224
frigate      | [2021-12-23 13:36:02] ws4py                          INFO    : Using epoll

FFprobe output from your camera

N/A

Frigate stats

"{"Terasz": {"camera_fps": 5.2, "process_fps": 1.5, "skipped_fps": 0.0, "detection_fps": 1.2, "pid": 220, "capture_pid": 225}, "Nyugati oldal": {"camera_fps": 5.0, "process_fps": 2.0, "skipped_fps": 0.0, "detection_fps": 1.0, "pid": 221, "capture_pid": 228}, "detectors": {"cpu1": {"inference_speed": 849.97, "detection_start": 1640261767.436945, "pid": 213}, "cpu2": {"inference_speed": 848.51, "detection_start": 1640261767.69933, "pid": 214}}, "detection_fps": 2.2, "service": {"uptime": 44897, "version": "0.9.4-26ae608", "storage": {"/media/frigate/recordings": {"total": 5756366.2, "used": 3882443.8, "free": 1873922.4, "mount_type": "btrfs"}, "/media/frigate/clips": {"total": 5756366.2, "used": 3882443.8, "free": 1873922.4, "mount_type": "btrfs"}, "/tmp/cache": {"total": 2000.0, "used": 20.7, "free": 1979.3, "mount_type": "tmpfs"}, "/dev/shm": {"total": 33.6, "used": 12.1, "free": 21.5, "mount_type": "tmpfs"}}}}"

Operating system

Other

Install method

Docker Compose

Coral version

CPU (no coral)

Network connection

Wired

Camera make and model

Reolink RLC-510a

Any other information that may be helpful

No response

blakeblackshear commented 2 years ago

ML isn't used for motion detection. All motion detection must run within Frigate. It uses motion detection to determine where in the image to run object detection. https://docs.frigate.video/configuration/masks#further-clarification

zoltanszalontay commented 2 years ago

Great explanation. Thanks.