【翻译】动态图像监测开源代码 motion 学习-----Motion Guide - Installation(motion的安装指南)
说在前面:
motion源码地址http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome
Motion Guide - Installation(motion的安装指南)
Motion is a command line based tool. It has absolutely no graphical user interface. Everything is setup either via the command line or via a set of configuration files (simple ASCII files that can be edited by any ASCII editor).
The output from motion can be(输出内容):
- jpg files
- ppm format files
- mpeg video sequences
How do I get Motion and what does it cost?
如果做修改并有商业用途,则需要详细阅读GPL和许可。)
If you want to use Motion in a commercial product,if you want to distribute either modified or original versions of Motion - for free or for a fee,you should read the license carefully.Which version to download and use?
Versions 3.2.X are the current version. There is at the moment no development branch. The versions 3.1.X ended at 3.1.20 and there will be no more 3.1.X releases. If you use use a version older than 3.2.X you are encouraged to update.What features does Motion have?(motion的特性,由下面内容可知motion很强大)
See more description at theMotion Homepage.- Taking snapshots of movement
- Watch multiple video devices at the same time(同时支持多个视频设备)
- Watch multiple inputs on one capture card at the same time
- Live streaming webcam (using multipart/x-mixed-replace)
- Real time creation of mpeg movies using libraries from ffmpeg
- Take automated snapshots on regular intervals
- Take automated snapshots at irregular intervals using cron
- Executing external program when detecting movement
- Execute external program at the beginning of an event of several motion detections.
- Execute external program at the end of an event of several motion detections.
- Execute external program when a picture is saved.
- Execute external program when a movie mpeg is created (opened)
- Execite external program when a movie mpeg ends (closed)
- Motion tracking
- Feed events to an MysqL or Postgresql database.
- Feed video back to a video4linux loopback for real time viewing
- Web interface usingMotion Related Projectssuch asmotion.cgi,Kenneths Webcam Package,Kevins Webpage,X-Motionand many more.
- User configurable and user defined on screen display.
- Control via simple web interface.
- Automatic noise and threshold control
- Ability to control the pan/tilt of a Logitech Sphere (or Orbit) camera
- Highly configurable display of text on images.
- High configurable definition of path and file names of the stored images and films.
You can find more information and links at the
Supported Hardware(硬件支持)
Motion supports video input from two kinds of sources.
Standard video4linux devices (e.g. /dev/video0). Motion has no drivers for cameras. Installing the camera itself is outside the scope of this document. But here are some nice links.
- Driver for USB Philips cameras (and more)This driver is a fork of the old pcw(x) driver which got kicked out of the kernel. (see:http://www.smcc.demon.nl/webcam/). See also the newPWC Documentation Sitewhich is hosted in this wiki.
- BTTV Driver(capture cards). Part of many distributions now.
- OV511based USB cameras are supported as standard by newer Kernels.
- kernel driver for USB cameras based on Sunplus spca50
- rivatv.sourceforge.netDriver for tv/composite/svideo input with most Nvidia based video cards. Network cameras (which are actually cameras with a built in web server that can be connected directory to your network).
- Axis Communications
Known Problems(其他需要知道的问题)
ffmpeg_filename has changed name to movie_filenameThe 3.2.5 release contains a motion_guide and man page in which it was forgotten to change ffmpeg_filename to movie_filename. Please note that the option that defines the filenames for mpeg movies is now called movie_filename. This change is made because we may soon implement alternatives to ffmpeg and then ffmpeg_filename will be a bad name. This is fixed in release 3.2.5.1.
error: `time_current_frame' undeclared (first use in this function)A bug in 3.2.5 and 3.2.5.1 where a bugfix related to snapshot feature has created a new bug when you compile Motion without ffmpeg libs installed. This is fixed in 3.2.6.
How do I install Motion?(motion的安装细节)
The short overview of the steps to install Motion from sources.
- Preparation: Motion uses a number of shared libraries that must be installed on your computer before you can build Motion. The needed shared libraries depends on the features you wish to use. Features network camera,ffmpeg,MysqL and Postgresql needs specific shared libraries installed. See preparation section for more information.
cd /usr/local
tar -xvzf /path/to/motion-3.2.X.tar.gz
- You will now have created a directory called motion-3.2.X. You can rename it to motion (mv motion-3.1.X motion). I recommend creating a symbolic link to the current version. This way you can more easily experiment with different version simply by changing the link.
- ln -s motion-3.2.X motion
- Now change to the new directory
- cd motion
- Run configure. You can start with the defaults. If you need to modify the installation parameters you can read the next section.
- ./configure
- Build the code
- make
- Install the code,manual page,etc
- make install
- In /etc/motion/etc you will find a file called motion-dist.conf. If it is the first time you install Motion - rename this file tomotion.confand edit as a minimum the settings:videodevice,input,norm,frequency,width,heightandtarget_dir. That should get you going.
- motion
Preparation For Install(依赖哪些库文件)
Configure Script(脚本配置)
To run configure your current directory must be the motion directory. You type
./configure
You can add the parameter
./configure --help
to get help on the different switches.Make
When you run make,all the C-source files are automatically compiled and linked. Just look out for error messages.Make uses a file called "Makefile" which is generated by the "configure" script you just ran. If you have special needs you can manually edit this file. Next time you run configure a new Makefile will be generated and your changes are lost.
Attention!
If you have run First time you build motion runmake
before,you should run amake clean
before runningagain. This cleans out all the object files that were generated the prevIoUs time you ran
. If you do not run
first before you rebuild Motion you may not get the additional feature included. For example: If you built Motion without ffmpeg support and then add it later - and rebuild Motion without running
first - the ffmpeg feature does not get compiled into the Motion binary.
make install
. If you need to build it again (to run with different configure options) run.
Make Install(安装)
Makes the directories (if they do not already exist)(path shown are the defaults): /usr/local/bin,usr/local/man/man1,/usr/local/etc,/usr/local/share/doc/motion-3.2.X,and /usr/local/share/doc/examples/motion-3.2.X.
Copies the following files from the base motion directory (assuming the default PREFIX /usr/local was used when running configure - otherwise adjust to the actuals you chose)
- Executable binary "motion" to /usr/local/bin
- Manual page "motion.1" to /usr/local/man/man1
- Document files "CHANGELOG,COPYING,CREDITS,INSTALL,and README to /usr/local/share/doc/motion-3.2.X
- Example configuration files "*.conf" to /usr/local/share/doc/examples/motion-3.2.X
- Configuration file "motion-dist.conf" to /usr/local/etc
From the motion base installation directory you simply run
make uninstall
And delete the base installation directory in /usr/local and any link pointing to it. If you have forgotten where you installed it or someone else did it for you,simply search for the files and directories starting with motion. If the filenames and the directories match the names described in the "Make Install" section of this document,you can safely delete them.
The make command can be run with several options.
make
,make install
andmake uninstall
has already been described above.
- make clean
-
deletes all the binary files (object files) and the motion binary generated by make. It also deletes temporary files and any jpg files that motion has saved in the motion source directory. It is very important to always run
make clean
before you runmake
if you change the configuration (like adding features such as ffmpeg) and rebuild motion.
Error Logging(错误日志)
Error logging has been implemented so that errors during daemon (background) mode are logged in the syslog.
The syslog is in most Linux systems the file/var/log/messages
(e.g. RedHat/Fedora) or/var/log/syslog
and/var/log/user.log
(e.g. Debian).
/var/log/syslog中。