View unanswered posts | View active topics It is currently Wed May 22, 2013 6:12 pm



Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Print temperature on Images? 
Author Message

Joined: Tue May 01, 2007 5:19 pm
Posts: 31
Post Print temperature on Images?
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/viewtopic.php?t=13850&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


Fri Jun 26, 2009 7:50 pm
Profile

Joined: Wed Jan 30, 2008 6:53 pm
Posts: 519
Location: St. Louis, MO, USA
Post 
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.


Fri Jun 26, 2009 8:07 pm
Profile

Joined: Tue May 01, 2007 5:19 pm
Posts: 31
Post 
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`


Fri Jun 26, 2009 11:02 pm
Profile

Joined: Mon Dec 15, 2008 1:10 am
Posts: 13
Post 
I 'd interested in the same thing. Would be cool to put some weather etc data on images.


Fri Jun 26, 2009 11:53 pm
Profile
User avatar

Joined: Sun Aug 17, 2008 6:34 am
Posts: 219
Location: Rosario - Argentina
Post 
Has anyone read the perfect description of zmtrigger?

At http://www.zoneminder.com/wiki/index.ph ... Components you can read:

Quote:
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

Quote:
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.


Sat Jun 27, 2009 5:56 am
Profile

Joined: Tue May 01, 2007 5:19 pm
Posts: 31
Post 
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!


Sat Jun 27, 2009 1:08 pm
Profile
User avatar

Joined: Sun Aug 17, 2008 6:34 am
Posts: 219
Location: Rosario - Argentina
Post 
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:
 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:
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:
$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:
http://myserver/zm/myscript.php?extTrigger=<id>|<action>|<score>|<cause>|<text>|<showtex>


in your case

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



Reply the results


Last edited by Normando on Wed Aug 12, 2009 11:49 pm, edited 1 time in total.



Sat Jun 27, 2009 4:50 pm
Profile

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


Sun Jun 28, 2009 1:01 am
Profile
User avatar

Joined: Sun Aug 17, 2008 6:34 am
Posts: 219
Location: Rosario - Argentina
Post 
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


Sun Jun 28, 2009 7:54 am
Profile
User avatar

Joined: Fri Mar 05, 2004 5:47 pm
Posts: 5218
Location: /USA/Washington/Seattle
Post 
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.


Tue Jul 07, 2009 8:34 am
Profile WWW
User avatar

Joined: Sun Aug 17, 2008 6:34 am
Posts: 219
Location: Rosario - Argentina
Post 
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


Tue Jul 07, 2009 4:01 pm
Profile

Joined: Tue May 01, 2007 5:19 pm
Posts: 31
Post 
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:
telnet localhost 6802
1|show||||test


For this purpose, I created this script:
Code:
#!/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)


Tue Jul 07, 2009 5:17 pm
Profile
User avatar

Joined: Fri Mar 05, 2004 5:47 pm
Posts: 5218
Location: /USA/Washington/Seattle
Post 
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.


Tue Jul 07, 2009 7:21 pm
Profile WWW

Joined: Wed Apr 26, 2006 1:39 am
Posts: 227
Location: Boston USA
Post 
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


Wed Aug 12, 2009 9:34 pm
Profile

Joined: Wed Apr 26, 2006 1:39 am
Posts: 227
Location: Boston USA
Post 
I take it back.. My perl script is working... Not sure why the .php won't work though...

_________________
MRD


Wed Aug 12, 2009 9:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group