Page 1 of 1

Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 11:31 am
by vbmike
Hi- I'd like to take senor data coming in from serial on an Arduino and overlay that text data on the ZoneMinder video. Is that possible? Can you point me in the right direction?

Thanks!

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 12:36 pm
by rockedge
Hello! maybe using zmTrigger.pl you can insert your overlay without having to change or add to much code.
look here http://zoneminder.readthedocs.org/en/la ... nitor.html

search for :
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 %Qwhich will be filled by any of the ‘show text’ detailed in the zmtriggers.pl section.
I hope this sets some wheels in motion in your quest.

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 12:57 pm
by vbmike
Thanks for the reply! I thought about that and figured modifying the code would shut me out from ZM updates. I was hoping there was some means of interfacing it.

Thanks

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 1:44 pm
by rockedge
I am envisioning something like an aquarium that has a camera pointed at it streamed using zoneminder. The water temp needs to be cold and constant, cooled by a chiller. A Arduino temp sensor sends its signal via serial port or receives a signal? But the end effect is the water temp is in real time displayed on top of the video stream of the aquarium.
This is an interesting feature. Someway of overlaying text/image onto the video stream. Some code could be added perhaps that is separated from the main zoneminder code so updates won't overwrite the modifications. But this may also mean zms needs to be modified. Not sure. But this is worth looking into.

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 2:10 pm
by Nerre
Wouldn't using a ffmpeg source work?

I think ffmpeg can add a text overlay to a video source, and if I'm not wrong ZM can use ffmpeg to capture images (with with the ability to set options per monitor). I've never used ffmpeg source in ZM so I'm not sure if this is a possible way.

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 5:34 pm
by vbmike
rockedge wrote:I am envisioning something like an aquarium that has a camera pointed at it streamed using zoneminder. The water temp needs to be cold and constant, cooled by a chiller. A Arduino temp sensor sends its signal via serial port or receives a signal? But the end effect is the water temp is in real time displayed on top of the video stream of the aquarium.
This is an interesting feature. Someway of overlaying text/image onto the video stream. Some code could be added perhaps that is separated from the main zoneminder code so updates won't overwrite the modifications. But this may also mean zms needs to be modified. Not sure. But this is worth looking into.
Very perceptive, that's exactly what I'm doing. ;) This is for a reef aquarium... I'd like to view temps, pH, light levels, etc.

This would also be useful in a weather station, quad copters, and all kinds of monitoring situations.

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 5:37 pm
by vbmike
Nerre wrote:Wouldn't using a ffmpeg source work?

I think ffmpeg can add a text overlay to a video source, and if I'm not wrong ZM can use ffmpeg to capture images (with with the ability to set options per monitor). I've never used ffmpeg source in ZM so I'm not sure if this is a possible way.
The video sources are usb webcams. I'm not very familiar with video capture stuff, so I need to do some research on ffmpeg.

Thanks

Re: Text Overlay from Arduino Serial....?

Posted: Tue Nov 10, 2015 11:42 pm
by rockedge
I stream a tank here: http://farmillriver.rockedge.org/?page_id=504

We also would like to set up a sensor pack to stream real time water data.It is not anywhere near a salt water reef tank in complexity. It is all part of Trout in the Classroom Project run by Trout Unlimited Nutmeg Chapter. Small side project. I am experimenting with X10 and a CM19a USB Transceiver and triggering events and activating motors.

Re: Text Overlay from Arduino Serial....?

Posted: Wed Nov 11, 2015 1:21 am
by asker
Ah! Nice find rockedge. I did not notice timestamp supported the %Q token. Good idea to use it with zmtrigger.

rockedge wrote:Hello! maybe using zmTrigger.pl you can insert your overlay without having to change or add to much code.
look here http://zoneminder.readthedocs.org/en/la ... nitor.html

search for :
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 %Qwhich will be filled by any of the ‘show text’ detailed in the zmtriggers.pl section.
I hope this sets some wheels in motion in your quest.

Re: Text Overlay from Arduino Serial....?

Posted: Wed Nov 11, 2015 4:40 pm
by vbmike
rockedge wrote:I stream a tank here: http://farmillriver.rockedge.org/?page_id=504

We also would like to set up a sensor pack to stream real time water data.It is not anywhere near a salt water reef tank in complexity. It is all part of Trout in the Classroom Project run by Trout Unlimited Nutmeg Chapter. Small side project. I am experimenting with X10 and a CM19a USB Transceiver and triggering events and activating motors.
Very nice!! Did you use zmTrigger.pl to inject the text banner at the top? Any more insight?

Thanks!

Re: Text Overlay from Arduino Serial....?

Posted: Wed Nov 11, 2015 10:23 pm
by rockedge
Did you use zmTrigger.pl to inject the text banner at the top? Any more insight?
The text banner is created when a camera is configured. In the config look under config.jpg the Timestamp tab.

I did inject successfully text by using %Q in the time format and sending this string to zmTrigger.pl

format :

Code: Select all

<id>|<action>|<score>|<cause>|<text>|<showtext>

Code: Select all

1|on|255|test run|cam control|cam controller
<showtext > is what is displayed with the %Q token
‘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.
camcontrol.jpg
camcontrol.jpg (62.38 KiB) Viewed 12638 times

Re: Text Overlay from Arduino Serial....?

Posted: Thu Nov 12, 2015 12:56 am
by rockedge
using this PHP script I called monck-v.php is modified to accept a string like:

Code: Select all

http://localhost/zm/monck-v.php?extTrigger=1|show|255|display txt|cam-control|control text here
or to turn it off:

Code: Select all

http://localhost/zm/monck-v.php?extTrigger=1|off|0|display txt|cam-control|control text here

Code: Select all

<?php
////monck-v.php

   $extTrigger = $_REQUEST['extTrigger'];
   $cfgServer = "localhost";
   $cfgPort = 6802;
//   $crtlTrigger = explode("|",$extTrigger);

$conn_handle = fsockopen($cfgServer, $cfgPort);
 if(!$conn_handle) {
        echo "Connection failed ";
   exit();
    }else{
      //  echo "Connected <br>";
        fputs($conn_handle, $extTrigger);
    }  
fclose($conn_handle);   

?>
This is working good.
working_txt.jpg
working_txt.jpg (29.29 KiB) Viewed 12630 times

Re: Text Overlay from Arduino Serial....?

Posted: Thu Nov 12, 2015 1:48 pm
by vbmike
Wow!!! Thank you for the detailed write up! I think that should fit the bill. I will test it out when I can.

Thanks again!

Re: Text Overlay from Arduino Serial....?

Posted: Thu Nov 12, 2015 4:08 pm
by rockedge
Your welcome.
How does your sensor setup work? What components are you using? I am interested in building a system with real time streaming via ZoneMinder with real-time water temp,pH and oxygen saturation data collection and display. Maybe ammonia levels/detection as well. Always looking for a relatively inexpensive sensor array solution.

Re: Text Overlay from Arduino Serial....?

Posted: Thu Nov 12, 2015 6:32 pm
by vbmike
Right now it's nothing more than cheap Arduino and temp problem from eBay combined with some dirty code. Reading serial data on Windows seems pretty straightforward, but I haven't tried it with Linux yet.

There are several inexpensive (and expensive!) pH probes, ORP probes, float switches, etc etc etc that can be controlled by them. You can control pumps for wave cycles. You can also control LED drivers to create cool lighting schedules, lightning storms, passing clouds, moon cycles...

There are several home brew, Arduino based reef controllers that could be adapted to freshwater use. Here's very interesting one that includes a mobile app... http://www.reefcentral.com/forums/showt ... ?t=2332822