ONVIF and ZoneMinder

Enters ZoneMinder

I decided to use ZoneMinder as the native linux app to connect to my ip camera. Actually this is much more than an app. It is a complete suite of video surveillance programs. From my furtive glance at their site I got the impression that this system could just as easily control all the cameras in you average shopping mall as provide a static look-out at my coffee machine.

ONVIF specification

A further perusal of the ONVIF specifications showed that the complete interface consisted of Web Services. Seeing this I decided that it would be easier to generate proxies for these Web Services than adapt the existing onvifdm .NET code.

There are a number of auto-generators that make source code out of a Web Service Description Language (WSDL) file:

  • gsoap for C/C++
  • wsdl2perl for Perl

In order to decide which programing language to use I needed a deeper look at ZoneMinder.

Installing ZoneMinder

Thus I installed ZoneMinder from source. I will skip the details and focus on the important commands:

su
yum install mysql-devel libjpeg-devel perl-Sys-Syslog perl-ExtUtils-MakeMaker perl-Sys-Mmap
tar -xzf ZoneMinder-1.27.0.tar.gz
cd ZoneMinder-1.27.0
./bootstrap.sh
ZM_SSL_LIB=openssl ./configure --prefix=/usr/local/ --with-webdir=/srv/www/html/zm --with-cgidir=/srv/www/html/zm/cgi-bin --with-extralibs="-L/usr/lib64 -L/usr/lib64/mysql"
make
make install

For the rest of the installation I closely followed the ZoneMinder Wiki page for CentOS.

This gave me a running ZoneMinder installation which I tested in the browser.

ZoneMinder camera protocol

The camera interface in ZoneMinder (version >= 1.2.3) apparently is a bunch of perl classes that react to a number of predefined commands such as:

  • moveConUp
  • moveConDown
  • horizontalPatrol
  • … and many more.

Thus it should be possible to write a onvif.pm camera control module that forwards these commands to the ONVIF web services.

In addition ZoneMinder has a mysql database table with capability information for each camera model.

ONVIF Web Services

A small aside on the ONVIF web services again. These are grouped in families like “Security”, “Media” etc. As  a first sketch I thought I needed these service groups:

  • Capabilities – these provide a highly granular list of the device’s capabilities. The ideal use would be a utility that fills the ZoneMinder capability table with the information returned by this service.
  • Device Management – for setup
  • Media – for the video (or audio) feeds
  • PTZ – for pan/tilt/zoom

A new project

I then a started a new project zm-onvif to collect the resulting sources and executables.
In the folder wsdl/ I downloaded these files:

Next I downloaded required perl modules for Web Service consumption:

su
cpan App::cpanminus
cpanm --force SOAP::WSDL

This downloaded and built quite a number of needed Perl modules automatically. The “–force” parameter was necessary for SOAP::WSDL 2.00.10 and Perl version >= 5.16 . (See also this bug report.)

Then I set about generating proxies for the WSDLs

wsdl2perl.pl -p ONVIF::Device:: -b proxy http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl

and was rewarded with a set of Perl modules and an error message:

/usr/local/share/perl5/SOAP/WSDL/Generator/Template/XSD\complexType.tt NOT_IMPLEMENTED error - Attributes with atomic simpleType definition are not implemented yet at /usr/local/share/perl5/SOAP/WSDL/Base.pm line 62.

I imagined this meant some simpleTypes had not been generated properly. So I expected some manual tuning of the generated classes further on.

By now the directory structure of my new project had grown some:

proxy
proxy/ONVIF
proxy/ONVIF/Media
proxy/ONVIF/Media/Types
proxy/ONVIF/Device
proxy/ONVIF/Device/Types
proxy/ONVIF/PTZ
proxy/ONVIF/PTZ/Types
src
src/onvif-control.pm
wsdl
wsdl/media.wsdl
wsdl/devicemgmt.wsdl
wsdl/ptz.wsdl
Makefile

Once the new camera module is working I will post it here – or on the ZoneMinder site.

 

This post is part of The ONVIF series. See the other posts in the series here.

Tags: , , , ,

2 responses to “ONVIF and ZoneMinder”

  1. Markus says :

    Hi! Did you finally solve this build? Thank you!

  2. Jan M. Hochstein says :

    Hi, yes I did. This code has been merged into the zoneminder project some years ago.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: