Text Overlay from Arduino Serial....?

Forum for questions and support relating to the 1.28.x releases only.
Locked
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

Text Overlay from Arduino Serial....?

Post 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!
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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.
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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.
Nerre
Posts: 100
Joined: Thu Sep 25, 2014 10:22 am

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

Post 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.
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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.
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

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

Post 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.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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!
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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 12628 times
Attachments
config.jpg
config.jpg (38.7 KiB) Viewed 12628 times
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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 12620 times
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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!
rockedge
Posts: 1199
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

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

Post 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.
vbmike
Posts: 7
Joined: Mon Nov 09, 2015 7:50 pm

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

Post 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
Locked