Better motion detection?

Support and queries relating to all previous versions of ZoneMinder
mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post by mor » Mon May 26, 2008 10:14 am

Hmm. I just found one of my zma processes chewing 1.8 gig of ram. So there's definately a memory leak somewhere, but I can't see what triggers it yet. I just re-read through my diffs and I don't _think_ I've added a memory leak but ....

moOd
Posts: 15
Joined: Tue May 13, 2008 9:53 pm

Post by moOd » Mon May 26, 2008 11:28 am

Hm. I applied your latest patch and have been running it for about 30 mins now. It's still running in alarm state.. and doesn't seem to be calming down.

Code: Select all

May 26 13:13:13 yin zma_m1[12663]: INF [Average 27.930651, pixels 614 (1.013229, 1.010361, 1.016342)]
May 26 13:13:13 yin zma_m1[12663]: INF [Average 9.318859, pixels 365 (1.014236, 1.011658, 1.015045)]
May 26 13:13:13 yin zma_m1[12663]: INF [Average 25.412925, pixels 520 (1.014236, 1.011658, 1.015045)]
May 26 13:13:14 yin zma_m1[12663]: INF [Average 7.702381, pixels 296 (1.017990, 1.013702, 1.022018)]
May 26 13:13:14 yin zma_m1[12663]: INF [Average 23.048835, pixels 435 (1.017990, 1.013702, 1.022018)]
May 26 13:13:15 yin zma_m1[12663]: INF [Average 10.417057, pixels 486 (1.020096, 1.016342, 1.022507)]
May 26 13:13:15 yin zma_m1[12663]: INF [Average 25.290770, pixels 532 (1.020096, 1.016342, 1.022507)]
[/size]

Cam:
Image

Delta:
Image

EDIT:
Now.. 50 mins later it seems to be a more stable, but still very sensitive. Jumps continuously between Alarm/Alert/Normal state.. :roll:

I'm still running with my old settings from the previous patch that worked fine. Should I adjust any parameters with this new one?

timcraig
Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA
Contact:

Post by timcraig » Mon May 26, 2008 5:37 pm

I gave your latest patch a try last night.

I have 7 analog cameras with capture size 640x480. 2 run at 4 fps, 2 run at 2.5 fps and 3 run at 1.6 fps. 4 are night vision the while the other 3 are low light sensitive and up to pick up infrared lighting. They were all running at ref blend 7 at first.

When I applied the patch. The training took a very long time. 3 cameras took 10 - 15 minutes to train while the others never left the alarm state for the 45 minutes I ran them. I then switch reference blend to 14 like moOd's 2fps camera. The training results were about the same.

One camera at my front door trained within 10 minutes but when my front door's light turns on than off, it took another 10 minutes to retrain.

It wasn't windy last night so I couldn't verify the filtering out moving trees and bushes but I was really impressed with the improved accuracy. At night time I didn't get very good accuracy. But with the patch people that appear as faint shadows in the camera image were picked up as motion.

Unfortunately I had to switch back the original 1.23.3 Zoneminder. The patch caused to much of a hit on system performance. I'm running on an Ubuntu 8.04 32-bit server edition (with nothing else installed but muinin). My system has a Pentitum 4 2.8 Ghz (with hyperthreading enabled), 3gigs of ram and a PV-155. Before my CPU would average at 40% with occasional spikes hitting 60%. My load would average would average about .40 with occasional spikes hitting 2.0. After the patch my CPU hit 200% and my load was around 6.0. It looks like my system can't handle the patch and 7 cameras at the same time.

Will the CPU utilization drop once all the cameras are trained, or does it stay the same?

mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post by mor » Mon May 26, 2008 8:27 pm

moOd wrote:Hm. I applied your latest patch and have been running it for about 30 mins now. It's still running in alarm state.. and doesn't seem to be calming down.
I'm still running with my old settings from the previous patch that worked fine. Should I adjust any parameters with this new one?
Yes, I need to post a new patch. This one is _much_ more sensitive than the old one. I'm unsure about the wisdom of the changes I've made. I'm currently running it with a threshold of 8.5 (!)

I may go back to the multiplicative noise masking. I think the additive is just too sensitive, and is a relatively poor match to the noise model.

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

Post by overly » Tue May 27, 2008 4:50 pm

mor wrote:Hmm. I just found one of my zma processes chewing 1.8 gig of ram. So there's definately a memory leak somewhere, but I can't see what triggers it yet. I just re-read through my diffs and I don't _think_ I've added a memory leak but ....
I'm finding my zma and zmc processes use a considerable amount of memory as well. My theory is that memory consumption increases even more when there is alot of noise motion. I'm guessing that's what led to the two crashes I've had - the system ran out of memory.

I used PS to try to determine memory usage:

Code: Select all

ps -eo args,rss,%mem --sort rss
It returned the following, which I believe indicates zma and zmc are using 63M and 75M of memory respectively. They are the top two in memory usage on my box at the moment:

Code: Select all

/usr/local/bin/zma -m 1     63564  6.5
/usr/local/bin/zmc -d /dev/ 75876  7.8
I haven't tried the motion-3.diff patch yet. It's working very well for me at the moment on motion-2. It's catching a bird when in lands in the camera view yet mostly rejects the motion caused by the afternoon tree shadows. My Average Pixel limit is currently at 15, Ref Image Blend is 5, 15 fps. I changed back to using one zone (I had used two previously before the new motion detection to attempt to reduce sensitivity for the tree shadows.

I'll give the motion-3 patch a try on the next go around.
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

SyRenity
Posts: 301
Joined: Mon Jan 24, 2005 2:43 pm

Post by SyRenity » Wed May 28, 2008 9:00 am

Hi.
oys wrote: I think that by object removal/placement detection, SyRenity meant:
For a museum an alarm could be generated if a painting was removed for more than X amount of time, but not if someone simply walks past it and obscures it.
For an airport, an alarm could be generated it a suitcase (bomb) was added and left stationary for more than X amount of time.

Also, with a motion detection algorithm that adapts to lighting conditions, could someone gradually overexpose a camera by using a flashlight (with variable intensity) without an event being generated?
Yep, that exactly what I meant :).
cordel wrote: This would be nice but I'm afraid we are a long way from this ability, even with what is being done in this thread, there would be much work to get to that point.
Why do you think so? If the whole algorithm is based on building adapting static image, and then detecting any fast changes on it, I think it can be also extended to detecting changes that "merge" into the static image.

sceadu
Posts: 4
Joined: Wed Feb 27, 2008 7:41 am

Post by sceadu » Tue Jun 03, 2008 7:58 am

This patch looks great. I'm having a hard time getting the right settings with the current ZM. To much alarms or not enough.
But i'm pretty new to both Linux and ZM so i wonder when this will be ready for someone like me? Not that it have to be included into ZM. With some simple instructions i think i can get it to work. But it seems now that you need to make changes to the code to tweak the settings.
Would be very happy to get some guide to configure this and get it to work.

Thank you.

mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post by mor » Sat Jun 07, 2008 5:19 am

Updated patch at http://www.dgmo.org/zoneminder-1.23.3-motion-4.diff

This has higher thresholds, and much, much lower CPU usage. (Less than half what was previously using). Just for future reference; calculations are free, accessing memory is expensive. time in ::Blend dropped by 30% switching from an array of int, to an array of short.

sceadu: Yes, you currently need to be happy to tweak the code.

Having said that, you should be able to apply the patch to zoneminder 1.23.3, selection motion detection, select 'blend during motion', and then fiddle with the transparency setting until you're happy with the result.

SyRenity
Posts: 301
Joined: Mon Jan 24, 2005 2:43 pm

Post by SyRenity » Sat Jun 07, 2008 8:38 pm

Hi.
mor wrote:Updated patch at http://www.dgmo.org/zoneminder-1.23.3-motion-4.diff

This has higher thresholds, and much, much lower CPU usage. (Less than half what was previously using). Just for future reference; calculations are free, accessing memory is expensive. time in ::Blend dropped by 30% switching from an array of int, to an array of short.
Great news :).

How's these speeds and loads are compared to ZM original mechanism?

Regards.

User avatar
robi
Posts: 477
Joined: Sat Mar 17, 2007 10:48 am

Post by robi » Sun Jun 08, 2008 11:03 am

Can this patch be applied on a running LiveCD version of ZoneMinder?
v1.25.0 + Ubuntu Linux 12.04 Server

behdha
Posts: 15
Joined: Thu Feb 07, 2008 12:20 pm

howto patch

Post by behdha » Wed Jun 11, 2008 5:28 am

Hi,

Maybe a dumb question, but i am a bit of a n00b, but how can i apply this patch againt which file?



thnx,

Dave

moOd
Posts: 15
Joined: Tue May 13, 2008 9:53 pm

Post by moOd » Wed Jun 11, 2008 6:02 pm

Maybe a dumb question, but i am a bit of a n00b, but how can i apply this patch againt which file?
You apply the patch by simply running "patch -p1 < PATCHFILE.diff" in the same directory you've got your sourcecode for ZoneMinder v1.23.3.
Last edited by moOd on Wed Jun 11, 2008 8:46 pm, edited 1 time in total.

moOd
Posts: 15
Joined: Tue May 13, 2008 9:53 pm

Post by moOd » Wed Jun 11, 2008 8:43 pm

I've now tried the latest patch this evening but are getting some strange results when looking at the delta image.

The images looks like this:

Image

It seems that the resolution is wrong, or something? :roll:
I will try some more testing later and also do a fresh reboot of everything to be sure it's not my server.

However, the CPU-load dropped dramatically compared to the other patches.. Good work! :!:

mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post by mor » Thu Jun 19, 2008 7:04 am

Just posted latest code at http://www.dgmo.org/zoneminderpatches

Mostly minor changes to tweak the settings. I'm running all cameras at 10 fps, with transparency set to 10%, and it's performing pretty well.

moOd: Which delta image is that? /tmp/blend*.jpeg or /tmp/sq*.jpeg?

That looks fine for a /tmp/sq* image. It's basically saying that there's not a lot of noise in the image stream.

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

Post by overly » Thu Jun 19, 2008 5:43 pm

mor,

I'm running your latest patch (motion-4) and was poking through the code with thoughts of tweaking the transparency. It was suggested at some point that a memory leak may exist and I think I may have found something.

In zm_image.cpp line 828 in Image::Blend() a debug image is created with:

Code: Select all

result = new Image( width, height, colours );
I don't see when the Image object is ever destroyed. Am I missing something or is this a potential leak?

-Ken
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

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests