Author Topic: Template for the Foscam FI8908W pan & tilt wifi camera  (Read 7891 times)

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Template for the Foscam FI8908W pan & tilt wifi camera
« on: August 14, 2010, 02:39:21 pm »
Hia,
i did create the template, with the ruby codes for the FI8908W camera.
It's recognized, pnp but the motion commands for pan and tilt are not working, besides the router keeps dieing and reloading.
Is there someone with more knowlegde on ruby that could give a help?
The original post is: http://forum.linuxmce.org/index.php?topic=9969.0, where is described what did happen.
TIA,
Paulo

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #1 on: October 07, 2010, 11:58:49 am »
Hi Paulo,
Can you share your pnp script for this camera. I want to try and make it work in LinuxMCE.

Looked at your script http://pastebin.com/LK160n8Z.

The authorisation should be sent within the querystring so we will need to rewrite the script slightly.
Barney
« Last Edit: October 07, 2010, 12:26:02 pm by b4rney »

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #2 on: October 07, 2010, 12:37:26 pm »
What shall i send to you? The ruby sniplets?

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #3 on: October 07, 2010, 01:12:29 pm »
Did you do a pnp script to autodetect the camera?
http://forum.linuxmce.org/index.php?topic=9969.msg72922#msg72922

I don't know if the original panasonic template works but I think we need to alter the GET string to include our user/pass.

I use my cameras under motion so I can use them as security triggers and record when movement is detected. I would like to get these cameras working so they pan and tilt from the camera screen.

I'm happy to see your ruby snippets if you want to pastebin them for me.
Barney

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #4 on: October 07, 2010, 06:51:13 pm »
Barney,
as i reinstalled the system from scratch 3 weeks ago, i only have the sniplets i created. The template is gone with the old installation :( .

Code: [Select]

### #84 get video frame
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}

fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);

s = "GET "+fix_path+" HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(16384, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end
if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
  fileName="/tmp/ip_camera_img"+device_.devid_.to_s
  imageFile=File.new(fileName+".jpg",'w')
  imageFile.print $1
  imageFile.close()
  system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
  size=File.stat(fileName+".png").size
  imageFile=File.new(fileName+".png",'r')
  img = imageFile.read(size);
  imageFile.close()
  data_set(img)
  format_set('png')
end

### #350 Process Incoming Data
conn_.Close()

### #200 Move Up
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=0&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end

### #201 Move Down
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=2&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end

### #202 Move Left
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=4&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end

### #203 Move Right
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=6&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end


Paulo

bongowongo

  • wants to work for LinuxMCE
  • **
  • Posts: 826
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #5 on: October 07, 2010, 08:44:42 pm »
Could you please change the wiki accordingly?
http://wiki.linuxmce.org/index.php/Foscam_FI8908W

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #6 on: October 07, 2010, 09:18:16 pm »
After the changes done by Barney, he or i will be glad to change the wiki.

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #7 on: October 08, 2010, 01:08:54 am »
Thanks Paulo,

I will look at this tomorrow.

Did you use a mac address range to make them plug and play?

Barney

pw44

  • Addicted
  • *
  • Posts: 666
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #8 on: October 08, 2010, 12:32:15 pm »
Barney,
Yes, did use mac address range. 00:12:7b:4d:22:79, which gives the range from 79378063993 to 79389786111.
Paulo

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #9 on: October 08, 2010, 02:00:13 pm »
Thanks Paulo,

 :)

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #10 on: October 09, 2010, 02:11:33 am »
OK. Got this working as a dce device (not under motion). ;D Anyone who's interested can try these settings. I copied the Panasonic IP Camera template and pw44's examples.

You have to set the path (/snapshot.cgi?) as well as the username and password in your cameras device data.

Next step is the plug and play mac addresses, trying to make it work under motion and updating the wiki.
Barney

Here are the commands for movement.
tilt up     = http://cameraip/decoder_control.cgi?command=0&onestep=1
tilt down = http://cameraip/decoder_control.cgi?command=2&onestep=1
pan left   = http://cameraip/decoder_control.cgi?command=4&onestep=1
pan right = http://cameraip/decoder_control.cgi?command=6&onestep=1

Below is one example for #202 move left. Just change the command number for the other directions.
#84 Get video frame
Code: [Select]
conn_.Reconnect()
auth_s="user="+device_.devdata_[114]+"&pwd="+device_.devdata_[115];
#auth_a=Array.new;
#auth_s.each{|c| auth_a.push(c)}

fix_path=device_.devdata_[2]+auth_s;
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);

s = "GET "+fix_path+" HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
#s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(16384, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end
if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
  fileName="/tmp/ip_camera_img"+device_.devid_.to_s
  imageFile=File.new(fileName+".jpg",'w')
  imageFile.print $1
  imageFile.close()
  system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
  size=File.stat(fileName+".png").size
  imageFile=File.new(fileName+".png",'r')
  img = imageFile.read(size);
  imageFile.close()
  data_set(img)
  format_set('png')
end

#202 move left
Code: [Select]
conn_.Reconnect()
auth_s="user="+device_.devdata_[114]+"&pwd="+device_.devdata_[115];
#auth_a=Array.new;
#auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=4&onestep=1&"+auth_s
s+= " HTTP/1.0\r\n Accept: */*\r\n"
#s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end
« Last Edit: October 09, 2010, 02:14:18 am by b4rney »

b4rney

  • Guru
  • ****
  • Posts: 454
    • View Profile
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #11 on: October 15, 2010, 05:02:13 pm »
Update.... and dilemma.

This camera is fully plug and play as a stand-alone pan/tilt camera using the completed script above in a new template.

Pros:
Plug and play (Just give it a sensible name)
Pan and Tilt work from on screen arrows
Cons:
No motion capture (security and video capture implementation)

Alternatively it can be installed under motion (my preferred option) by adding the mac range of both the wireless and wired adapters into the 'Generic Motion IP Camera' template:
Wireless
79373008896 to 79389786111 (DHCP).
Wired
414170742784 to 414171791359 (DHCP).

After the device has been detected and assigned a room just give it a sensible name and add the following to the path parameter in web admin:
http://<CAMERA_IP_ADDRESS>/videostream.cgi?user=XXXXX&pwd=XXXXX

Replace the ip address and the XXXXX with your settings

Pros:
Plug and Play (Just give it a sensible name)
Installed under motion for security monitoring/recording
Cons:
Path must be manually set as described above
No Pan/Tilt other than via its own web interface

Anyone got any suggestions on the best implementation. It would be nice to have both working but I can't get both 'motion' capture and pan/tilt working together.

I will integrate this post into the wiki.
Regards
Barney

brononius

  • Guru
  • ****
  • Posts: 454
  • Trying to keep it simple and centralized...
    • View Profile
    • OnIrIa - linuxMCE blog
Re: Template for the Foscam FI8908W pan & tilt wifi camera
« Reply #12 on: July 31, 2012, 03:22:17 pm »
OK. Got this working as a dce device (not under motion). ;D Anyone who's interested can try these settings. I copied the Panasonic IP Camera template and pw44's examples.

Hey,

I'm trying to get my camera's (IPCAM02) to work, and believe it should be the same way that you've done it here.
But i can't manage to copy the template, and update the commands (scripts).
Can you point me out where/how i can do this?

Version: linuxMCE 1404, running virtual on ESXi

Orbiters: ASUS eeePAD, Nexus 5, Huwai, web
Automation: EIB technology, KNX IP ROUTER 750
Phones: Cisco 7912-7940-7960
Camera's: Foscam POE