blakeblackshear / frigate

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

Why not add support for ONVIF events for motion detection? #3485

Closed Aculeasis closed 2 years ago

Aculeasis commented 2 years ago

Describe what you are trying to accomplish and why in non technical terms I want to use cameras' motion detectors via ONVIF events to decrease cpu usage.

Describe the solution you'd like Add new motion detector type - something like the ONVIF motion events

Additional context Many modern ip cameras have internal detectors (sound, move, zone etc.) and support ONVIF events. For example a connected my dahua cam to HA via ONVIF and I can use motions' binary sensors. I think it is a wonderful option for low hardware with coral tpu and a lot of cameras. https://www.home-assistant.io/integrations/onvif/#supported-sensors

NickM-27 commented 2 years ago

I'm not super familiar with ONVIF motion detection protocol, but frigate doesn't just say "if motion detected somewhere then run object detection", it is hyper focused on only detected motion based on how the config is setup and then also will ignore motion that occurs inside of motion masks (like a tree or something).

Frigate uses the location of motion to decide where to pull a region from to run object detection on it (frigate does not run object detection on the entire frame when motion occurs). So if ONVIF motion doesn't provide this pixel based location of motion, it would be useless to frigate.

Other problem is, each camera may have a different % support of protocol and that would create its own issues for supporting this.

NickM-27 commented 2 years ago

I looked through the ONVIF protocol specifications.

The manually defined polygons / regions wouldn't realistically work since these seem to be user-setup and not dynamic. The cell based option could potentially work depending on how configurable the cell sizes / positions are:

Cell based motion detection determined by placing a grid over the video source and determining changes.

Aculeasis commented 2 years ago

So if ONVIF motion doesn't provide this pixel based location of motion, it would be useless to frigate.

It is sad. Maybe hikivision protocol supports it, but it's proprietary.

NickM-27 commented 2 years ago

I'm not sure if it needed to be closed, my second comment highlighted some options that could work depending on how it's implemented

Aculeasis commented 2 years ago

The manually defined polygons / regions wouldn't realistically

This is it? image I think this has only a region name. image

Also, I tried to subscribe on events using onvif_zeep for my inside camera, but all examples don't work and ONVIF device manager can't see the events. But HA works =\

NickM-27 commented 2 years ago

I was referring to

Cell based motion detection determined by placing a grid over the video source and determining changes.

Not sure if you see anything like that

Tyler-2 commented 1 year ago

Wouldn't this be useful in the sense that Frigate wouldn't need to do constant motion detection, and could just do motion detection on a buffered stream based on when ONVIF motion is reported?

NickM-27 commented 1 year ago

Wouldn't this be useful in the sense that Frigate wouldn't need to do constant motion detection, and could just do motion detection on a buffered stream based on when ONVIF motion is reported?

Frigates motion detection is not momentary, it keeps calculating an average background to know where motion is occurring as well as to know when to ignore motion because it's too large (like when a camera changes from color to IR).

YBonline commented 10 months ago

Can I request this be reopened? My server CPU ground to a halt today because I had a TON of motion activity (I believe in excess of 25 cameras, which is unusual), and this is a feature that other software like Shinobi and Blue Iris has. I understand its not a priority but I'm hoping it can be added at some point, I'm pretty confident I'm at my limit of adding more cameras without something to reduce CPU and memory usage substantially

NickM-27 commented 10 months ago

we already have ideas for how to further reduce motion detection cpu usage, and as has been explained above the motion data in onvif is not specific enough and also likely not fast enough to process data in real time like frigate does