OBSCURA LUCIDA
A Homebrew Video Surveillance System
I have two apricot trees in my backyard, which occasionally yield a crop of truly amazing fruit. If you've never tasted a tree-ripened apricot, then you have no idea what you're missing. Those crunchy, tart things at the supermarket have nothing in common with the real thing. The fact that my trees only sporadically bear fruit makes them more delectable.
One summer, the trees were heavy with fruit. Tracy and I anxiously waited for the perfect day to pick them. And then suddenly, between Monday and Wednesday, they all disappeared. Wha-wha-what the hell?!
I knew that people had been picking apricots on the other side of the fence--thanks to the the alley that runs behind the yard--but in order to strip the tree, a person would have to jump the fence and enter my yard. That got me hoppin' mad, and it was then that I hatched a plan: why don't I dust off off my old PC, add a camera and some software, and presto: homebrew video surveillance. Then I could catch the apricot thief in action. And thus was ObscuraLucida conceived.
On paper, the whole thing looked straightforward:
- The apricot thief blithely strolls into the visual field of the well-positioned camera.
- The well-positioned camera slyly forwards damning video evidence to a PC of crap.
- Motion detection software on the PC of crap notes the activity and records damning video evidence on the local harddrive.
- The software also posts a few image frames to this website.
Implementation
As any engineer knows, the devil lies in the details. Obscura Lucida was fairly bedeviled with details. For example:
Camera Selection: The trees are outside, but computers, particularly antique desktop PCs, prefer to live inside. The shortest run from a power outlet inside of my garage to the external observation point is about 20 ft. This ruled out USB cameras (those extender cables are expensive, and it's not clear they'd even work over that distance). So the system had to use a weatherproofed, analog camera and a video tuner card.
PC of Crap: because the PC would reside in my detached garage, it needed to have network access via a wireless card. Similarly, the PC needed to run headless (without a monitor or keyboard), and yet still allow me to access the system if necessary. Linux would have been the obvious choice, but Linux didn't support my video tuner card so I went with Windows 2000 and cygwin. VNC provided network access to the Windows desktop.
Motion Detection Software: I didn't want to write this myself. I'm not lazy or nothing, but I did have a day job and family.
After pursuing this line of requirements analysis, here's the configuration I ended up with:
- PC of crap (300 MHz Dell desktop), had to buy a new case fan
- Video tuner card (Hauppauge WinTV PCI card)
- 802.11g network card (D-Link): The D-Link card has an external antenna on a cable, which is very handy because the reception in my garage ain't so great
Digi-Watcher Software: a nice, full-featured piece of software. Digi-Watcher supported motion-triggered video recording and posting image stills. It severely taxed the underpowered PC, however.
- Swann Color Outdoor Day/Night Camera: imagine a long, long video cable with a turd attached to one end. More on this later.
I slapped the whole thing together and tested it by monitoring KittyPerdido's food bowl, which attracted a steady stream of hungry and furry visitors. Surprisingly, the thing worked. I tinkered with ObscuraLucida off and on over several years, and eventually refined it to the point where I could plop down the PC anywhere near an electrical outlet, boot it up, position the camera, and get video recordings + web updates. To configure the motion detection sensitivity and mask, I remotely accessed ObscuraLucida via VNC.
As usual, the software proved to be more work than expected. The system complexity grew as I added more features. I have a bad memory and months would go by between modifications, so I drew myself a diagram to document the increasingly Rube-Goldbergish mess.
Digi-Watcher included functionality to automatically start upon login. However, Digi-Watcher also had a habit of dying without warning. To catch this condition, I wrote a bash script called Watch Watcher, which ran as a cronjob. Watch Watcher periodically checked that Digi-Watcher was still running, and restarted it if necessary.
Digi-Watcher was designed to FTP a few still images whenever it detected activity. I configured Digi-Watcher to FTP the images to robertyu.com, so I could view the results directly from WikiPerdido (see /Monitor). On the website side, I wrote a Python script to rotate and resize the images.
At one point, I moved my website to a fly-by-night ISP which supported access via OpenSSH but not FTP (Caleb's Courteous ISP--an excellent deal if you can get it). This precipitated a laughably complex solution whereby Digi-Watcher FTPd the images to an FTP server running on the same PC (proftpd, running under cygwin). Another (Python) script, executing periodically as a cronjob, checked for new images and scp'd them to my website.
A Hello World script periodically ran as a cronjob and deposited hearty messages into a log file, just to reassure me that cron was executing.
Results
I eventually installed the camera on a vantage point, overlooking one of the apricot trees. Because the field of view included the tree and its shadow, the motion detection software was very susceptible to false positives, and triggered whenever the wind moved the branches. These false positives accounted for 99% of the captured video.
The system also worked as intended, capturing exciting videos of the garbage truck and my neighbors' cars.
Here's a little gallery of the images I captured with ObscuraLucida.
Cats
Here's KittyPerdido.
Mr. Scruffy was a feral cat who boarded next door
Here's KittyPerdido leaping off the fence onto the roof:
Squirrels
Possum
Ne'er-do-wells
One day, the system captured a bunch of neighborhood miscreants assaulting the poor tree.
I never did catch the apricot thief at work, though I now know who it is (more on this later).
Epilogue
In retrospect, I can identify two particular weaknesses of the system. First, the false positives triggered by moving branches and shadows hampered the system's effectiveness. I completely overlooked the importance of having a controlled, static environment in terms of lighting and background.
The far more serious problem was the camera, manufactured by Swann (http://www.swannsecurity.com): Swann Color Outdoor Day/Night Camera N3960. I bought this camera at Fry's for $79, and at the time it looked perfect: water-resistent housing, color output, a ring of infra-red LEDs for nighttime surveillance. Unfortunately, the camera was complete crap. During the day, it conveyed a grainy image, neither color nor BW. At night, the LEDs were insufficient to illuminate anything further than 10 feet away. But the worst part was the contrast: an automatic gain control, built into the camera, invariably locked onto the wrong setting. Under perfect lighting conditions, in broad daylight, the scene would suddenly go completely dark (which also triggered the motion detector), or wash out completely. Once the camera had entered this state, it would not recover until the power had been cycled or the contrast changed drastically.
I eventually figured out that the original apricot thieves were racoons, which are adept at climbing trees, have voracious apetites, and can smell ripe apricots from a mile away.
I decommissioned ObscuraLucida in 2009, cannibalizing the PC to build an ubuntu-based development system for my latest project.

