This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

LM object data as metadata on videocamera's stream
#1
Hi [Image: smile.png]

Please help me adapt script from other system to LM. In result we will see any object data on videostream (Works with Hikvision cameras). In simple words - if we open videocamera videostream on it we will see our data. I use Hikvision camera and now when I connect to it remotely using Hikvision videosoftware I see outside temperature and my heating device temperature. . etc..

How it works on my other system - at C:/ disk (win10) located 1.xml file. In 1.xml file also located coordinates in pixel where our data will be shown at videostream (from upper left corner - X and Y position of starting place for our text).. I insert values I need to show at my camera videostream to this 1.xml file. After that with curl.exe it sends to camera. This repeated every minute (Just cycle how often we want to update values at videostream..).

So, questions:
1. how put on LM SD card 1.xml file and later put data in 1.xml using script???
2. how execute curl command and use it with string in script above?



My script on other system:

$CONNSTRING = "http://camera_loginandpass@cameraIP/Video/inputs/channels/1/overlays/text/";
$value=getGlobal('Mainsity.Today_temp'); -- in our case we take LM's needed object's value and put it in 1.xml

file_put_contents('C:\1.xml', $xml);
exec('C:\curl.exe -T C:\1.xml '.$CONNSTRING.'1');
//$answer=exec('C:\curl.exe -T C:\1.xml '.$CONNSTRING.'1'); 
//echo $answer;


Alex
Reply
#2
Post XML file contents. There's no need to save file anywhere as you can send data directly from the script using LuaSocket. I'll post an example bit later.
Reply
#3
1.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<TextOverlay xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<id>1</id>
<enabled>true</enabled>
<posX>16</posX>
<posY>16</posY>
<message>$value</message>
</TextOverlay>
Reply
#4
Try this, change camera URL and text message as needed. Uncomment last line with logging if request does not work.
Code:
url = 'http://USER:PASS@IP/Video/inputs/channels/1/overlays/text/1'
text = 'Test message'

function http_put_xml(url, xml)
  local http = require('socket.http')
  local ltn12 = require('ltn12')
  local resp = {}

  local res, code = http.request({
    url = url,
    method = 'PUT',
    headers = {
      ['content-type'] = 'text/xml',
      ['content-length'] = #xml,
    },
    source = ltn12.source.string(xml),
    sink = ltn12.sink.table(resp),
  })

  if res then
    return table.concat(resp), code
  else
    return nil, code
  end
end

function xml_escape(text)
  return text
    :gsub('&', '&amp;')
    :gsub('<', '&lt;')
    :gsub('>', '&gt;')
    :gsub('"', '&quot;')
    :gsub("'", '&apos;')
end

xml = [[<?xml version="1.0" encoding="UTF-8"?>
<TextOverlay xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<id>1</id>
<enabled>true</enabled>
<posX>16</posX>
<posY>16</posY>
<message>]] .. xml_escape(text) .. [[</message>
</TextOverlay>]]

res, err = http_put_xml(url, xml)
-- log(res, err)
Reply
#5
[quote pid='11307' dateline='1545918376']
Admin, 
BIG THANKS Smile 
All works. 

Result seen in attachment..



[/quote]


Attached Files Image(s)
   
Reply
#6
Hi,
I have a ip cameras with an stream MJPEG. The url to acces to cam is: http://user:pwd@Ip_Adress/Streaming/channels/102/httpPreview
If I open de url in the web browser it's opening without problem, but if I configure a camera button in a visualitzation of LM, the camera not open.
WHY?
Can you help me?
Reply
#7
Hi
Yo need direct url stream, try to find it here https://www.ispyconnect.com/sources.aspx
BR
Reply
#8
You need to disable username/password or pass them as URL parameters (if camera supports it). This is a security limitation in most modern browsers, there's nothing we can do from our side.
Reply
#9
Hi.
I have a direct url stream, and in the url i put the user and pwd.
I open the camera button and appear this:

[Image: camera-error.jpg]
but if I click in broken image with de right button and choose copy image url (Copiar dirección de la imagen) i can view the ip camera in a window of chrome.
[Image: camera-error2.jpg]
Reply
#10
For me it works in Mozilla not in Chrome. Test with Firefox.
As mentioned ONLY new Hik cameras allow disable user autentification. My cam is old enough and not allow do such things.
Also try to find newest firmware for Hik cam here:
http://www.hikvisioneurope.com/portal/?d...Front-ends

(Please note Hik divide cameras by platforms, so check which is yours, or just write to me in PM)
Alex
Reply
#11
(16.01.2019, 19:09)AlexLV Wrote: For me it works in Mozilla not in Chrome. Test with Firefox.
As mentioned ONLY new Hik cameras allow disable user autentification. My cam is old enough and not allow do such things.
Also try to find newest firmware for Hik cam here:
http://www.hikvisioneurope.com/portal/?d...Front-ends

(Please note Hik divide cameras by platforms, so check which is yours, or just write to me in PM)
Alex

Thanks AlexLV! With Firefox it works!
Thanks
Reply


Forum Jump: