IP camera from eBay

I just bought this off of eBay:
http://cgi.ebay.com/New-WPA-Wireless-WiFi-IP-Internet-PTZ-Dual-Audio-Camera-/220561313027?cmd=ViewItem&pt=PCA_Video_Conferencing_Webcams&hash=item335a7a8d03

I have an arduino with an Ethernet shield creating it's own webserver. I need to control this camera with my own webserver (don't ask why...). How do I do this?

I've already figured out how to grab the image by doing this:
<img src="http://IP-ADDRESS:81/videostream.cgi\" />

Now I just need to control it. If not control it have preset places that it can pan and tilt to.

Thanks,
Elijah

What is the web control protocol? You should be able to determine that by looking at the source of the web pan/tilt page.

I think it's TCP. I'll send the source HTML if you want.

The html in a web pan/tilt web page should show the method of sending the control info to the cam. Usually put in some type of a "get" request associated with a pan/tilt button on the page.

Here's the source from the mobile version of the webserver the camera creates:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<link rel="stylesheet" href="style.css" type="text/css">
<body>
<script src="public.js"></script>
<script src="check_user.cgi"></script>
<script src="get_status.cgi"></script>
<script src="get_camera_params.cgi"></script>
<script language="Javascript">
if (alias=='') alias=str_anonymous;
alias=alias;
document.title=str_device+'('+alias+')';

function Click(){ window.event.returnValue=false;}

var g_ptzcmd=-1;
function OnPtzMouseDown()
{
      var url="decoder_control.cgi?command=2";
      g_ptzcmd =2;
      new Image().src = url;
}

function OnPtzMouseUp()
{
      var url="decoder_control.cgi?command=0";
      g_ptzcmd =0;
      new Image().src = url;
}

function OnPtzMouseLeft()
{
      var url="decoder_control.cgi?command=4";
      g_ptzcmd =4;
      new Image().src = url;
}

function OnPtzMouseRight()
{
      var url="decoder_control.cgi?command=6";
      g_ptzcmd =6;
      new Image().src = url;
}

function OnPtzMouseStop()
{
      if(g_ptzcmd != -1){
            g_ptzcmd++;
            var url="decoder_control.cgi?command=" + g_ptzcmd;
            g_ptzcmd = -1;
            new Image().src = url;
      }
}
function OnSwitchOff()
{
      var url="decoder_control.cgi?command=93";
      new Image().src = url;
}
function OnSwitchOn()
{
      var url="decoder_control.cgi?command=94";
      new Image().src = url;
}

function OnBtnRefresh()
{
      document.getElementById("imgDisplay").src = "snapshot.cgi?"+Math.round(Math.random()*10000);      
      window.status=" ";
}

function OnImgLoad()
{
      window.status=" ";
      setTimeout("OnBtnRefresh()",1000);
}

function OnImgError()
{
      setTimeout("OnBtnRefresh()",1000*5);
      return true;
}
</script>
      
<body>

<center>
<img src="" alt="snapshot" id="imgDisplay" name="imgDisplay" onload="OnImgLoad()"/>


<table>
  <tbody>
    <tr>
      <td/>
      <td><div align="center">
            <input id="btnrefresh" type="button" value="" onclick="OnBtnRefresh();"></div></td>
      <td/>
    </tr>

    <tr>
      <td></td>
      <td><div align="center">
            <input id="btnup" type="button" value="" onclick="OnPtzMouseUp()">
</div></td>
      <td></td>
    </tr>
    <tr>
      <td><input id="btnleft" type="button" value="" onclick="OnPtzMouseLeft()">

      <td><div align="center">
        <input id="btnstop" type="button" value="" onclick="OnPtzMouseStop()">
      </div></td>
      <td>
            <input id="btnright" type="button" value="" onclick="OnPtzMouseRight()">
      </tr>
    <tr>
      <td/>
      <td><div align="center">

            <input id="btndown" type="button" value="" onclick="OnPtzMouseDown()">
      </div></td>
      <td/>
    </tr>
    <tr>
            <td/>
        <td><div align="center">
              <input id="btnswitchon" type="button" value="" onclick="OnSwitchOn()">        
            <td/>

    </tr>
    <tr>
            <td/>
      <td><div align="center">
            <input id="btnswitchoff" type="button" value="" onclick="OnSwitchOff()"></div></td>
            <td/>
    </tr>
  </tbody>
</table>

</center>
</body>

<script language="Javascript">
      btnup.value = str_ptz_up2;
      btnleft.value=str_ptz_left2;
      btnstop.value=str_stop;
      btnright.value=str_ptz_right2;
      btndown.value=str_ptz_down2;
      btnrefresh.value=str_refresh;
      btnswitchon.value=str_switchoff;
      btnswitchoff.value=str_switchon;
      
      
      var obj =document.getElementById("imgDisplay");
      if(resolution==8){
            obj.width=320;
            obj.Height=240;
      }
      else if(resolution==32){
            obj.width=640;
            obj.Height=480;
      }      
      else{
            obj.width=160;
            obj.Height=120;
      }      
      
      OnBtnRefresh();
</script>
</body>
</html>

This has 7 buttons that say up, down, stop, ect. So when you press the up button the camera moves up until you press the stop button. I don't really like that way of controlling it but maybe someone can alter this code so I could control it better using presets.

Below are some urls that may control your cam just looking at the html. if these work, then different button setups probably can be made. I've got a page setup that will start a servo move when the button is clicked, and stop the move when the button is released. Not sure about your "stop" button command, but it could be -1, or the move command -1, or maybe something else. Tinker with the below and see if things move.

http://IP-ADDRESS:81/decoder_control.cgi?command=0 up  
http://IP-ADDRESS:81/decoder_control.cgi?command=2 down 
http://IP-ADDRESS:81/decoder_control.cgi?command=4 left
http://IP-ADDRESS:81/decoder_control.cgi?command=6 right

http://IP-ADDRESS:81/decoder_control.cgi?command=-1 stop?
http://IP-ADDRESS:81/decoder_control.cgi?command=1
http://IP-ADDRESS:81/decoder_control.cgi?command=3
http://IP-ADDRESS:81/decoder_control.cgi?command=5

http://IP-ADDRESS:81/decoder_control.cgi?command=93 on 
http://IP-ADDRESS:81/decoder_control.cgi?command=94 off

Ok thanks so much! Now how can the arduino send these commands? Like this?

client.print("command");

Thanks,
Elijah

Ok thanks so much! Now how can the arduino send these commands? Like this?

client.print("command");

You will probably need an ethernet shield or other network interface. The arduino would use client side code and send the commands via a "GET" request to the cam (assuming the suggested strings work). Which of the suggested url strings worked with the cam and which didn't?

Yep they all worked perfectly and te stop command is command 1. I already got the Ethernet shield.

Can you post some code on controlling the camera with these commands?

The below link has some basic code with a GET request. The client.println may be something like below, but you may need to experiment to see if an http// is needed in the string (I would think not).

Edit: after looking at all the example code below, the ip address and port of the cam would be put in the given code like below. One might modify the code to hold the ip and port in the get string itself, but try the below to see if it works.

byte server[] = { 64, 233, 187, 99 }; // Google

Client client(server, 80);

client.println("GET /decoder_control.cgi?command=93 HTTP/1.0");

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

So I don't really connect to the ip cam server at all? Just google?

So I don't really connect to the ip cam server at all? Just google?

I used the example given in the code to help you find where you put the cam IP and port in the code. You use the IP address and port your cam is using. ::slight_smile:

Oh ok...I understand.

One more question; do you have any idea why this code doesn't work?

Here's the code:
files.me.com/elijahwood/hm3zf6

I keep getting this error:

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:55: error: expected ',' or '...' before numeric constant

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:56: error: expected ',' or '...' before numeric constant

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:59: error: expected ',' or '...' before numeric constant

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:60: error: expected ',' or '...' before numeric constant

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:63: error: expected ',' or '...' before numeric constant

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:66: error: expected ',' or '...' before numeric constant

In function 'void setup()':
error: no matching function for call to 'TimeAlarmsClass::alarmRepeat(int, int, int, void (&)())'/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:54:
note: candidates are: AlarmID_t TimeAlarmsClass::alarmRepeat(time_t, void (*)())

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:55: note: AlarmID_t TimeAlarmsClass::alarmRepeat(int)

/Users/elijahwood/Documents/Arduino/libraries/TimeAlarms/TimeAlarms.h:56: note: AlarmID_t TimeAlarmsClass::alarmRepeat(timeDayOfWeek_t, int)

It also high lights this:
Alarm.alarmRepeat(7,0,0, FishTankLightOn); // 7:00am every day

Any ideas?

Thanks,
Elijah

Don't have a clue as the zip file has seven different chunks of code in it. I suggest starting with simple working code and add to that instead of debuging complex code that isn't working.

Well it started when I started implementing the time library alarms. I just basicly copied and pasted the example codes into my code.

Any ideas?

Any ideas?

Sure. Tell us which of the 7 sketches has the problem(s).

It should be in the main tab and the time tab.

I've looked at the sketches and some are over my head, but the webserver one is interesting. Does it in itself work ok? The yahoo email is interesting. I made a vbscript application that emails thru yahoo, but the vbscript handles the details. If you have a cell phone that does text messaging, you can send your phone a text message using email thru the cell phone SMS gateway. Pretty neat for security notifications and such.

Oh yah, the webserver part works perfectly...accually I'm running an older version of the code without the time library now and am controlling things in my house and feed my fish! Very neat!

With the email, I looked at some other forums to figure that out, that works perfect too. It just seems to be the implementation of the time library with alarms that's causing problems. Any ideas on why I can't compile?

Just as a side light to the button push cam pan/tilt that you might want to try, I've used the below setup for controlling servo movement with my ssc-32. The buttons send one command when depressed, and another command when released. These would be for left, up, stop, down, and right. The mouse cursor needs to be over the button for the action to be sent. You can depress the button, then move the cursor off the button, then release the button and the stop command will not be sent. I added your commands to show where they would fit.

Zoomkat's pan/tilt control 4/25/10



Depress the button to move,


release to stop.

 
<input type="button" value="<" 
onmousedown="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=4');" 
onmouseup="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1');"/> 

<input type="button" value="^" 
onmousedown="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=0');" 
onmouseup="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1');"/> 

<input type="button" value="S" 
onmousedown="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1');" 
onmouseup="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1);"/> 

<input type="button" value="V" 
onmousedown="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=2');" 
onmouseup="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1');"/> 

<input type="button" value=">" 
onmousedown="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=6');" 
onmouseup="location.href 
('http://IP-ADDRESS:81/decoder_control.cgi?command=1');"/> 



</body>
</HTML>