Interacting with an IP Camera

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Interacting with an IP Camera

Post by simon.schvartzman » Wed Dec 09, 2020 10:03 pm

Greetings, I wonder if someone has experience (and ideally a stack to share) interacting with one of those popular Interact / IP Cameras.

There are several, relatively cheap, so called IP Cameras (example https://www.vstarcam.com/support/) that are controlled by a propiatary APP and/or are able to upload the image stream to the cloud. In my case what I'd like to do is to control one of such cameras from a LC App and instead of getting the full image stream I'd like to grab an image snapshot as a response of a command issued by the LC APP.

Many of those cameras support a protocol called ONVIF and last year there was a post (with no answer) about it ...viewtopic.php?f=7&t=33030&p=182518&hilit=onvif#p182518

Any ideas/suggestions?

As always many thanks in advance...
Simon
________________________________________
To ";" or not to ";" that is the question

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Interacting with an IP Camera

Post by FourthWorld » Wed Dec 09, 2020 11:57 pm

What sort of control over the device are you looking for?

Are you looking to manage the device remotely (on/off, tilt, zoom, etc.), or to capture the stream?

I would imagine the control protocols would be accomplishable with reasonable effort, depending on how they handle security.

Capturing the stream is probably not something you want to take on, and certainly not in a scripting language. Stream codecs are complex, and often patent-encumbered with steep licensing fees. If you're after stream capture it may be best to consider LC in a supporting role integrating with an app dedicated to that purpose.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Interacting with an IP Camera

Post by matthiasr » Thu Dec 10, 2020 12:54 am

Simon,

without more information about how to communicate with the camera it is very difficult.

I am pretty sure you've already had a look at the examples at https://www.onvif.org/resources/.
I've used there the link to the VBS ONVIF Scripting tools at https://github.com/mrrekcuf/ONVIF-scripting-tools

and had a quick look at some of the scripts. It looks like it should be possible to do this with LC, but it seems to be hard work. A documented api would be much better.
But what i could see so far in the .vbs is that the request has to be done as POST and before posting your request to the camera you have to set the requestHeaders first. I would try to "convert" one of the smaller .vbs scripts for testing if i were you. For example the onvifQuery.vbs

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Interacting with an IP Camera

Post by simon.schvartzman » Thu Dec 10, 2020 3:00 pm

Hi team, many thanks for the replies.

@FourthWorld, as you expected I don't want to capture the whole stream, I just want to remotely be able to capture a snapshot of the image.

@matthiasr, your suggested approach makes sense to me but as you said it will be a hard work and I'm not sure is worth but I will probably will give it a try...

I'm considereing a much simpler approach, let me know what you think about (I don't have a camera available at the moment to run a quick and dirty test)...

Since the stream of these cameras can be reached through a standard URL I'm thinking about using LC's Browser Widget and then capture (and manipulate) the Browser output. Any downsides on such approach?

Best
Simon
________________________________________
To ";" or not to ";" that is the question

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Interacting with an IP Camera

Post by matthiasr » Thu Dec 10, 2020 3:05 pm

Since the stream of these cameras can be reached through a standard URL I'm thinking about using LC's Browser Widget and then capture (and manipulate) the Browser output. Any downsides on such approach?
If LC is able to capture the content of the browser widget (i am currently not sure if that is working), then this would really be the easiest and fastest way to get it working.

Give it a try and let us know. ;)

All the best.

Matthias

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Interacting with an IP Camera

Post by simon.schvartzman » Thu Dec 10, 2020 4:50 pm

Matthias as you suspected it doesn't work :evil:

I created a group with a button and the browser
Screen Shot 2020-12-10 at 12.48.44.png
and then took a snapshot of the group

Code: Select all

  export snapshot from group "Grupo" to file "screen.jpg" as JPEG
The file is created but is just a black screen with the button
screen.jpg
screen.jpg (4.34 KiB) Viewed 6568 times
Any better ideas?
Simon
________________________________________
To ";" or not to ";" that is the question

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Interacting with an IP Camera

Post by matthiasr » Thu Dec 10, 2020 4:55 pm

I am not sure if this is working, but you could call the macOS command line tool screencapture to capture the the stack/card.

Here's a little overview.
https://osxdaily.com/2011/08/11/take-sc ... -mac-os-x/

There are much more flags available. You can define the screenarea for example or the windowid and so on.

Regards,
Matthias

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Interacting with an IP Camera

Post by matthiasr » Thu Dec 10, 2020 5:02 pm

In an other forum thread someone wrote that export snapshot from rect would work for him. Post #2 at viewtopic.php?t=28384

I just tried it and it definitely works.

Code: Select all

export snapshot from rect (the rect of widget "browser") to file "~/desktop/File1.png" as PNG

So you can do it with LC without external tool.

Regards,
Matthias

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Interacting with an IP Camera

Post by simon.schvartzman » Thu Dec 10, 2020 6:24 pm

Indeed it works, great! Many thanks.

Regards
Simon
________________________________________
To ";" or not to ";" that is the question

Post Reply

Return to “Multimedia”