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

Integrate OpenCV's image detection into zm_monitor.cpp as an alternate option #2138

Open
pliablepixels opened this issue Jul 2, 2018 · 18 comments
Labels

Comments

@pliablepixels
Copy link
Member

pliablepixels commented Jul 2, 2018

OpenCV offers some "reasonable" methods to detect people. They are not as accurate as CNNs and use HOGs but are of orders of magnitude faster. The code is straight forward, for example, this. OpenCV code is very portable, and in C++, and therefore integration into ZM is not hard. (I don't feel like investigating - someone who knows zm_monitor.cpp and how ZM handles image buffers should be able to do it much faster than me)

There are multiple profiles to choose from (different XML files)

The request:
a) Integrate OpenCV with ZM
b) Select "Person Detection" as a scheme as a detection algorithm as an alternate to "Pixels/Filter/Blob" and basically replicate the functionality provided in the link above.
c) Ability to specify a "frame interval" -> which will basically decide how often this logic will be used. In other words, even if I select the monitor FPS as say 5, I should be able to select "2" here, which will mean detection to be applied on the 1st, 3rd, 5th frames - for more speed control without affecting live fps
d) Draw a bounding box around the person detected in frame (Again, already part of the sample code)

3rd party work
a) This company did some early work here in 2011, if it helps. Licensed under GPL.

Future Enhancement
Not a necessary condition for the bounty:
a) Ability to make item b) above in request section more flexible. Let me select any XML profile in OpenCV so I can tweak my model.

I'll be putting in a $100 bounty for this.

@pliablepixels
Copy link
Member Author

pliablepixels commented Jul 2, 2018

@connortechnology
Copy link
Member

So I have merge the CVisionLabs work into my opencv branch. However the plugin code is for an ancient version of opencv.... so I think I'll be updating that to version 3.

@pliablepixels
Copy link
Member Author

do you have a branch I can track/test?

@connortechnology
Copy link
Member

my opencv branch

@TheSwert
Copy link
Contributor

Since version 3.4.2 of OpenCV, it looks like it now supports the YOLOv3 DNN detector as well. Below link has some C++ and python examples.
https://www.learnopencv.com/deep-learning-based-object-detection-using-yolov3-with-opencv-python-c/

@pliablepixels
Copy link
Member Author

pliablepixels commented Oct 8, 2018

I'm going to revise some of the asks based on integrating both OpenCV approaches in the ZM event notification server:

I originally said:

b) Select "Person Detection" as a scheme as a detection algorithm as an alternate to "Pixels/Filter/Blob" and basically replicate the functionality provided in the link above.
c) Ability to specify a "frame interval" -> which will basically decide how often this logic will be used. In other words, even if I select the monitor FPS as say 5, I should be able to select "2" here, which will mean detection to be applied on the 1st, 3rd, 5th frames - for more speed control without affecting live fps

Based on my experience actually trying to get it working:

  • Many (if not most) users of ZM are not running a GPU
  • OpenCV SVM HOG is very fast but not quite accurate. It keeps identifying my water heater as a "person" (On an Intel Xeon 3.16GHz 4Core machine with no GPU HOG takes 0.25s)
  • OpenCV DNN with Yolov3 (80 labels) but with Tiny-Yolo weight/config is much more accurate and takes almost the same time as HOG (On an Intel Xeon 3.16GHz 4Core machine with no GPU this takes 0.34s)
  • OpenCV DNN with Yolov3 (80 labels) and yolov3 config /weight files is most accurate but without a GPU takes 10x the time as HOG (On an Intel Xeon 3.16GHz 4Core machine with no GPU YoloV3 takes 2.4s)

To make this practically useful, I'd like to suggest that "Person detection" is implemented as 2 options:

a) As a replacement for "motion" - that way people don't have to worry about defining zones and configuring its accuracy
b) As a "after motion" analysis so that people can configure some basic but very lenient motion system and only trigger person detect if motion occurred first

@stale
Copy link

stale bot commented Dec 9, 2018

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.

@stale stale bot added the stale label Dec 9, 2018
@stale stale bot closed this as completed Dec 16, 2018
@stale stale bot removed the stale label Dec 17, 2018
@3lk0k0
Copy link

3lk0k0 commented Dec 24, 2018

anyone know if these if going to do ?

@connortechnology
Copy link
Member

I started on it... but there is lots more to do.

@jysaloma
Copy link

There is also some work done in this project for face recognition https://github.com/goruck/smart-zoneminder by goruck

@stale
Copy link

stale bot commented Apr 11, 2019

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.

@stale stale bot added the stale label Apr 11, 2019
@stale stale bot removed the stale label Apr 11, 2019
@cleverinx
Copy link

Is this still in progress?

@connortechnology
Copy link
Member

bountysource will take this money on July 1st. Either contact bountysource to redirect your funds, or alternatively, I can close this out, collect the bounty, and I will hold the money until this issue is properly closed.

@pliablepixels
Copy link
Member Author

I’d prefer you just collect for the money I added.

@Rayn0r
Copy link

Rayn0r commented Nov 10, 2020

@connortechnology
Is implementing OpenCV into Zoneminder still on the list of things to do?

@connortechnology
Copy link
Member

Yes

@dirkarnez
Copy link

@connortechnology
Hi is this still open please?

@connortechnology
Copy link
Member

Yes it's still open. I'm not sure it's a good idea, as I think AI should be happening in it's own process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8 participants