ZoneMinder CCTV Camera Monitoring Software

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

ZoneMinder is a set of applications intended for use in CCTV video camera security applications. It supports capture, analyse, recording and monitoring of any cameras you have attached to a Linux based machine. It also features a user-friendly Web interface which allows viewing, archival, review, and deletion of images and movies captured by the cameras.

ZoneMinder has a highly configuratble image analysis system permitting retention of specific events, while eliminating false positives. ZoneMinder supports both directly connected and network cameras and is built around the definition of a set of individual 'zones' of varying sensitivity and functionality for each camera.

This allows the elimination of regions which should be ignored or the definition of areas which will alarm if various thresholds are exceeded in conjunction with other zones. All management, control, and other functions are supported through the Web interface.

ZoneMinder is designed to run on kernels which support the Video For Linux (V4L) interface and has been tested with cameras attached to BTTV cards, various USB cameras and IP network cameras. It is designed to support as many cameras as you can attach to your computer without too much degradation of performance.

ZoneMinder Web Site

Fedora Information for package zoneminder

ZoneMinder Tutorial

ZoneMinder FAQ

 

Fedora Setup

  • Have packages for Apache and MySQL installed on the sytem.
  • Install the zoneminder RPM package on the system
  • Configure zoneminder

The packaged version of Zone Minder installs all binarys to /usr/lib/zm including the web pages. So don’t worry when you do not see any files installed to the root directory for your web server. The web pages for Apache are aliased by zm.conf in the apache/conf.d directory which vary depending on your distribution.

  • Make sure Apache and MySQL services are running
  • Edit the zoneminder.conf apache configuration file to allow web connections
 vi /etc/httpd/conf.d/zoneminder.conf
  • Build the MySQL database table for zoneminder
 mysql -p -u root mysql < /usr/share/zoneminder/db/zm_create.sql > mysqladmin -p -u root reload

locations and paths

The Fedora RPM creates /var/log/zoneminder, but the database scripts point logs to /tmp, rather than the new directory. (Stupid)

  • Click Options, Paths tab, and change
 ZM_PATH_LOGS = /var/log/zoneminder
  • Click Options, Debug tab, and change
 ZM_EXTRA_DEBUG_LOG = /var/log/zoneminder/zm_debug.log+

Find the php program files:

 cd /usr/share/zoneminder/www/

Find the jpg still captures:

 cd /var/lib/zoneminder/events

Available sounds:

 cd /usr/share/zoneminder/www/sounds

Others:

  • /etc/zm.conf : file is generated by 'configure'
  • /usr/share/zoneminder/www/zm_config.php : web configuration file

ffmpeg: converts jpg captured frames into mpeg video

NOTE: Unable to get ZM_STREAM_METHOD mpeg or mpeg export working due to flaw in RPM build and ffmpeg version. No solution is currently available. A work around is to run ffmpeg from the command shell to turn still JPEG images into MPEG video if you install ffmpeg per instructions below.

  • Install ffmpeg on Fedora.

Due to licensing the ffmpeg package is absent from Fedora. It can be added from Livna.

 wget http://rpm.livna.org/livna-release-8.rpm
 rpm -ih livna-release-8.rpm
 yum install ffmpeg
 yum install ffmpeg-devel

Which provides the following: ffmpeg-libs-0.4.9-0.41.20071011.lvn8, ffmpeg-0.4.9-0.41.20071011.lvn8, ffmpeg-devel-0.4.9-0.41.20071011.lvn8

  • Test ffmpeg
 ffmpeg -f image2 -i %03d-capture.jpg /tmp/movie.mpg
  • Configuration changes in zoneminder necessary
    • Goto the Options menu, click on the Images tab
    • Change the following options for Fedora:
      • ZM_PATH_MPEG_ENCODE: /usr/bin/mpeg_encode
      • ZM_PATH_FFMPEG: /usr/bin/ffmpeg

 

Monitor Functions

  • None – The monitor is currently disabled and no streams can be viewed or events generated.
  • Monitor – The monitor will only stream feeds but no image analysis is done and so no alarms or events will be generated,
  • Modect – or MOtion DEteCTtion. All captured images will be analysed and events generated where motion is detected.
  • Record – In this case continuous events of a fixed length are generated regardless of motion which is analogous to a convention time-lapse video recorder. No motion detection takes place in this mode.
  • Mocord – This is a hybrid of Modect and Record and results in both fixed length events being recorded and also any motion being highlighted within those events.
  • Nodect – or No DEteCTtion. This is a special mode designed to be used with external triggers. In Nodect no motion detection takes place but events are recorded if external triggers require it.

Zones

The default zone is Active and so will be red, Inclusive zones are orange, exclusive zones are purple, preclusive zones are blue and inactive zones are white.

  • Active - trigger on any event within selection
  • Inclusive - triggered only if another zone has an event also
  • Exclusive - triggered only if other zone not triggered
  • Preclusive -
  • Inactive - no alarms will be triggered

Blobs AlarmedPixels FilteredPixels

  • Alarmed Pixels - only a count of individual alarmed pixels should be used to determine the state of a image.
  • Filtered Pixels - the pixels should be filtered to remove isolated pixels before being counted.
  • Blobs - a more sophisticated analysis which is designed to aggregate alarmed pixels into continuous groups, or ‘blobs’.

Parameters

  • Min/Max Pixel Threshold -
  • Filter Width/Height - this filter removes any tiny or discontinuous pixels that don't form part of a discrete block.
  • Min/Max Alarmed Area - the minimum and maximum number of pixels that exceed this threshold that would cause an alarm.
  • Min/Max Filtered Area -
  • Min/Max Blob Area - only the Minimum is likely to be very useful.
  • Min/Max Blobs - the limits of the actual number of blobs detected.

 

Capture Width x Height

The Analog TV and Digital Video Resolution Guide explains how lines of TV resolution translates into pixels. The default setting for a camera on ZoneMinder is 320x240 pixels.

First, your capture card can limit the resolution you must use. The capabilities of the capture card may dictate that you set 320x240 for all your cameras connected to the capture card - if using an analog capture card.

For IP cameras the best match between camera and pixel resolution is if the number of lines equals with the height of the captured picture.

  • For resolutions above 352x240 NTSC the video will become interlaced.
  • For resolutions above 368x288 PAL the video will become interlaced.

When an image is interlaced, basically 2 passes are made on camera, one pass for odd lines, one for even, and these are spliced together to form one image. The interlaced frames are 1/60th of a second apart.

de-interlacing errors on 878A single chip cards

ZM_CAPTURES_PER_FRAME with interlacing, the default is 3, you can try 2 to solve interlacing problems. If you stick with 320x240 you will not have to worry about interlacing issues.

 

Quality

I recommend setting quality to '85'

85   ZM_JPEG_FILE_QUALITY 	Set the JPEG quality setting for the saved event files (1-100) (?) 	
85   ZM_JPEG_IMAGE_QUALITY 	Set the JPEG quality setting for the streamed 'live' images (1-100) (?)

Advanced

zoneminder is made up of 3 types of programming

  1. C++ compiled binaries
    1. /usr/bin/zm*
    2. /usr/libexec/zoneminder/cgi-bin/zms
    3. /usr/libexec/zoneminder/cgi-bin/nph-zms
  2. perl scripts
    1. /usr/bin/zm*.pl
  3. php scripts
    1. /usr/share/zoneminder/www/zm_*.php
zmu -d /dev/video0 -q                show device settings
zmu -m 8 -q                          show settings for monitor with id "8"
zmu -m 8 -s                          state for monitor 8, 0 = idle, 1 = prealarm, 2 = alarm, 3 = alert, 4 = tape

Inded of documented zmu commands: http://www.zoneminder.com/wiki/index.php/Zmu

zoneminder components including C++, Perl, and PHP

zmtrack.pl

This is a script that can execute custom events when it detects an alarm. Set the zmtrack.pl to watch a

perl zmtrack.pl -m 2
 zmtrack.pl -m id_camera

Event Filters

Run External Script When Alarm is Active

ZoneMinder includes a perl API which means you can create a script to interact with the ZM shared memory data and use it in your own scripts to react to ZM alarms or to trigger ZM to generate new alarms. Full details are in the README or by doing 'perdoc ZoneMinder', 'perldoc ZoneMinder::SharedMem' etc.

Follow this link to an example script that checks all monitors for alarms and when one occurs, prints a message to the screen. You can add in your own code to make this reaction a little more useful.