Part X) Install a video surveillance system on Ubuntu Linux
This is a fun project that sidetracked me while installing Ubuntu Linux.
The basics are that you can connect the output of many inexpensive surveillance cameras (through a modulator if you have multiple cameras) to the input of a (bttv) video recorder card on your Linux system. In other words, the output from the camera will be digitized by the card, and then your computer can do anything it wants with the digitized data.
ZoneMinder is a great (free) program for Linux that will then function as a complete security system, based on the v4l (video for Linux) modules available in Ubuntu Linux. By adding the module "motion", which will add motion detection to the recording capabilities of ZoneMinder, you will have a fully functioning security system based on video surveillance.
I will refer you to the ZoneMinder website at:
http://www.zoneminder.com
for details.
The very first step is, of course, to obtain cameras. I happen to use Greyfox, because they were wired into my house when it was built. They have a multiplexer that automatically sequences the images from the four cameras. There is also a multiplexer that puts all four camera inputs on a single page for a single output image.
This is the time tested method for CCTV systems, and the image that is output can be recorded onto any VCR, DVD, or hard-drive based PVR (personal video recorder). But ZoneMinder can also monitor and interact with cameras individually. It can make decisions (such as triggering an alarm) based on the images from any individual camera. If at all possible, then, it is desirable to have each camera output connected to your PC's PVR or video capture card directly, instead of through a multiplexer.
Ideally, you will have a video capture board (VCB) in your computer with 4 (or eight) different inputs, depending on the number of cameras. This is different than a TV or video board in that most TV and video boards only have one input. If you multiplex all your cameras into only one output, you can use a video or TV card, but I don't recommend it.
BNC connectors, yellow RCA connectors, and F-connectors (cable connectors) are all 75 ohm connectors. Don't stress if your card has a BNC connector and your camera has an RCA connectors -- you can connect them with the correct adapter. You can even use generic RG-6 cable with F-connectors (the one used by your cable company) to connect a distant camera and computer, by simply using the appropriate adapters on each end.
(Note, however, that I have not seen many security cameras that use S-connectors, and although many video capture and PVR cards have inputs for this, I am not familiar with using them.)
The next step is to find a Linux-compatible video capture board / video recorder card. The Linux bttv drivers are known to work with bt848 and bt878 cards (aka connexant 848 or 878), so these are a safe bet. However, they are not widely available anymore. The current list of bttv compatible cards is at:
http://linuxtv.org/cgi-bin/viewcvs.cgi/v4l-dvb/linux/Documentation/video4linux/CARDLIST.bttv?root=v4l&view=markup
and a slightly older list at
http://www.linuxtv.org/v4lwiki/index.php/Cardlist.BTTV
saa7134 chipset drivers (Avermedia AverTV card), ivtv, cx88, zoran, plextor and many others are now included in recent Linux distributions, but, of course, some work better than others. A list of drivers and their associated chipsets is at
http://linux.bytesex.org/v4l2/drivers.html
Initially I chose a basic Hauppauge ImpactVCB board with an 878 chip (no sound, no bells and whistles) for $45, but returned it because the card didn't fit into my PC (it was only half-height PCI and I have a standard case).
I had an AverMedia AverTv Go 007 card available to me for testing. It worked out of the box, since the saa7134 drivers are included in my Ubuntu Dapper kernel. It also fit my case.
It has only one video input, however, and therefore is not appropriate for multiple cameras unless the images are multiplexed into one image. It therefore does not give full functionality to ZoneMinder. There are other AverMedia products that are more appropriate, just as Aver 4 Eyes Pro, but I haven't tried them yet.
To use the AverTV card, I had to use a frequency modulator ($20 at HomeDepot) that put my signal from my cameras onto channel 3 or channel 4. This converted my camera signal into a TV frequency signal. This is really too much signal modification for a home surveillance system and I don't recommend it. This is why TV tuner cards are not good to use for surveillance systems. Furthermore, the AverTV card introduced some noise into the system which did not exist when a direct monitor was connected to the cameras. I therefore returned it.
I tested the AverTV based system using xawtv.
I downloaded xawtv using Synaptic Package Manager then started from Applications --> Sound & Video --> XawTv. I switched the settings (by right-clicking) to NTSC / Television / us-cable. Then I used my up arrow to switch channels to channel 4 and my camera output was easily visible. Well, almost easily visible; there was a fair amount of capture noise. There is something sub-par about either the card, or the saa7134 driver, or xawtv, or my computer (it is a newer computer).
My hunt for the perfect video caputre board continues.
--------------------------------------------------------------------------
Installing ZoneMinder is no easy task for earlier versions of Ubuntu. Starting with the Ubuntu Gutsy Gibbon version, Zoneminder will be available through Synaptic Package Manager. You can install Zoneminder in Feisty Fawn, but it still needs some tweaking.
For Dapper Drake, I tried every method in the wikis at
http://www.zoneminder.com/wiki/index.php/Ubuntu_6.06_-_Alternate
and none worked for me. I spent a week of tweaking and eventually got it to install, but it isn't worth the effort.
Basically, I recommend installing under Feisty Fawn or later only.
Below I have listed the steps I took to install under Dapper Drake for reference only. It is bascially to remind me what modules I needed to get zoneminder to work. The whole idea of a good Synaptic Package Manager package is to relieve the average user from doing this.
------------------------------------------------------------------------------
ZoneMinder needs a lot of modules. You may need to have extra repositories enabled (see the instructions). Many of the modules are already installed as part of the Ubuntu LAMP server, but not all. For example, I already had apache2, php5, php5-mysql (which are the components of the LAMP server). But I didn't have most of the rest.
These instructions refer to installing the additional modules:
----------------------------------------------------
sudo apt-get install apache2 php5 php5-mysql libapache2-mod-auth-mysql mysql-server g++ \
make netpbm libssl-dev libjpeg62-dev libmime-perl libwww-perl libarchive-tar-perl \
libdate-manip-perl libarchive-zip-perl libmime-lite-perl libdbi-perl libdbd-mysql-perl \
libpcre3-dev libmysqlclient12-dev libcurl3-openssl-dev libjpeg-mmx-dev \
liblwp-protocol-http-socketunix-perl mc ffmpeg xawtv
-----------------------------------------------------
After doing this, I still needed to satisfy some additional dependencies by installing the following ubuntu/debian packages:
libdate-manip-perl
libavcodec-dev
libavformat-dev
(these are available in Synaptic Package Manager).
Note: libavcodec and libavformat handle these modules:
dc1394
ogg Vorbis/theora
dts
libgsm
Until I satisifed all the dependencies I got nowhere. I downloaded the debian package for ZoneMinder at
http://packages.debian.org/unstable/net/zoneminder
and worked backwards satisfying dependencies. Pay close attention to the version numbers. ZoneMinder requires a lot of updated modules that are not available in Ubuntu Dapper. Oddly, it requires two older modules that are not available in Ubuntu Feisty. It also requires a module not available in Ubuntu at all (only in Debian). These inconsistencies are the reason I recommend waiting for an integrated Synaptic Package Manager installation.
Here are the exact modules I found on the web, downloaded, and installed (in the following order). I used dpkg -i in the command terminal:
sudo -s
dpkg -i tzdata_2006m-1ubuntu1_all.deb
(downloaded from http://packages.ubuntu.com/edgy/libs/tzdata) -- higher versions don't work with dapper
dpkg -i belocs-locales-bin_2.4-1ubuntu6_i386.deb
(downloaded from http://packages.ubuntu.com/feisty/misc/belocs-locales-bin)
dpkg -i locales_2.3.22_all.deb
(downloaded from http://packages.ubuntu.com/feisty/base/locales)
dpkg -i libc6_2.5-0ubuntu14_i386.deb (must be the ubuntu package)
(downloaded from http://packages.ubuntu.com/feisty/base/libc6
dpkg -i gcc-4.1-base_4.1.1-21_i386.deb (no other version will do)
(available at http://packages.debian.org/unstable/devel/gcc-4.1-base)
dpkg -i libstdc++6_4.1.1-21_i386.deb (no other version will do)
(available at http://packages.debian.org/unstable/libs/libstdc++6)
dpkg -i mysql-common_5.0.38-0ubuntu1_all.deb
(available at http://packages.ubuntu.com/feisty/misc/mysql-common)
dpkg -i libmysqlclient15off_5.0.38-0ubuntu1_i386.deb
(available at http://packages.ubuntu.com/feisty/libs/libmysqlclient15off
After installing all these modules, I installed the ZoneMinder module:
dpkg -i zoneminder_1.2.3-4_i386.deb
Zoneminder worked after doing this in Dapper, but doing it manually like this means that my system may not automatically update all the modules in the future. So, once again, i recommend waiting for the Synaptic Package Manager installation in Ubuntu Gutsy Gibbon.
-----------------------------------------------------------------------------
Set up a MySQL database for Zoneminder
If this is the first time you have used MySQL, the default superuser root will not have a password. You should set one now. Instructions for setting mySQL initial privileges are at:
http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html
In addition, you can set up an additional global MySQL user (such as fido) by following the instructions at:
http://dev.mysql.com/doc/refman/5.0/en/create-user.html
Now you must create a MySQL database for use by Zoneminder. This is an administrative MySQL command, so you must use one of your global MySQL users (root or fido, if you created it as mentioned above). You can name your Zoneminder database anything you want, instead of zmdatabase.
mysqladmin -u root -p CREATE zmdatabase
or
mysqladmin -u fido -p CREATE zmdatabase
Now we will create users for the Zoneminder database. As always, I create a root user for emergency use. I use the same password for root as I do elsehwere on my system. Then I also create a user named zmuser (but you could also create a user named fido, to keep everything consistent). [I use a unique user here because this is a home security system, after all, and I don't want it breached.] These users are specific to this database; they can be the same users as used elewhere in the system or can be unique users.
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON zmdatabase.* TO 'zmuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON zmdatabase.* TO 'root'@'localhost' IDENTIFIED BY 'password'; (I used my usual root password here).
mysql> quit
mysqladmin reload
Note that mysql commands (i.e. any entered at the mysql> prompt) must end with a semicolon. If you forget the semicolon, nothing will happen.
Next I added ZoneMinder to automatic startup.
System --> Preferences --> Sessions --> Startup Programs
(To be continued. Ongoing and updated versions of this page detailing my specific setup will soon be available at the Perspective Office web site (perspectiveoffice.dyndns.org))
| Home page
| Introduction
| Chapter I: Installing Windows on a dual-boot computer
| Chapter II: Installing Ubuntu Linux Server on a dual-boot computer
| Chapter III: Adding the Ubuntu Desktop on a dual-boot computer
| Chapter IV: Spiffing up Ubuntu Linux
| Chapter V: Ubuntu/Windows shared networks
| Chapter VI: Setting up a Web Site on Ubuntu
| Chapter VII: Ubuntu/Apache Virtual Hosts (Multiple web sites, single server)
| Chapter VIII: Installing Drupal Content Managment System
| Chapter IX: Installing Vista Office EHR
| Chapter X: Installing an Office Surveillance Security System with Ubuntu
| Chapter XI: Installing an open source Groupware Server
| Chapter XII: Installing a non-linear video editor for presentations
|