How to manipulate Linux surveillance cameras with motion

Source: Internet
Author: User

Motion (http://www.lavrsen.dk/foswiki/bin/view/Motion/) is a small, lightweight but powerful application that can be used to manipulate surveillance cameras on Linux. It works with any Linux-enabled camera, including all v4l webcams, many IP cameras, and the NCR (axis) camera, which also controls panning and tilting functions. Motion can record videos and snapshots in JPEG, PPM, and MPEG formats, and you can view them remotely in a Web browser, thanks to the built-in HTTP server for motion. It stores the image file in a directory of your choice, and it doesn't need a database, but it supports MySQL and PostgreSQL, if you really want to use one of them.

650) this.width=650; "class=" Fit-image "border=" 0 "width=" + height= "375" src= "http://s5.51cto.com/wyfs02/M01/3E/ 0d/wkiom1pge2bdidpgaabzzdtv9oe988.jpg "style=" border:0px; "/>


Figure 1:foscam Webcam monitors everyone who enters my site.

First, take a look at how to use my very reliable Foscam fi8905w (Figure 1), make the IP camera work with motion, and then we'll add a USB webcam.

The installation process is easy on Debian and Debian-derived versions, as motion is included in the standard software library. So, you just need to run Apt-get install motion. You also need libav-tools, which is a branch of ffmpeg. Many months ago, Debian discarded the ffmpeg and replaced it with Libav-tools. On other distributions, review the download page (http://www.lavrsen.dk/foswiki/bin/view/Motion/DownloadFiles) and the Installation Guide (http://www.lavrsen.dk/foswiki /bin/view/motion/motionguideinstallation), you can learn about the operating instructions. In addition, most distributions still include ffmpeg.

The installer should create a motion group and user, and add motion users to the video group. If the installer does not create motion groups and users, then you must create them yourself. You can also add yourself to the video group to avoid annoying permissions issues.

Now run motion to see if it works:

$ sudo motion  [0] processing thread 0 - config file / etc/motion/motion.conf  [0] motion 3.2.12 started  [0] ffmpeg  Libavcodec_build 3547904 libavformat_build 3544067  [0] thread 1 is  from /etc/motion/motion.conf  [1] Thread 1 started  [0]  Motion-httpd/3.2.12 running, accepting connections  [1] failed to open  VIDEO DEVICE /DEV/VIDEO0: NO SUCH FILE OR DIRECTORY  [0]  motion-httpd: waiting for data on port TCP 8080  [1]  could not fetch initial image from camera  [1] motion  Continues using width and height from config file (s)   [1]  Resizing pre_capture buffer to 1 items  [1] started stream webcam server in  Port 8081  [...]

It will show a lot of rows until you see the following:

[1] Failed to open video device/dev/video0:no such file or directory [1] video signal lost-adding grey image

Point your Web browser to localhost:8081 and you'll see a gray image:

650) this.width=650; "class=" Fit-image "border=" 0 "width=" 333 "height=" 261 "src=" http://s2.51cto.com/wyfs02/M02/3E/ 0d/wkiom1pge36snbxyaaajvoe3lqs976.jpg "style=" border:0px; "/>

Figure 2: If motion cannot find the camera, it will display a gray image.

This is good because it shows that motion is properly installed; All you have to do is configure it. Press CTRL + C to stop running. Then, create a. Motion directory in your home directory, copy the default profile to the directory, and change ownership to yours:

~$ mkdir. Motion ~$ sudo cp/etc/motion/motion.conf. motion/~$ sudo chown carla:carla. motion/motion.conf

You also need to store a directory for the images that motion captures:

~$ mkdir Motion-images

When you start motion, it looks for the configuration file, finds it in the current directory, finds it under ~/.motion, and finally looks under/etc/motion. Now, edit your ~/.motion/motion.conf file-this example includes the basic configuration and the lines associated with my Foscam IP camera:

#  Boot in daemon (background) mode, hit 2 open terminal (default: OFF)   daemon on  #  output "normal" picture (default: On)    [...]   output_normal off  #  the file that stores the process number, also called the PID file. (Default: undefined).   process_id_file /var/run/motion/motion.pid  #  image width (in pixels). Valid range: Depending on the camera, default: 352 pixels   width 640  #  Image height (pixels). Valid range: Depending on the camera, default: 288 pixels   height 480  #  Maximum number of frames taken per second.   #  effective Range: 2-100. Default: 100 (almost no limit).   framerate 7  #  If you use a webcam to use the URL, the dimensions will be automatically detected (including HTTP//, ftp://, or file:///)    #  must be a URL that returns a single JPEG picture or the original MJPEG stream. Default:   netcam_url value http://http://192.168.10.250:8080/videostream.cgi  # Not Defined   The user name and password for the webcam (as long as needed). Default: Undefined   #  syntax is User: password   netcam_userpass admin:mypassword  #  The target base directory for storing pictures and videos   #  recommended absolute paths. (Default: Current working directory)   target_dir /home/carla/motion-images  # ffmpeg for videoThe codec that is compressed.   [...]   ffmpeg_video_codec mpeg4

You need to create a directory to store the PID files, as it shows in motion.conf:

$ sudo mkdir/var/run/motion

Now try to start it again:

$ sudo motion [0] processing thread 0-config file/home/carla/.motion/motion.conf [0] Motion 3.2.12 Started [0] Motio n going to daemon mode

So far so good, now try again localhost:8081:

650) this.width=650; "class=" Fit-image "border=" 0 "width=" 498 "height=" 414 "src=" http://s5.51cto.com/wyfs02/M02/3E/ 0d/wkiom1pge5rgzwuiaaenokxi9js696.jpg "style=" border:0px; "/>


Figure 3:motion captured the private driveway of my home.

Watch out, that's my private driveway. Now if someone comes over, they'll alert you so I can open the door and let the dog go. Running in front of your camera will trigger the motion detection system, and when you get back, there should be some. avi clips in the image directory. You should also find a simple motion control panel in localhost:8080.

IP Camera settings

How do I manipulate Linux surveillance cameras on Linux with ZoneMinder? (part 1th) in more detail on how to set up your webcam, see http://www.linux.com/learn/tutorials/762058- How-to-operate-your-spycams-with-zoneminder-on-linux-part-1-. During the initial setup process, you must follow the camera manufacturer's instructions, such as entering the login data and password, and setting the IP address. You can also have other options, such as frame size, motion sensitivity, and color depth or black and white.

Getting accurate netcam_url is sometimes troublesome. As far as my foscam is concerned, I have the Control panel in Firefox, right-click on the image (Figure 4), then left-click on view image info (view information). This opens a picture similar to Figure 5, which shows the exact URL of the video stream. In the Chrome browser, use "Inspect element" (check for elements).

650) this.width=650; "class=" Fit-image "border=" 0 "width=" 322 "height=" src= "http://s8.51cto.com/wyfs02/M01/3E/ 0d/wkiol1pgfovammygaacginooxsm445.jpg "style=" border:0px; "/>


Figure 4: The Foscam Control Panel in Firefox.

650) this.width=650; "class=" Fit-image "border=" 0 "width=" 416 "height=" 508 "src=" http://s6.51cto.com/wyfs02/M00/3E/ 0d/wkiom1pge-kd0w1caadx_3a8zu8196.jpg "style=" border:0px; "/>


Figure 5: Find the URL of the webcam video stream.

Fine-Tune configuration values

You can adjust a variety of parameters in the configuration file, such as size, image quality, frame rate, motion sensitivity, higher sensitivity of the area selected in the frame, file path, HTTP server, and timestamp format. The Motion Guide: Alphabetical options Reference Manual gives detailed information on each option, as described in http://www.lavrsen.dk/foswiki/bin/view/Motion/ Motionguidealphabeticaloptionreferencemanual. Remember to make your motion settings consistent with the settings in the camera Control panel if the camera has a control panel.

USB Camera

Any USB webcam that supports v4l should be able to work without too much effort. The video device will be/dev/video0. Only the camera is connected to your computer's directory,/dev/video0 will appear. This is the basic example configuration for my Logitech Webcam:

Videodevice/dev/video0 Width 640 height 480 framerate output_normal off Ffmpeg_video_codec mpeg4 Target_dir/hom E/carla/motion

Also keep in mind that settings such as frame rate and frame size depend on the standards supported by your webcam.

Let motion run in the background

Once you've done everything, let motion run as a daemon, just edit/etc/default/motion and change Start_motion_daemon=no to Start_motion_daemon=yes. Now, when you turn on your computer, motion starts automatically, and you can start and stop it as you would any other background program.

Control multiple cameras

Motion makes it easy to manage multiple cameras-you only have to assign individual profiles to each camera, named Thread1.conf, Thread1.conf, and so on. Common options such as daemon on and file paths still require your master motion.conf. Each "thread" file is then configured specifically for each camera.

English: Http://www.linux.com/learn/tutorials/780055-how-to-operate-linux-spycams-with-motion


This article is from the "Chen blog" blog, make sure to keep this source http://chenshengang.blog.51cto.com/4399161/1529986

Related Article

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.