Controlling a Panasonic network camera with web requests

A couple years ago the University purchased a Panasonic network camera to use to put images online of the new Fites Center. The specific model was a WV-NS202A and was selected because it also had a web interface that you could use to control it. As with our other construction cameras I was asked to make sure an always updating image would be available online. With a little further investigation I actually found I could do a bit more with this camera that others might find useful as well.

The first thing of note is how you can get images off the camera. The default way the camera wants you to do this is by having the camera FTP the images somewhere but we don’t use FTP on our live servers so this was not going to work. To be able to view or control the camera you have to install an ActiveX plugin which also not really the best since not everyone uses Windows. So what I did was pull out Wireshark and take a look at what might be going back and forth between the plugin and the camera. What I found was that everything was just simple web requests. Once I knew that it was simple to replicate.

To get an image off the camera you need to make a call like this (obviously change the ip address, username and password to match your camera)

http://username:password@123.123.123.123/cgi-bin/camera?resolution=640

320 also works for the resolution. The movements are done with these urls

http://152.228.129.11/cgi-bin/directctrl?zoom=1

http://152.228.129.11/cgi-bin/camctrl?pan=1&tilt=0

Should have user/pass in it if needed like above. The numbers can be more then 1 but just moves more then if bigger. No clue on what the limits are for that. The movements break down like this

Up – tilt=1
Down – tilt = -1
Right – pan = 1
Left – pan = -1
Zoom in – zoom = 1
Zoom out – zoom = -1

Here is an example php script for making a move.

$url = “http://123.123.123.123/cgi-bin/camctrl?pan=1&tilt=0″;
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //Use basic authentication
curl_setopt($ch, CURLOPT_USERPWD, ‘username:password’); //Set u/p
curl_setopt($ch, CURLOPT_REFERER, ‘http://123.123.123.123/live/live_flame_ctrl.html’);

This would move the camera 1 to the right. It’s been a while since I did this but I believe the referrer was needed to make this actually work.

Once I had all this information I was able to make a simple interface that would trigger these calls to make the camera do whatever I wanted. Hopefully this research that I did will be helpful to someone else out there searching to do the same.