Axis IP cams with VAPIX protocol
Axis is a Swedish brand, one of the world leaders in the video surveillance IP cams market, which has an extensive catalog of camera models that cover virtually any need. All its products have a common access protocol via http, the VAPIX protocol, based on CGI commands, which makes it especially interesting to know.
The VAPIX protocol is quite extensive, so I cannot cover it entirely in this blog. In any case, all necessary documentation is available in the developers support center on the Axis website, as well as free basic software to start using their products from the beginning.
In this article I will make a review of the basic operation of these cameras, its configuration and the use of commands to manage them from an application. As an example, I will use a Visual Studio 2013 project, written in CSharp language. In this link you can download the IPCameraDemo project source code, along with the executable program.
This program works with cameras that have implemented the version 3 of VAPIX HTTP API, which is the current version at this time.
Camera parameters
The Axis cameras have a lot of parameters with which you can configure the network, enable or disable camera functions, video formats, etc. They are managed by param.cgi and are organized in a tree structure divided into several groups and subgroups.
I cannot make an exhaustive review of all of them, but they can be explored and modified using the program that accompanies this article, using the manufacturer's documentation as a reference guide. To begin, select the Axis camera and press the Play button (the loading of the parameters takes a few seconds, be patient):
The parameters tree appear in a modeless dialog box, so you can modify their values and check the result immediately, with the camera image displayed in the main window.
If the selected parameter is not read-only, at the bottom appear the appropriate controls to change its value, by pressing the Save button.
The command to list all the parameters is as follows (as the commands are long, I omit the http://<server> part of them):
/axis-cgi/param.cgi?action=list
If you want to load only a tree branch or a single parameter (by example, Properties.Image.Format), add it in this way:
/axis-cgi/param.cgi?action=list&group=Properties.Image.Format
This returns a series of lines with the names of the parameters and their value separated by the = character.
You can also get a complete description of the parameters, their type and their allowed values in XML format using the following command:
/axis-cgi/param.cgi?action=listdefinitions&listformat=xmlschema
And to change the value of a parameter, the command is as follows:
/axis-cgi/param.cgi?action=update&PTZ.ImageSource.I0.PTZEnabled=yes
Depending on the camera features, not all parameters take effect. You can find interesting parameters in the ImageSource.Sensor group, to control the color, contrast and brightness, for example, and in the Image.I0.Appearance group to change resolution or rotate the image.
Controlling the camera with PTZ commands
Although the VAPIX API is more extensive, in this article I will comment only the parameter management and the PTZ control commands, which stands for Pan (horizontal movement), Tilt (vertical movement) and Zoom.
Before using the PTZ commands, make sure that they are active and unlocked, using the following parameters:
/axis-cgi/param.cgi?action=update&PTZ.ImageSource.I0.PTZEnabled=yes
&PTZ.Various.V1.Locked=false
Once this is done, you can get the available commands by means of the ptz.cgi CGI, using the info command as follows. The number of available commands depends on the camera model:
/axis-cgi/com/ptz.cgi?info=1
In the program you can use the PTZ tab to parameterize the commands and execute them:
In the manufacturer's documentation you will find a description of each of these commands and their parameters. It is not necessary to have a motorized camera to use the motion commands, as fixed cameras can also move the center of the image, provided that the corresponding commands are available.
By example, to zoom in the image, use the following command:
/axis-cgi/com/ptz.cgi?zoom=1000
Or this other to zoom relatively from the current value:
/axis-cgi/com/ptz.cgi?rzoom=100
Capturing images from the camera
We can get images from the camera in Bitmap or JPEG format, or a MJPEG video stream. The available formats can be obtained reading the Properties.Image.Format parameter.
To download a snapshot in bmp format, use:
/axis-cgi/bitmap/image.bmp
And for the jpg format, use the following CGI command:
/axis-cgi/jpg/image.cgi
And that's all; you can experiment by using the program, or modify it to add new features, because, as I say, the VAPIX API offers many more possibilities, such as user management and permissions, network configuration, movement detection, or remote access to the cameras.