Shell Scripting a Camera Server

Adding functionality to an embedded device doesn't have to be complex. How about some shell scripting?

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.

The Camera

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.

The Problem

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).

  • HTTP API.

  • Scripting.

  • Shell scripting.

  • PHP3 Lite.

  • 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.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix