<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.staging.zoneminder.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ocgltd</id>
	<title>ZoneMinder Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.staging.zoneminder.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ocgltd"/>
	<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/Special:Contributions/Ocgltd"/>
	<updated>2026-04-20T00:22:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.staging.zoneminder.com/index.php?title=AxisMotionDetection&amp;diff=5491</id>
		<title>AxisMotionDetection</title>
		<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=AxisMotionDetection&amp;diff=5491"/>
		<updated>2012-07-31T15:15:32Z</updated>

		<summary type="html">&lt;p&gt;Ocgltd: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I had this performance problem while monitoring and event recording for 8-10 IP cameras using the ZM.&lt;br /&gt;
ZM is too good a software to abandon just for performance issues. So I decided I should pay more attention to the motion detection feature of the cameras I have and relieve the ZM server from the task of detecting motion.&lt;br /&gt;
I&amp;#039;ve finally managed to use the on-camera motion detection feature of Axis Cams and here are my notes:&lt;br /&gt;
&lt;br /&gt;
== Cameras ==&lt;br /&gt;
 &lt;br /&gt;
I&amp;#039;ve set my Axis camera as follows:&lt;br /&gt;
&lt;br /&gt;
[[Image:AxisMDetect1.png]]&lt;br /&gt;
[[Image:AxisMDetect2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The text &amp;quot;1|on 5|5|cause|text|showtext&amp;quot; means that&lt;br /&gt;
alarm will be triggered for the monitor which has ID=1,&lt;br /&gt;
alarm will set recording on&lt;br /&gt;
alarm will be cleared after 5 seconds.&lt;br /&gt;
The score of the alarm is 5 ( any score &amp;gt;0 is OK)&lt;br /&gt;
&amp;quot;text&amp;quot; and &amp;quot;showtext&amp;quot; are just explanatory notes.&lt;br /&gt;
&lt;br /&gt;
The ZM specs tells us that the format of the message can include a &amp;quot;duration&amp;quot; as long as the message is sent as:&lt;br /&gt;
&amp;quot;1|on+5|5|cause|text|showtext&amp;quot; bu the problem is the Axis camera cannot or will not save the &amp;quot;+&amp;quot; sign which appears in the message. A CGI parameter conversion problem I presume...&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ve taken care of this &amp;quot;+&amp;quot; problem with a small modification in zmtrigger.pl source (see below).&lt;br /&gt;
&lt;br /&gt;
Next, I specified the host IP address of the zm computer and its default zmtrigger port of 6802.&lt;br /&gt;
&lt;br /&gt;
[[Image:AxisMDetect3.png]]&lt;br /&gt;
[[Image:AxisMDetect4.png]]&lt;br /&gt;
&lt;br /&gt;
The second important setup is the &amp;quot;motion detection&amp;quot; setup on the Axis. I created a window which covers the area of interest; kept the object size as small as possible, pulled the history slider all the way back to zero and left the sensitivity slide somewhere past the %50 value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== ZM settings ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is no special setting for the ZM except that I&amp;#039;ve assigned the &amp;quot;Nodect&amp;quot; function to my camera monitor.&lt;br /&gt;
&lt;br /&gt;
[[Image:AxisMDetect5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, I modified the zmtrigger.pl file so that the first few lines of the&lt;br /&gt;
function handleMessage looks like this:&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
         sub handleMessage{&lt;br /&gt;
        my $connection = shift;&lt;br /&gt;
        my $message = shift;&lt;br /&gt;
        #&lt;br /&gt;
        #  CUA  - Axis camera send the message quoted with&amp;quot;&lt;br /&gt;
        #  CUA  - Also Axis camera cannot save the plus sign which&lt;br /&gt;
        #  CUA  - possibly exists in the 1|on+20|score|cause|text|showtext formatted msg&lt;br /&gt;
&lt;br /&gt;
        $message=~ s/^\&amp;quot;//g;&lt;br /&gt;
        $message=~ s/\&amp;quot;$//g;&lt;br /&gt;
        $message=~ s/on /on\+/;&lt;br /&gt;
&lt;br /&gt;
        #  CUA - end of modifications&lt;br /&gt;
&lt;br /&gt;
        my ( $id, $action, $score, $cause, $text, $showtext ) = split( /\|/, $message );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
a few other modifications I made in the zmtrigger.pl file are commenting out some unused modules and pushes:&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
        use ZoneMinder::Trigger::Channel::Inet;&lt;br /&gt;
        #CUA use ZoneMinder::Trigger::Channel::Unix;&lt;br /&gt;
        #CUA use ZoneMinder::Trigger::Channel::Serial;&lt;br /&gt;
           use ZoneMinder::Trigger::Connection;&lt;br /&gt;
&lt;br /&gt;
         my @connections;&lt;br /&gt;
         push( @connections, ZoneMinder::Trigger::Connection-&amp;gt;new( name=&amp;gt;&amp;quot;Chan1&amp;quot;, channel=&amp;gt;ZoneMinder::Trigger::Channel::Inet-&amp;gt;new( port=&amp;gt;6802 ), mode=&amp;gt;&amp;quot;rw&amp;quot; ) );&lt;br /&gt;
         #CUA push( @connections, ZoneMinder::Trigger::Connection-&amp;gt;new( name=&amp;gt;&amp;quot;Chan2&amp;quot;, channel=&amp;gt;ZoneMinder::Trigger::Channel::Unix-&amp;gt;new( path=&amp;gt;&amp;#039;/tmp/test.sock&amp;#039; ),         mode=&amp;gt;&amp;quot;rw&amp;quot; ) );&lt;br /&gt;
        #push( @connections, ZoneMinder::Trigger::Connection-&amp;gt;new( name=&amp;gt;&amp;quot;Chan3&amp;quot;, channel=&amp;gt;ZoneMinder::Trigger::Channel::File-&amp;gt;new( path=&amp;gt;&amp;#039;/tmp/zmtrigger.out&amp;#039; ), mode=&amp;gt;&amp;quot;w&amp;quot; ) );&lt;br /&gt;
         #CUA push( @connections, ZoneMinder::Trigger::Connection-&amp;gt;new( name=&amp;gt;&amp;quot;Chan4&amp;quot;, channel=&amp;gt;ZoneMinder::Trigger::Channel::Serial-&amp;gt;new( path=&amp;gt;&amp;#039;/dev/ttyS0&amp;#039; ), mode=&amp;gt;&amp;quot;rw&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my modifs are marked with &amp;quot;# CUA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These three regular expressions remove the quotes sent by Axis which envelope the message string and insert a plus sign if the &amp;quot;on&amp;quot; command is followed by a space). These 3 statements convert an incoming message of the form&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
        &amp;quot;1|on 25|5|cause|text|showtext&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
to&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
        1|on+25|5|cause|text|showtext&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
and of course, you shouln&amp;quot;t forget to restart zmtrigger.pl; or better still modify the zm startup script so that it starts zmtrigger.pl everytime zm is [re]started.&lt;br /&gt;
&lt;br /&gt;
Note: If you plan to use the zmxap interface (to connect ZoneMinder to MisterHouse using xAP), your cause must be &amp;quot;Motion&amp;quot; (without quotes), and your text must be a single word (no spaces); eg: LAWN.  In Misterhouse, the camera name will be the MONITOR name (eg: FRONT_DOOR), and the zone name will be the text (eg: LAWN).  If you don&amp;#039;t follow this convention then MisterHouse will not respond to the xAP event messages properly.&lt;br /&gt;
&lt;br /&gt;
I added the line &amp;#039;/usr/bin/zmtrigger.pl &amp;amp;&amp;quot; in the start section of&lt;br /&gt;
/etc/init.d/zoneminder and also added the line &amp;quot;pkill zmtrigger.pl&amp;quot; in the stop section.&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
&lt;br /&gt;
        start() {&lt;br /&gt;
        echo -n &amp;quot;Starting $prog: &amp;quot;&lt;br /&gt;
        $command start&lt;br /&gt;
        # CUA&lt;br /&gt;
        /usr/bin/zmtrigger.pl &amp;amp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        RETVAL=$?&lt;br /&gt;
        [ $RETVAL = 0 ] &amp;amp;&amp;amp; echo success&lt;br /&gt;
        [ $RETVAL != 0 ] &amp;amp;&amp;amp; echo failure&lt;br /&gt;
        echo&lt;br /&gt;
        [ $RETVAL = 0 ] &amp;amp;&amp;amp; touch /var/lock/zm&lt;br /&gt;
        return $RETVAL&lt;br /&gt;
        }&lt;br /&gt;
        stop() {&lt;br /&gt;
        echo -n $&amp;quot;Stopping $prog: &amp;quot;&lt;br /&gt;
        #&lt;br /&gt;
        # Why is this status check being done?&lt;br /&gt;
        # as $command stop returns 1 if zoneminder&lt;br /&gt;
        # is stopped, which will result in&lt;br /&gt;
        # this returning 1, which will stuff&lt;br /&gt;
        # dpkg when it tries to stop zoneminder before&lt;br /&gt;
        # uninstalling . . .&lt;br /&gt;
        #&lt;br /&gt;
        # CUA&lt;br /&gt;
        pkill zmtrigger.pl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I just hope that this helps other people trying to implement the on-camera motion detection with ZM.&lt;br /&gt;
&lt;br /&gt;
Again; many thanks to those people who developed ZM at the first place and to those who helped it to become a perfect opensource project.&lt;br /&gt;
&lt;br /&gt;
[http://www.zoneminder.com/forums/viewtopic.php?t=10872 Original Thread]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DO NOT PM THESE USERS &amp;quot;&amp;quot;just post a question in the forum&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Copied By: KingOfKYA&lt;br /&gt;
&lt;br /&gt;
Created By: cayfer&lt;/div&gt;</summary>
		<author><name>Ocgltd</name></author>
	</entry>
</feed>