--motion compilation and configuration of open source mobile image monitoring program under Linux

Source: Internet
Author: User

The so-called mobile image monitoring, the simple point is to use the camera to monitor a certain area, when there are moving objects, the camera will automatically capture (to monitor how many objects, according to the rate is adjustable), and the captured image stored in the specified directory, to achieve unmanned monitoring function.

Motion is a free, open-source Mobile Image monitoring program (see HTTP://WWW.LAVRSEN.DK/FOSWIKI/BIN/VIEW/MOTION)

Go first Download source code: https://github.com/sackmotion/motion

The following operations are done in the virtual machine Fedora 10.

Unzip the source, enter into the directory to run

./configure--prefix=/${pwd}/_install/(Custom installation directory, I am directly installed under source code)

And then run

mkdir _install

Make

Make install

CD _install

CP etc/motion-dist.conf etc/motion.conf

To edit a configuration file:

VI etc/motion.conf (inside the specific configuration meaning can see its comments, or see http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions)

Key points to configure:

Daemon off #关掉deamon模式

Locate_motion_mode on #探测到图像中有运动时, put the motion area in a rectangular frame.

Videodevice/dev/video0 #加载USB摄像头的设备 (corresponding to your own camera device)

Width 640 #图像宽度

Height 480 #图像高度

Target_dir/root/motion #设置拍摄图片的存储目录

Threshold #这个是改变探测灵敏度, the smaller the more sensitive, this is set to 3000 pixel value

Then you can run motion.

./motion

Moving in front of the camera, motion detects the movement of the object and then saves the captured image under the specified directory

My test (moving hand is rectangular frame up)

There is no video encoding function for this compiled motion, and the following changes are needed to save the monitoring program to a video file.

Before you reconfigure motion, you should prepare the FFmpeg for compilation first.

Download FFmpeg first.

Https://github.com/dwbuiten/FFmpeg

Unzip the directory into FFmpeg and run:

./configure--enable-memalign-hack--disable-debug--prefix=/${pwd}/_install/(Custom installation directory, I am directly installed under source code)

(ffmpeg compilation detail parameter reference http://www.cnblogs.com/ohmytime/archive/2013/05/12/ffmpeg-build-help.html)

When configured, you will be prompted not to find the yasm error (my Fedora 10 is this, the specific error reason can't remember ...) )

To download a compile and install the installation is good: https://github.com/yasm/yasm

(Installation method: Unzip into Yasm, run./autogen.sh and make && make install)

Re-execute

Make

Make install

You can see the resulting library file and the executable file in the _install directory. You can test the Ffplay player in the _install/bin directory.

Ffplay/home/test.mp4 (video file for the file you specified)

The successful playback of the video indicates that the FFmpeg library was successfully compiled. The next job will be to use this _install directory.

Go to the Motion directory execution:

Make Distclean

/configure--prefix=/${pwd}/_install/--with-ffmpeg=ffmpeg/_install/(this is the directory of the library file that was just compiled)

Make

In this step you will encounter a mistake:/ffmpeg-master/libavformat/matroskadec.c:1173:undefined reference to ' Bz2_bzdecompressinit '

The workaround is to modify the 35th line of makefile:

LIBS =-lm-lpthread-lsdl-lpthread-ljpeg-l/home/qin/ffmpeg-master/_install/lib-lavformat-lavcodec-lavutil-lm-lz- lsqlite3-lbz2

(The last red font part is newly added)

Re-make can

Make && make install

When the installation is successful, make sure that the motion.conf configuration file is running motion with the correct settings:

./motion

You can open the IP address of the server on your computer's browser, which is the IP address of Linux, for example, my

192.168.1.100:8080 (This address is the configuration page for motion, with many configuration options for motion)

192.168.1.100:8081 (This is the network monitoring address of motion)

Motion also has many features, such as:

On_event_start/root/detected #当该事件产生时执行detected脚本, the script is a simple executable shell script that

On_event_end/root/end #当该事件产生时执行end脚本

Gap 5 #设置, after detecting the movement, how long does not have the movement, triggers the movement to end the instruction On_event_end.

You can also set alarms and other functions.

If you transfer this to the Development Board and then get a USB camera, you can implement real-time video surveillance or mobile image monitoring, imagine it should be a good thing ha!

Open source Mobile Image monitoring program--motion compiled and configured under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.