Shell Scripting a Camera Server
The Swedish company Axis Communications AB introduced a new concept several years ago, when it launched its line of camera servers. Perhaps recognizing that its line of network cameras (one of which is reviewed in LJ, September 2000) could not fill all the niches of old-style analog surveillance cameras, it also offered its control and digitizing electronics in a separate, rugged, fanless enclosure. Available in versions with one or four analog video inputs and one pass-through output, camera servers now have offered companies a way to modernize their surveillance systems incrementally for most of a decade.
Naturally, the appliances run Linux these days, on rather specialized hardware. We came into contact with this server because a client had needs that could not be met by Axis' own cameras, but its Web-browser-based interface was well liked by both us and the client. So we were quoted some pro-level third-party hardware from a traditional surveillance camera supplier that was tested to work well with the camera server.
Like computer hardware, cameras and their optics are money sinks. Depending on desired sophistication, it is possible to spend any given sum you might have available.
For our purposes, we needed a remote-controllable pan-tilt-zoom (PTZ) camera for outdoor use, with a respectable amount of magnification. You can find PTZ cameras for a few hundred dollars for basic indoor versions, and a few thousand dollars for variants tolerant of outdoor climate, direct sunlight and minor vandalism.
We went with a pendant-mount enclosed clear dome system at the time—the type you might see at modern airports. For outdoor winter use in Norway, we needed a heated enclosure to avoid ice build-up. Here are the specifications:
Pan movement: 360 degrees continuous.
Vertical tilt: +2 to -92 degrees.
Image sensor: 1/4 inch CCD (3.2 x 2.4mm).
Zoom: 22X optical, focal length 4 to 88mm.
Sensitivity: 0.07 lux at 1/1.5 s shutter speed.
Shutter speed: 1/1.5 to 1/30,000 s.
Minimum F-stop: f/1.6
Operating environment: -40 to +50 degrees Celsius, sustained.
Now, part of the idea in using a PTZ camera for this project was periodically imaging several fixed points and uploading these images to a Webserver. Here we encountered a problem. The stock software could do periodic imaging and FTP just fine. However, we had no way to tell it to go to a PTZ position before snapping the image. The functionality was not essential for our first customer, so delivery went ahead while we researched the issue.
The software in this appliance is open to modification in a few ways. Source code is available for all open-source components of the firmware image—so the administration interface CGI is missing, but the rest is mostly available for inspection and modification. The source code for a specific firmware release is not downloadable, though; you must request it in writing, from the Axis IPR Department. They will send you the source code on a CD for a nominal fee.
We had more customers in the pipeline, so research went ahead. That work eventually yielded several APIs that could be mined for functionality.
Here are the available APIs:
The normal admin interface (Web browser).
GCC SDK for Linux/cris.
As with most embedded devices, there are some restrictions and inconveniences. First and foremost, the severely limited space. Less than 100kb-writable filesystem space is available for third-party modifications, out of the 4MB Flash storage. All standard software is on a read-only filesystem, not replaceable without creating a custom firmware image.
No SSH server or client was available at the time, so custom shell scripts had to be triggered by timer or run from a PHP script. There was a telnet server available for development use, however. And nowadays, Dropbear SSH has been ported to the architecture.
We wanted to make do without an additional server just for automation, if we could, so our effort went toward some internal shell scripting, triggered at a set interval by the task scheduler utask. Incidentally, this task scheduler has some extra capabilities compared to a vanilla cron—it can react to external events, like a digital input low-high transition, or loss of video signal on camera #2.
- Encrypt Your Dog (Mutt and GPG)
- Practical Tiny Core in the Fire Service
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- DevOps for Dummies
- New Products
- Give new life to old phones and tablets with these tips!
- Open Axiom
- Returning Values from Bash Functions
- Is the Private Cloud a Real Cloud?
Free DevOps eBooks, Videos, and more!
Regardless of where you are in your DevOps process, Linux Journal can help!
We offer here the DEFINITIVE DevOps for Dummies, a mobile Application Development Primer, and advice & help from the expert sources like:
- Linux Journal