OpenCV

Anything you want added or changed in future versions of ZoneMinder? Post here and there's a chance it will get in! Search to make sure it hasn't already been requested.
gianfx
Posts: 3
Joined: Tue Feb 24, 2009 6:54 pm

Post by gianfx »

Hi,
I'm italian's student of computer science. I'm trying to hack ZM to support Opencv Computer Vision features available in the academic literature.
I started to prepare a in the IDE framework to developer in C++ and recompile ZM using Opencv header file in ZM source. I did this by changing the ZM's configure file adding the link to Opencv header dir and libs. was necessary to alter the files of opencv headers for bypassing Opencv's conditional compilation (C/C++) issue (commenting on some lines).

The first step of the modification was to introduce a new instance variable (IplImage*) to the class "image" of ZM to linking ZM's image data. I changed some php files and database tables to introduce a new feature can be activated / deactivated via Web: OpencvProcessing " I have also introduced a new "state" and a new "functions" in typedef struct of the C + + ZM project("monitor" class).

The next steps introduce new methods to the ZM's class "monitor". Afterwards I have introduced a pipeline to implement the motion tracking putting into Capture()/Analyse() method of Monitor class their instance.<br>
Meanwhile i'm working to publishs the hacked ZM server I put belove some screenshots:

Image
Image
Image
Image

I will be happy to collaborate with those interested in my work.

(I'm sorry for my bad English)
greetings Gianfx
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

Good work gianfx!
overly
Posts: 36
Joined: Mon Aug 20, 2007 6:14 pm
Location: Cleveland, Ohio USA

Post by overly »

gianfx,

I've been trying to join ZoneMinder and OpenCV for some time now to improve the motion detection. I have made little progress compared to you. I have also spent a lot of time comparing the motion detection code from both ZoneMinder and Motion. Motion seems to reject false alarms much better than ZoneMinder and I believe it's due to the Smart Mask feature of Motion.

I would be interested in collaborating with you if you would like. Which OpenCV algorithm were you using? The bgfg_segmentation example?

Please, make no apologies for your English - it's much better than my Italian!
Bluecherry PV-149 4-port capture card
Topica TP-936WIR-30C camera
Cheap Harbor Freight camera
HP Athlon 64 X2 w/ 2GB
Slackware 13 - 2.6.29.6-smp kernel
gianfx
Posts: 3
Joined: Tue Feb 24, 2009 6:54 pm

Post by gianfx »

overly,

For the moment I have suspended the development of OpenCV in ZM. However I have worked to implements a pipeline for hi livel features analisys in video. I can use several type of foreground segmentation model (MoG is very performer)
The pipeline is composed of:

1) foreground segmentation (you can use any type already implemented in OpenCV like MoG, "Complex background in video seq", codeword approch etc.)

2) A blob detector which groups adjacent "foreground" pixels into blobs

3) A blob tracker which assigns ID numbers to blobs and tracks their motion frame-to-frame

I think create a robust pipeline in ZM as described above allows us to make assumptions about moving objects at a level much higher than simple motion detect. (Human detect, car detect, plate recognition etc..). At this moment I'have implemented only pipeline belove described, in the monitor class of ZM for the simple tracking of foreground objects.
(see video ZM event exported) .
I would like to work for linking the ZM zones in Opencv analisys bat unfortunately I can not devote much time to programming. :-(

I'm happy to share and swap ideas with you.
...waiting for reply...
chestnut
Posts: 5
Joined: Fri Oct 01, 2010 2:56 pm

Post by chestnut »

Hi, Gianfx:

I am a student in computer science. I am trying to use more advanced motion detection algorithms to replace the one used in ZoneMinder now. I happen find you have already done a lot of work here, your work looks great!

I did not use zoneminder before, so understanding the whole framework and source code may take a too long time. Can you tell me how can I proceed with this work, e.g., specify how and where I need make changes in zoneminder, including source code, scripts and web frontend? Or can you share me some of your source code for references, I have my own motion detection code ready now, but need to integrate them to zoneminder to make it function well.

Thanks, Eric
gianfx
Posts: 3
Joined: Tue Feb 24, 2009 6:54 pm

Post by gianfx »

Hi Eric,

I'm not have a lot experience about open source with makefile projects but as first step I configured eclipse c++ IDE with ZM source code project. (new c++ make file project then link ZM source directory). At this step you have a C++ ZM project for your customization!(only C++ editing).
In second step you need to link opencv lib at configure file of ZM project (you can probably do this by passing arguments to configure file of ZM but experimentally so it's good enough!)
you can modify configure file in ZM project through Eclipse IDE like in code below:

Code: Select all

FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include"


+CPPFLAGS="$CPPFLAGS -I/usr/local/include/opencv"
+CPPFLAGS="$CPPFLAGS -D__STDC_CONSTANT_MACROS"
+LDFLAGS="$LDFLAGS -L/usr/local/lib"
...
in third step you might configure ZM project for opencv library like you can see from more tutorial findign in google: eclipse + opencv...

ask me if you have a problem so far

Gianfx
swuu
Posts: 1
Joined: Thu Apr 07, 2011 3:50 am

Re: OpenCV

Post by swuu »

I dont know this looks even better than open cv. Might be easier to intergrate. Prob not though

(agh tee tee pee semi Colin foward slash forward slash)info(dot)ee(dot)surrey(dot)ac(dot)uk/Personal/Z.Kalal/tld.html

Includes source code for the awesome price of free.

Admin please edit my post so my link doesn't look retarded
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Re: OpenCV

Post by Normando »

http://info.ee.surrey.ac.uk/Personal/Z.Kalal/tld.htm

Looks very nice!

But should be ported to linux before we can do anything:

https://github.com/zk00006/OpenTLD/blob/master/README
mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Re:

Post by mastertheknife »

JackG wrote:I've been playing around with OpenCV hopeing to build a more robust motion detector for ZM to fix some of the flaws I see in my setup with ZM 1.23's detector. I tweaked the motion template example a bit, and the resulting alg doesn't get false positives on blinking (auto shutter switching between "night" and "day" mode) on cheap cameras, and is more robust against moving trees. So now I need to plumb it in to put it to use. What is needed is first data structure translation to put the ZM images into OpenCV IplImage strutures, which is trivial. But then ZM needs to also be hacked up to call the new detector.

I've done a little searching here, and hope I haven't missed something, but I haven't found any type of detector plug-in architecture. Did I miss something? For just experimenting one can just hack up ZM to call the new detector. But it wouldn't be hard to put together a .so based plugin architecture. It only needs a couple entry points: open, detect with new image, and close. Making a .so interface means that it is much easier for people to experiment with new motion detectors, and ZM could also add a new detector to a binary distro.

So is there a plugin arch for motion detectors?
Although it is not too difficult to do, keep in mind that motion detection in zoneminder works differently. A 8bit grayscale delta(difference) image is generated for every captured frame, containing the difference between the captured frame and the reference picture.
Then for each zone, that delta picture is checked and depending on the parameters and difference, an alarm can be triggered.

mastertheknife.
Kfir Itzhak.
promethiusan
Posts: 9
Joined: Mon Sep 21, 2009 7:53 pm

Re: OpenCV

Post by promethiusan »

swuu wrote:I dont know this looks even better than open cv. Might be easier to intergrate. Prob not though

(agh tee tee pee semi Colin foward slash forward slash)info(dot)ee(dot)surrey(dot)ac(dot)uk/Personal/Z.Kalal/tld.html

Includes source code for the awesome price of free.

Admin please edit my post so my link doesn't look retarded
That code uses OpenCV 2.2.
Post Reply