Nov 3 2003

Big Brother watching over Little Sister

Wireless CameraWhat are a wireless network camera, perl, TiVo and our daughter doing together? A geeks attempt to combine his favourite two subjects: technology and the newborn daughter.

Long before our baby was born (see Welcome to the world, Pia!) I was thinking about ways I could combine my geekiness with the arrival of the new child. I needed a “project”! It had to be fun and useful at the same time and should involve one or the other gadget. Soon I decided to install a network camera in the baby’s room for a number of reasons:

  • I could use the camera to monitor the baby from my laptop while I’m in the office
  • We could check on the baby using the Home Media Option on the TiVo units (which essentially means that the baby appears on TV)
  • Friends and Family (especially those overseas) would be able to check what’s going on with the baby whenever they wanted to.

That does sound like fun and useful at the same time – doesn’t it?

First I needed to decide on a network camera. As the baby’s room does not have a CAT-5 connection I needed a wireless camera solution. I first looked at the Linksys WVC11B (see Linksys WVC11B) and liked the very attractive price of the unit. As it is a brand-new device there were not a lot of experience reports out there on the web. I ordered it from Dell a few months ago.
Too bad that the unit was either not even shipping yet (contrary to the reports on the Linksys web site) or Dell had stocking problem. I received several notices that the unit would be delayed and (SHOCK!) would not arrive on time for the little baby. So I cancelled my order and ordered the next (slightly pricier) solution, the D-Link DCS-1000W (see D-Link DCS-1000W).
Soon after ordering the unit it arrived and it really only took 20-30 mins to unpack the device, hook it up to the switch, upgrade the firmware and configure it. Once configured I moved the camera to the baby’s room and checked the wireless connection. Everything worked without a problem:

Side note about Image Quality: In some of the reviews about this camera I read about image quality issues. I was not entirely sure what to expect from the camera, but now that I’ve used it for about 2 weeks, I’m beginning to see the same issues mentioned in other reviews. The color resolution of the device is very, very poor. I can see fringing between darker and lighter areas and I can also see a lot of compression artefacts in uniform colored areas even at the lowest compression level. I don’t really need a real-time 15 frames/sec video stream, but about 1 high-quality frame every few seconds. I either have not found the correct settings yet or the camera actually is not be able to perform the way I expected it to perform. I’m talking to D-Link tech support (Case ID: PTS9040266) at the moment to figure out whether there’s anything else I can tweak.

Update 11/10/2003: I received another one of those DCS-1000W cameras this weekend from pcnation.com. The other one is on it’s way back to the warehouse. I went through the same installation procedure as for the first one and got the impression that the quality was a tad better. However after looking at a few days worth of captures, I can see the same problems as before. To add to the disappointing results I now also see frames that look like they were shot through a red-filter. I sent another note to dlink-tech support and hope to receive a response soon.

Update 11/11/2003: I contacted D-Link tech support again and told them that I was still having problems with my camera. I created a page which showed a frame which was shot at 3:30pm yesterday by the camera, compared to the frame shot by a digital camera at the same time. The response:

Date of Reply: 11/11/2003 8:17:45 AM

Products: DCS-1000W
Operating System: Windows XP Pro

The artifacts are still abnormal. The image in general also appears to be poorer than normal. I believe you may be purchasing from a bad batch of cameras. I recommend contacting a different vendor.

Please visit this URL to view a DCS-1000W that is currently working at D-Link:

http://www.dlink.com/products/livedemo/

and also

http://[censored] User name is “[censored]” leave the password blank.

Thank you for networking with D-Link.

Sincerely,
[censored]

D-Link Technical Support

I looked at the two live-cameras mentioned above, but it is very hard to compare my images to the demo-images (the resolution on the demos is a lot lower). This basically means that I am without luck. I can certainly return the camera, pay a hefty restocking fee and try another vendor.

However I lost faith in D-Link’s DCS-1000W. I’m going to return this camera and will use another camera model instead of the DCS-1000W. Sorry D-Link … and how come the vendor has a batch of bad cameras in the first place? And how come you’re not interested in the serial numbers? Or the vendor’s name? Or any other information that would allow you to track down the batch of bad cameras? Makes you wonder – doesn’t it?

Using the camera’s control panel I setup the unit to store a frame on my Unix server once a minute:

D-Link DCS-1000W FTP upload

Good – now I get a 640×480 JPG image (roughly 40KB) every minute on my Unix server. It would be very easy to just make this frame available somewhere on www.kahunaburger.com, but I’m not happy with it. Most certainly it’ll be useless for my parents in Germany to look at the page during “their” day time when it’s dark here and everybody’s asleep. I have to find another solution.

First I thought about saving simply every frame for a 24-hour period on the disk and provide a way how you can view/navigate all those images. Considering that the camera does not work in the dark, you still end up with about 720 images (12 hrs * 60 mins * 1 frame/min) for a day which is a hell of a lot to go through if you want to find the few frames that actually contain some “action”.

And then I started implementing the final solution: motion detection. Here’s what’s happening right now:

  • every minute the wireless camera drops an image into a fixed location on the Unix server
  • every minute a perl-script is executed on the Unix server, which performs the following steps:
    • compare the last frame from the camera with the latest frame handled by the script; if no difference is detected then the script exits
    • move the image called “latest” to an image called “last”
    • copy the current camera image to a file called “latest”
    • check the contents of the “latest” file if it appears to be “dark”; if this is the case then the script exits
    • compare the contents of the file “latest” with the file called “last”; if no significant differences are detected, then the script exits
    • create a thumbnail for the file “latest” and add the whole image plus the thumbnail to a set of “interesting points in time”
    • regenerate a web page which contains the current camera image plus the “interesting points in time” images

The more difficult part in this script was the “compare ‘latest’ to ‘last'” step. I needed to find a way how I could determine that changes in the image were “significant” and not only slight brightness changes. Here are two sample frames from the camera, which show a “significant change” (and by the way also show the poor image quality I mentioned before):

frame 118

frame 119

In order to do that I convert the frames to “gray” images only (merging the RGB information) and scale them down to 160×120 (this is mainly for peformance reasons). Those steps are performed with the (excellent) Imager perl module (see Imager.pm module on CPAN.org). And the same two frames now look like this:

gray frame 118 gray frame 119

Next the two images are passed into this routine:

sub diffImages {
    my($older,$newer,$darkness,$difference)=@_;
    my($white)=$older->getwidth()*$older->getheight()*255;
    my($d2,$s2)=("",0);
    $newer->write(data=>\$d2,type=>'raw');
    # check darkness of frame
    map { $s2+=ord($_) } split(//,$d2);
    # do we have a dark frame?
    if($s2/$white <= $darkness) {
        return 0;
    }
    my($d1,$s1)=("",0);
    $older->write(data=>\$d1,type=>'raw');
    my($i)=0;
    map {
        my $x=abs(ord($_)-vec($d2,$i++,8));
        $s1+=($x*$x) if($x>=GRAYNOISE);
    } split(//,$d1);
    my $d=$s1/$white;
    if($d < $difference) {
        return 0;
    }
    return 1;
}

This code-fragment also shows why I chose Imager.pm over other solutions: Imager allows me to get to the "raw" image data and perform operations on this data. Both map {} sequences are performed so much faster than using a getpixel() like loop over all the image data. The first "if" checks whether the sum of all gray-values of the newer image is above a certain "darkness" threshold (which has been computed by looking at sample frames). If the image is too dark then we know that we don't want to add it to our collection.

In the second step we compute the absolute difference between the gray values of the "newer" and "older" images. If this value is above a certain "noise" value (GRAYNOISE, which is currently set to 40), then the square of the difference is added to our difference counter. Tests have shown that on a windy, cloudy day where the brightness in the room changes often, this GRAYNOISE value allows me to weed out just brightness changes which would normally be detected as "interesting frames". The squaring of the difference makes huge gray value changes a lot more "important".

Another interesting side effect of this setup is that we can use our TVs as baby monitors (no sound - yet!). I share the directory where the "latest" files are stored through TiVo's Home Media Option and set the TiVo Unit to run a slideshow where it rereads the same image(s) over and over again. Here are two samples from just a few minutes ago (sorry, the baby is still sleeping in the other room). Sorry about the bad quality, I did not have my tripod with me:

Pia's crib on TV

Pia's crib on TV

All together I probably spent two days to setup hardware, configure things and write the software mentioned above.

Now I need a new project - perhaps I try to mount the camera with a battery on one of the dogs while we take a walk? That sounds like fun. Useful? Who cares!!!

4 Responses to “Big Brother watching over Little Sister”

  • Nobby Says:

    Hello. Sorry to trouble you I can’t find any way to get help from the veo people. I have an observer and a young baby and was hoping to set it up like you have but I can’t see the picture on my web browser (IE7) it states “about:ActiveX%20can%20not%20be%20initialized!” and I can’t seem to get round it. I may also have the problem that at work the firewall blocks port 1600 so I’m trying to find a solution for that as well…any suggestions would be most gratefully recieved….thanks

  • nobody Says:

    i have got same problem orite ip cam ic-301 about:ActiveX%20can%20not%20be%20initialized! i disabled all activex settings but i have got same problem.

  • Roseline Brenneis Says:

    Heah, what a nice blog you have. I found it on Google while looking for some newborn baby items. Thanks and God bless.

  • Tobias Says:

    No, Roseline, you did not find it via Google and you only sent you spam bot here to post a comment that’s supposed to link back to your site (which I obviously removed from your comment). You “read” the page in less than a second and one second later posted the comment above. You are not only a fast reader, you are also an incredibly fast writer. The site you tried to advertise here was just added to a number of spam catchers and I’d be surprised if you have much more luck posting spam comments 🙂

Leave a Reply