Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support for opencv-based object detection #2864

Open
jbruening opened this issue Feb 23, 2022 · 5 comments
Open

[Feature Request] Add support for opencv-based object detection #2864

jbruening opened this issue Feb 23, 2022 · 5 comments
Labels
enhancement New feature or request pinned

Comments

@jbruening
Copy link

Describe what you are trying to accomplish and why in non technical terms
Opencv is capable of performing its own object detection, and can load a variety of model formats. Adding this would allow object detection acceleration on other hardware than just coral/nvidia (such as opencl and vulkan).

Describe the solution you'd like
Using the object detection example from opencv, create an object detection implementation that uses opencv rather than tensorflow, and add options in the configuration to use the opencv detector rather than the tensorflow detector. This should be able to be done on the 'cpu' version of frigate, as long as the opencv dnn module is included.

Describe alternatives you've considered
This is adding alternatives for object detection in tensorflow, allowing more users to use hardware acceleration.

Additional context
Opencv currently does not support loading tflite files. One would need to obtain alternative model files at the moment

@jbruening jbruening added the enhancement New feature or request label Feb 23, 2022
@jbruening jbruening changed the title Add support for opencv-based object detection [Feature Request] Add support for opencv-based object detection Feb 23, 2022
@tjedmunds
Copy link

I just ordered a Coral TPU from the one place that would actually accept an order and they quoted a 46 week wait time! Every place is backordered. It looks like having alternatives to use the GPU is going to be essential for the next year or so.

@tjedmunds
Copy link

After looking at the frigate code a little bit it occurred to me that this feature could be GREATLY simplified by implementing this as a feature to call an external REST API for object detection. I previously used a project called mlapi (https://github.com/ZoneMinder/mlapi) with ZoneMinder and it basically exposes object detection with opencv and GPU support via such an API. There really isn’t anything ZM specific to what it does and it seemed to be actively maintained for the few years I used it.

Setting up mlapi isn’t simple and usually involves compiling stuff specific for your GPU card. But the upside is that the messy part doesn’t become part of Frigate but leverages an existing open source project.

Something to think about…

@blakeblackshear
Copy link
Owner

It will probably be too slow. Frigate is fast because it works with the same decoded frames in memory across the entire pipeline. If you have to copy, convert, and call a 3rd party service, you probably arent going to get much better latency than running CPU detectors when it's all said and done. If I was going to support this, it would probably use doods.

@tjedmunds
Copy link

Yeah that makes sense. I thought about the speed issue. I am just more concerned with managing my CPU usage at the moment until I can snag a TPU. I think the way it worked with ZM is that it may have only checked the frame with the 'most' motion in an event or the frame that triggered the alarm but I always felt that it was hackish in the way it was done. Object detection was an afterthought and not integrated into the pipeline.

@blakeblackshear
Copy link
Owner

I may look at adding some configuration options to tone down the object detection a bit. Frigate is currently built around the assumption that it has access to a Coral that can run it fast without much overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned
Projects
None yet
Development

No branches or pull requests

3 participants