Print temperature on Images?

Forum for questions and support relating to the 1.24.x releases only.
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Print temperature on Images?

Post by lukelukeluke »

With the timestamp setting, it seems you cannot print anything dynamically loaded from an external program to the Monitor image. Is there another way to do it?
I've read about zmtrigger.pl - that it could probably be done with it. But nobody seems to know about this according to my last post:
http://www.zoneminder.com/forums/viewto ... highlight=
Also, updating the MySQL timestamp entry seems to do nothing to the current image - the timestamp entry has to be cached somewhere...?
Thanks for any hints
coke
Posts: 518
Joined: Wed Jan 30, 2008 5:53 pm
Location: St. Louis, MO, USA

Post by coke »

I don't think timestamps are what you think they are, or at least they're not what I thought they were a couple of weeks ago in another application. A timestamp field is usually generated by the database for it's own purposes.
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

Well I know what a timestamp is.
But zoneminder calls the text string timestamp, which is printed on every image top left, which contains name of the Monitor and Date/Time. I'm looking for a way to add a dynamic value there, coming from an external program. For example:
`cat /opt/currtemp`
ludri
Posts: 13
Joined: Mon Dec 15, 2008 12:10 am

Post by ludri »

I 'd interested in the same thing. Would be cool to put some weather etc data on images.
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

Has anyone read the perfect description of zmtrigger?

At http://www.zoneminder.com/wiki/index.ph ... Components you can read:
zmtrigger.pl
This is an optional script that is a more generic solution to external triggering of alarms. It can handle external connections via either internet socket, unix socket or file/device interfaces. You can either use it ‘as is’ if you can interface with the existing format, or override connections and channels to customise it to your needs. The format of triggers used by zmtrigger.pl is as follows "<id>|<action>|<score>|<cause>|<text>|<showtext>" where

* 'id' is the id number or name of the ZM monitor
* 'action' is 'on', 'off', 'cancel' or ‘show’ where 'on' forces an alarm condition on, 'off' forces an alarm condition off and 'cancel' negates the previous 'on' or 'off'. The ‘show’ action merely updates some auxiliary text which can optionally be displayed in the images captured by the monitor. Ordinarily you would use 'on' and 'cancel', 'off' would tend to be used to suppress motion based events. Additionally 'on' and 'off' can take an additional time offset, e.g. on+20 which automatically 'cancel's the previous action after that number of seconds.
* 'score' is the score given to the alarm, usually to indicate it's importance. For 'on' triggers it should be non-zero, otherwise it should be zero.
* 'cause' is a 32 char max string indicating the reason for, or source of the alarm e.g. 'Relay 1 open'. This is saved in the ‘Cause’ field of the event. Ignored for 'off' or 'cancel' messages
* 'text' is a 256 char max additional info field, which is saved in the ‘Description’ field of an event. Ignored for 'off' or 'cancel' messages.
* '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.

Note that multiple messages can be sent at once and should be LF or CRLF delimited. This script is not necessarily intended to be a solution in itself, but is intended to be used as ‘glue’ to help ZoneMinder interface with other systems. It will almost certainly require some customisation before you can make any use of it. If all you want to do is generate alarms from external sources then using the ZoneMinder::SharedMem perl module is likely to be easier.
and

http://www.zoneminder.com/wiki/index.ph ... estamp_Tab
Timestamp Label Format
This relates to the timestamp that is applied to each frame. It is a ‘strftime’ style string with a few extra tokens. You can add %f to add the decimal hundredths of a second to the frame timestamp, so %H:%M:%S.%f will output time like 10:45:37.45. You can also use %N for the name of the monitor and %Q which will be filled by any of the ‘show text’ detailed in the zmtriggers.pl section.
So...it is very easy to add dinamically a text on the timestamp over the image. Interface with zmtrigger.pl your external program and send a series of "<id>|show||||<showtext>" to add your own text over the image. Of course, add the %Q token in your monitor timestamp settings.
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

Normando wrote:So...it is very easy to add dinamically a text on the timestamp over the image. Interface with zmtrigger.pl your external program and send a series of "<id>|show||||<showtext>" to add your own text over the image. Of course, add the %Q token in your monitor timestamp settings.
That's why I mentioned zmtrigger.pl. But can you also describe how to "interface with zmtrigger.pl"? I can't see another description of zmtrigger.pl than what you posted, I also mentioned this one in my old post.
Do I just start zmtrigger.pl on command line and enter "1|show||||temp: 24C"? At least this doesn't work... Where you got this syntax from anyway? Thanks a lot for further help!
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

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 ";
	exit();
    }else{
    //    echo "Connected ";
        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
Last edited by Normando on Wed Aug 12, 2009 10:49 pm, edited 1 time in total.
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

wow! Thanks Normando! Just did everything you wrote and it worked perefctly fine like that! An instruction like this should be added into the zmwiki or manual!
Btw.: It even works with Monitor-Mode (No motion detection).
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

lukelukeluke wrote:wow! Thanks Normando! Just did everything you wrote and it worked perefctly fine like that! An instruction like this should be added into the zmwiki or manual!
Btw.: It even works with Monitor-Mode (No motion detection).
Great :D
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Agreed, Thx Normando for a great example. Another feature that should be better defined in the Wiki LOL, At least this one is there. Let me know if you feel the inclination to work it, else I add something a bit down the road.
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

cordel wrote:Agreed, Thx Normando for a great example. Another feature that should be better defined in the Wiki LOL, At least this one is there. Let me know if you feel the inclination to work it, else I add something a bit down the road.
Thanks Cordel for your gratitude. Because my english is very little, I don't know If I undertand what you said about the work. Are you saying if I want to add this to the wiki? If yes, I reply yes, but I have no access to the wiki

Regards
Normando

Edit: upsss, sorry, I have access to the wiki. If you want I will post this ASAP
lukelukeluke
Posts: 31
Joined: Tue May 01, 2007 4:19 pm

Post by lukelukeluke »

Thanks for posting this to the Wiki Normando.
Maybe you can include my little hint for people who dont have PHP (or I can do it if you want me to).

You know you can also send the commands via telnet:

Code: Select all

telnet localhost 6802
1|show||||test
For this purpose, I created this script:

Code: Select all

#!/bin/sh
# ./script.sh | telnet
echo 'open localhost 6802'
sleep 1
echo $1
sleep 1
echo 'quit'
Create this script "script.sh" (executable) and enter this on the console:
./script.sh '1|show||||18' | telnet
to send a command.
Easy 8)
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Actually Normandos example is fine and more appropriate. It's better kept generic so that it applies to and is readable by more people. It's then up to those people to tailor it to their specific needs. Maybe add another section for different script languages. It should be just to aid in understanding how it works. If you get to specific then it tends to confuse some. It's about the API, not how to do a certain thing.

We will be going though the wiki fairly shortly and trying to make it all generic in the documentation, as distro and purpose directed stuff should be under more specific headings.
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

Ok.. I'm missing something here.

- I've edited zm_trigger.pl and commented out the other connection methods.
- I've selected ZM_OPT_TRIGGERS in options and restarted ZM
- I've added the %Q to my #4 monitor timestamp
- I've created a .php just like yours (Didn't give any errors or work)
- I've created a perl script to write to the socket and it also didn't work.
- The socket is open
- zm_trigger.pl is running
- I've tried just about all monitor states
- my URL and script syntax seem correct

http://<myserver>/zm/zm_trigger_temp.php?extTrigger=4|show||||123

root@system-z:~# ./trigger_sock.pl 4 123
4|show||||123

What am I missing?
MRD
mrd
Posts: 269
Joined: Wed Apr 26, 2006 12:39 am
Location: Boston USA

Post by mrd »

I take it back.. My perl script is working... Not sure why the .php won't work though...
MRD
Locked