Print special things on Webcam Images (zmtrigger.pl)

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.
Post Reply
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Print special things on Webcam Images (zmtrigger.pl)

Post by lukelukeluke »

Hi, I wondered if there was a solution to print more than timestamps on Zoneminder generated images. I know you can display the time and title, but I would like to display output of an external application on it, for example display the temperature with something like: `cat /tmp/curtemp`.

I've seen in the manual that there is ZoneMinder-1.23.3/scripts/zmtrigger.pl:
‘showtext’ is up to 32 characters of text that can be displayed in the timestamp that is added to images. The ‘show’ action is designed to update this text without affecting alarms but the text is updated, if present, for any of the actions. This is designed to allow external input to appear on the images captured, for instance temperature or personnel identity etc.
But I can't find an instruction on how to use zmtrigger...?
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

Since no one answered, I tried the following workaround for my problem:
I wrote an external PHP-Script, which changes the Database entry Monitors.LabelFormat which I wanted to execute every 5 minutes. But apparently the change of this entry doesnt effect the timestamp on the image, even tough the Monitors Timestamp settings are updated in the settings pane - but the Monitor is only updated correctly when the Save button is pressed within Zoneminder.
Does anyone know a workaround for my workaround? :?
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

Normando posted the solution in this topic:
Normando wrote:1- Comment those channels you will not use. In my case I only use port 6802 to control zmtrigger.pl, so comment the rest of connection in zmtrigger.pl

Code: Select all

 my @connections;
push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan1", channel=>ZoneMinder::Trigger::Channel::Inet->new( port=>6802 ), mode=>"rw" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan2", channel=>ZoneMinder::Trigger::Channel::Unix->new( path=>'/tmp/test.sock' ), mode=>"rw" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan3", channel=>ZoneMinder::Trigger::Channel::File->new( path=>'/tmp/zmtrigger.out' ), mode=>"w" ) );
#push( @connections, ZoneMinder::Trigger::Connection->new( name=>"Chan4", channel=>ZoneMinder::Trigger::Channel::Serial->new( path=>'/dev/ttyS0' ), mode=>"rw" ) );
2- Enable triggers in options and restart zm

Code: Select all

OPT_TRIGGERS
3- Send the command to the port 6802. You can make a script in php to access the socket in that port or send directly with your external app. I have write my own php script:

Code: Select all

$cfgServer    = "localhost";
$cfgPort    = 6802;
$cfgTimeOut    = 10;

if ($extTrigger) {
    // open a socket
    if(!$cfgTimeOut) {
	// without timeout
        @$conn_handle = fsockopen($cfgServer, $cfgPort);
    }else{
	// with timeout
        @$conn_handle = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
    }
    if(!$conn_handle) {
    //    echo "Connexion failed ";
        echo "E1";
	exit();
    }else{
    //    echo "Connected ";
	echo "E0";
        fputs($conn_handle, $extTrigger);
    }
// close connexion
fclose($conn_handle);
}
4- Add the token %Q at the end of timestamp string in your monitor settings, or where you want.

5- Change the monitor function to NoDect, MoCord or MoDect. If you want more functions to use external trigger look at http://www.zoneminder.com/forums/viewtopic.php?t=12926

6- Send the command. In my case because script, I send via URL:

Code: Select all

http://myserver/zm/myscript.php?extTrigger=<id>|<action>|<score>|<cause>|<text>|<showtex>
in your case

Code: Select all

http://myserver/zm/myscript.php?extTrigger=1|show||||your_text

Reply the results
ludri
Posts: 13
Joined: Mon Dec 15, 2008 12:10 am

Post by ludri »

Thanks this works for me too.
whatboy
Posts: 304
Joined: Mon Aug 31, 2009 10:31 pm

Post by whatboy »

Wonder how can you past info from a file, I have a weather station, and I generate a file every 5 minutes with temp, wind, rain, etc... and wanted to pass that info from the file to Zoneminder...
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

If you used the php version, you could just do a little shell script that would open that file (a certain information from it) and call the PHP script with your information:

Code: Select all

VAR=`cat /path/to/your/file | grep line`
wget http://myserver/zm/myscript.php?extTrigger=1|show||||$VAR
For more info:
man cat
man grep
man wget
ohmeega
Posts: 2
Joined: Fri Jan 07, 2011 6:01 am

Post by ohmeega »

Can I add another webcam to a computer that already has an integrated webcam? I recently bought a Dell. I don't like the quality of the image that the integrated webcam has, therefore I would rather keep my old webcam. Will there be any interference if I install my old webcam?
______________________
external keyword tool ~ keyworddiscovery.com ~ keycompete.com ~ compete.com ~ webmasterworld.com
Post Reply