Jump to content

Integrating FosCam Webcams into ISY and it's Web Server


MaddBomber83

Recommended Posts

Security Update

For the Camera Controls, please visit http://foscam.us/forum/showing-secure-m ... tml#p46871 for additional information.

The short version is that there is some simple PHP code you can run that makes controlling the camera more secure. It does require that you have your own web server though.

 

The below code reflects direct communication with your camera and exposes your IP/USER/PASS to anyone who can access your network. I'm ok with this for my external cameras, I'm not ok with this for any internal cameras.

 

Hello;

I've been working on integration of the FosCam H.264 series of Cameras into ISY. Essentially, I would like to completely control the camera from within the ISY. I have mostly accomplished this.

  • [*:ly02gd6g]Here is a screen shot of the interface:

Interface.jpg

 

A lot of the help and specifics came from the FosCam IP Camera CGI User Guide.

  • [*:ly02gd6g]It lists all the CGI commands and formats; which really are just URLs structured in a specific way to get the camera to do things.
    [*:ly02gd6g]You can add all, or the useful ones to ISY's Network Resources.
GET /cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=SkyScan&usr=USER_NAME&pwd=PASSWORD HTTP/1.1
Host: IP_Of_Camera:Port


[*:ly02gd6g]The above GET Request starts the Camera on a Cruise of the Sky (a custom cruise path defined by the user).

 

We can then use these network resources in ISY programing.

  • [*:ly02gd6g]The following ISY program commands the Camera to pan left.
    [*:ly02gd6g]1 second on my normal speed is enough to pan the camera half a frame.

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')
Then
       Resource 'ptzMoveLeft '
       Wait  1 second
       Resource 'ptzStopRun '
Else
  - No Actions - (To add one, press 'Action')

 

With all the functions for the camera in network resources / programs; we can now create an *.htm file and upload it to the ISY's built in web server.

  • [*:ly02gd6g]You can run all of ISY's programs by simply visiting a URL with the proper REST tag.
    [*:ly02gd6g]Here is what my HTML Table for the basic directions looks like:

>
</pre>
<table border="1">Up/LeftUpUp/RightLeftStopRightDown/LeftDownDown/Right</table>

-To get a list of all your programs (including their ID numbers) you can simply visit the following site:

http://isy/rest/programs?subfolders=true

- Please note, you can do more than just run programs. You can also control your nodes / devices.

Visit the ISY Developers API REST Interface wiki for all sorts of rest commands you can just throw into a URL.

 

 

When you open any of these URL's on a web page, you'll get a return of 200 if it was correct. As these are buttons, we don't really want to change the page. To get around this you'll see the target="control" in all those links. What I do is add an iFrame at the bottom of the web page where all these links open to. In the image you'll see it at the bottom clipped off a bit.


 

- The last part is getting the feed into the web page.

- I heavily used a post on the FosCam forums for doing this.

- My particular camera is a FI9831W and uses the H.264 CGI.

- If you use a MJPEG version (FI8xxx) there is another post here on doing the same thing.

- You can also get your CGI User Manual Here.

 

Essentially, you will use the following HTML code to get an image that refreshes itself every 1-2 seconds:


 

So, the web page is complete. We can now upload it to the ISY Web Server.

- Because it is now on the ISY, we can access it remotely in HTTPS (assuming you have your ports forwarded).

- We can also use this web page as the default ISY page. So when you log into the ISY you'll see your camera.

- I added a button to access the default ISY web page, so I can still get to all my nodes and such (as I have not added them to a custom UI yet).

UD Ajax

 

Snapshots and e-mails:

- This is where the weak spot in this setup comes into play.

- When ISY sends an HTML email with an IMG URL, it does not attach or reference the actual image. It just passes the link.

- The image is accessed for the first time when you open your email client. So you don't get an image of when the email was sent, but when it was opened (maybe a day later).

- The e-mail that ISY sends also has a bad habit of being cached.

 

To make sure it does not get cached we use the following Notification Body


You'll see we added a Variable there. As long as this is a different number then the last few images you sent, it won't be cached. As a result, this is what our notification program looks like:

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')
Then
       $Increment += 1
       Send Notification to 'Admin' content 'Images'
Else
  - No Actions - (To add one, press 'Action')

That Increment Variable is the same as the ${var.1.50} in the notification.

 

 

 

 

Now, using a *.php script on a web server, you can actually send yourself an attachment image that will be the same one as the time it was taken, no matter when you opened it. I used the following site as a guidefor creating mine.

 

In that FosCam forum post I linked earlier, you can use another *.php script to get access to secure images to email. You'll want to download the information and follow that thread if you are interested and have a web server. I uses Amazon's EC2 personally.

Link to comment

An example program is one that I've made for night checks. A screen shot of the major points of interest is sent to me in the following way:

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Resource 'VeryFast'
       Wait  5 seconds
       Resource 'Softener'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Back_Right'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Back_Center'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Back_Left'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Back_Patio'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Back_Door'
       Wait  5 seconds
       Resource 'Camera_Email'
       Wait  5 seconds
       Resource 'Normal'

Else
  - No Actions - (To add one, press 'Action')

 

My wife uses the web page part to set it up on scans for when the kids are in the back playing.

Link to comment

In the future we will be setting up trips on our gates. Motion sensors on our entrances and driveway.

 

With everything in ISY we can have the appropriate cameras point at the direction of the trip and snap a few pictures and email them to us.

Link to comment

Thank you for the information. I'll have to look at modifying a few of the php files and have the ISY call those instead.

 

A note about the cruise, we use it for when we are looking at the monitor. When we walk away it goes back to a single point.

 

Also, we will use a separate motion sensor to fire off alerts as it is still very difficult to feed a motion response into the ISY from a FosCam. One scenario I'm playing around with is having the FosCam email alert go to a server that triggers a php script.

 

Meh, bed time.

Link to comment

When my motion detectors trigger an alarm, I have the foscams patrol predefined routes and enable FTP uploading of images once per second, This seems to work quite well for me. Of course this is not using the "Alarm" function of the cam but it may be a useful work around for some.

 

-Xathros

Link to comment

A topic very near and dear to me, and thank you for the extensive write up on it.

 

Are any of the foscam's you are playing with full 1080P resolution? I've got some depth to my driveways, and the neighbors have had some issues, so I would like to have the higher resolution in case some real face recognition is needed to identify prowlers, vandals etc.

 

Alan

Link to comment

I know that maddbomber83 efforts for sure, will also help to have additional methods to access Foscam IP Cameras.

 

Just wanted to answer your question. To help you have the ability to better determine which Foscam IP Camera model might better fit your needs.

 

So I do apologize to maddbomber83, on the level of details provided here.

 

Don

 

No apology needed. As mentioned, most of this is from other people's work. I would appreciate any and all feedback / ways to improve. ISY forums are here for that!

Link to comment
  • 5 weeks later...

Guys thanks for the info. I just bought a Foscam FI9821W V2 and starting to upgrade my UI to control and stream it. It looks like I have here all the info I need.

 

Before I start it I have a doubt. Should I start it using the HTTP methods because it's easier and think about upgrade to PHP in the future, or it's better to go on PHP direction from the start?

Link to comment
...

Security Update

For the Camera Controls, please visit http://foscam.us/forum/showing-secure-m ... tml#p46871 for additional information.

The short version is that there is some simple PHP code you can run that makes controlling the camera more secure. It does require that you have your own web server though.

 

The above code reflects direct communication with your camera and exposes your IP/USER/PASS to anyone who can access your network. I'm ok with this for my external cameras, I'm not ok with this for any internal cameras.

Link to comment

Thanks guys for all the info...

 

The reason that I need to do it on my own UI, is that I already have it to control my Insteon and global cache devices.. I just want to upgrade it with another screen with the camera streaming...

 

I think I won't have problems with the controls, just with streaming... Gonna start my tests and see what happens..

Link to comment

Uber; that is some great information and thank you.

 

I have some travel coming up, but when I'm done I'll need to make some updates to the OP.

 

Another question for you:

  • [*:36qeexcu]The ISY communicates with the camera by using the CGI api provided by FosCam.
    [*:36qeexcu]
HTTP://IPcamera:PORT/cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=BackScan&usr=[uSR]&pwd=[PWD]
...
[*:36qeexcu]With a web server running your PHP script, we would instead interface with that PHP rather than the CGI. (and add the ISY's IP to the Authorized Usage List)
[*:36qeexcu]HTTPS://WEB_SERVER/SecureImageDisplayControl.php?cmd=ptzStartCruise&mapName=BackScan

 

- For users who can not use PHP; if we followed your advice on restricting the HTTP port to local network only, and understanding we are now at the mercy of the ISY security when in remote; is this still a secure method?

- While apparent now, I am no security expert. Having the Operator USR/PWD in the url like that rather than at least in the Authorization/Basic header feels like a security risk.

- My understanding is that the FosCam API currently does not allow use of that Authorization/Basic header.

 

Again, thank you in advance!

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...