Under Design

…hates to admit he might have a blog.

Getting still JPEGs from Hawking HNC-210 Internet Cameras

with one comment

Switching to an altogether super-nerdy topic today. I’ve got these network video cameras (Hawking Technology HNC210, pictured to the right). These web-cameras don’t plug into your computer; they run their own HTTP server and plug in to the network directly via RJ-45 port.

I won’t bore you with the nitty-gritty details of how to get them on your internal network, so you can access the delightfully old HTML-frames and java applet camera viewer interface. It delivers a few frames a second of live video, at 640 x 480 resolution.

Live video was nice, but not required for my purposes. I’d prefer to check on demand, quickly, and have a saveble JPEG if need be.

Since it takes more than a few seconds to login to the camera interface to get video (username, password, redirect, load java applet, play video stream). However, with a bit of searching, I discovered these video cameras have a blatant security hole; They’ll send anyone a JPEG still with a simple HTTP request – no password needed!

First up, I pillaged Michael A. Dickerson’s page, where he has a live camera feed, and some Ruby code. It works in a cludge, but it’s kind of using a poor choice of language – Ruby isn’t default installed everywhere.

I’d found this PERL code somewhere else, and with a bit of shuffling, I had it pushing a JPEG everytime it’s called. Renaming it as a .CGI, and placing it any web host’s cgi-bin (inside the firewall) let me pull up multiple live stills from multiple cameras at once, on one ‘master control’ screen.

Finally, with a bit of digging on eBay, I found cheap replacement lens for the camera, so that now they offer a wider angle of view. Before they only gave you a 56˚ view, my new lens offer 90˚ view.

In this code, you need to put in the IP address of your camera (in this code, it’s 192.168.168.141). In my firewall, I can assign any device a permanent IP address. Save the file as ‘cameraname.cgi’ and put it on the web server. Make sure it’s permissions are 777, then you can simply use the very basic HTML code to ‘insert’ a live still JPEG in any webpage. I have a jukebox computer that runs 24/7 that now also hosts the camera feeds, and can be accessed by anyone in the building for a quick peek at the front door anytime!

The Code

#!/usr/bin/perl
use IO::Socket;
#SET WHERE CAMERA IS
$sock = new IO::Socket::INET (PeerAddr => '192.168.168.141',
PeerPort => 4321,
Proto => 'tcp',
Timeout => 1);
select(undef, undef, undef, 0.5);
$sock->send("0110\n");
$sock->read($size, 2);
$sock->read($j1, 1);
$sock->read($j2, 1);
$j1=oct("0x".unpack("H*", $j1));
$j2=oct("0x".unpack("H*", $j2));
$size=oct("0x".unpack("H*", $size));
if ($size != 0) {
$sock->read($data, $size);
print "Content-type: image/jpeg\n\n";
print $data;
}

The HTML

<img src="/cgi-bin/cameraname.cgi" width="640" height="480" alt="">

The Results

Here’s two stills from cameras with the new wide angle lens. They look sharp, and offer a nice wide view. I wouldn’t rely on it to identify someone, but it certainly gives you a first look.

Care to Comment? Need help doing this with your Camera?

Written by underdesign

2010/02/27 at 4:20pm

Posted in DIY, Hacking

One Response

Subscribe to comments with RSS.

  1. [...] my case, I’m making it for my wired network camera, a Hawking HNC-210, which is generally always situated farther away from the power outlet. It comes with a fairly [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.