So I picked up a cheap tilt/pan, wireless IP camera (by Hootoo). If you’re not familiar, these just plug into the network (and then later can work wirelessly), and there is a built-in web server. From the browser interface, you can pan and tilt, and change settings, etc. For example:
The significance of an IP camera is that the video stream, controls, and still images are available via URL-like commands. For example, here are some things you can do:
This generates a snapshot using all the current camera settings
This is an MJPEG video stream that you might stream to a player that supports that video type.
This is an ASF video stream that you might stream to a player that supports that video type.
This is a tilt/pan camera – and this command tells it go to "position 1"
This is a tilt/pan camera – and this command tells it go to "position 2"
If you are using one of these Hootoo cameras, which are available everywhere – here is the API documentation (this took some time to find): http://www.drivehq.com/file/df.aspx/publish/bubbah/PublicFolder/IPCAMCGISDKV1.7.pdf
From the programming perspective:
My thinking was that I could add this to my little WPF status app. So while I’m in my office, I can see when someone pulls in the driveway, for example. Now, pulling snapshots and changing camera position were easy via this web API. Dealing with these streams has been a mess though. The MJPEG stream, I can’t seem to get anything working with. The ASF stream works in Windows Media Player, but still prompts me for credentials. Meanwhile, in WPF – the MediaElement doesn’t work with either. I spent some time researching, but ultimately didn’t find anything helpful.
So, for my purposes, I am ok with just doing periodic screen refreshes. So, I created a little ViewModel and update the image snapshot like twice per second, and bind an image to it. That should work! Well, it kind of does. The problem is that it takes the Image element some time to reload an image. This means that the picture "flickers" as it’s getting reloaded. My first thought was that the image control should have a "double-buffer" feature, but it doesn’t appear to. So, I hacked together a double-buffer to give me a better framerate.
Even that ended up not working well because sometimes I could get around 4fps while other times, I would "flip" between images ever 3 seconds, and the back image still wasn’t loaded yet. Put another way, I don’t to base this on a race-condition, and I couldn’t get any sort of reliable/flicker-free results from this approach.
So, I’ll continue to play around with this. The ultimate answer would just to be to use one of the streaming formats, because that’s a smooth 10-20fps ( I believe). So, I guess I need to figure out how to get that working with WPF. To be continued…