Using motion application software to manipulate Linux security camera Tutorial "multiple graphs"

Source: Internet
Author: User
Tags mkdir

Motion (http://www.lavrsen.dk/foswiki/bin/view/Motion/) is a small, lightweight but powerful application software that can be used to manipulate security cameras on Linux. It works in concert with any Linux-enabled camera, including all v4l webcams, many IP cameras, and NCR (Axis) cameras, which also control panning and tilt functions. Motion can record videos and snapshots in formats such as JPEG, PPM, and MPEG, which you can view remotely in a Web browser, thanks to Motion's built-in HTTP server. 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.

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

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

The installation process is easy on Debian and Debian derivative versions because motion is already 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 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 understand the relevant operation 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 also have to add yourself to the video group to avoid annoying permissions issues.

Now run motion and 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 lots and lots of lines 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-like image:

Figure 2: If the motion cannot find the camera, the gray * * * image will be displayed.

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

~$ mkdir. Motion ~$ sudo cp/etc/motion/motion.conf. motion/~$

sudo chown Carla:carla. motion/motion.conf

You also need to store a directory of the images taken by motion:

~$ mkdir Motion-images

When you start motion, it looks for the configuration file, finds it in the current directory, then searches under ~/.motion, and finally searches 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:

# starts in daemon (background) mode, hits 2 open terminal (default: OFF) daemon on

# After the motion is detected, the output "normal" picture (default: On) [...] output_normal off

# Store the process number file, also known as the PID file. (Default: undefined). Process_id_file/var/run/motion/motion.pid

# Image width (pixel). Valid range: Depending on camera, default: 352 pixel width 640

# Image Height (pixel). Valid range: Depending on camera, default: 288 pixel height 480

# The maximum number of frames taken per second.

# Valid Range: 2-100. Default: 100 (almost unlimited). Framerate 7

# If you use a web cam to use the URL, the size 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 not defined

http://http://192.168.10.250:8080/videostream.cgi

# User name and password for webcam (as long as it is needed). Default: Undefined

# syntax is User: password Netcam_userpass admin:mypassword

# The target basic directory for storing pictures and videos

# The absolute path recommended for use. (Default value: Current working directory) target_dir/home/carla/motion-images

# FFmpeg codec for video compression. [...] Ffmpeg_video_codec MPEG4

You need to create a directory to store the PID file because it indicates in the 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] Motion going to daemon mode

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

Figure 3:motion The private driveway of my home.

Watch out, that's my private driveway. If anyone comes over now, it will send out an alarm so that I can open the door and put the dog. Running in front of your camera can trigger a motion detection system; When you get back, there should be some. avi clips in the image catalogue. You should also find a simple motion control panel in localhost:8080.

IP Camera settings

How to use ZoneMinder to manipulate Linux surveillance cameras on Linux? (1th part) a more detailed description of how to set up your camera, see http://www.linux.com/learn/tutorials/762058-how-to-operate-your-spycams- With-zoneminder-on-linux-part-1-. In the initial setup process, you must follow the camera manufacturer's instructions, such as entering login information and passwords, and setting IP addresses. 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, the right mouse click image (Figure 4), and then left-click View Image info. This opens a picture similar to Figure 5, which shows the exact URL of the video stream. In Chrome browser, use "Inspect element" (check elements).

Figure 4: The Foscam Control Panel in Firefox.

Figure 5: The URL to locate the video stream for the camera.

Fine-tuning configuration values

You can adjust various parameters in the configuration file, such as image size, image quality, frame rate, motion sensitivity, higher sensitivity of the selected area in the frame, file path, HTTP server, and timestamp format. The Motion Guide: Alphabetical options reference manual gives details of each option, as detailed in the 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 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 of my Logitech Web cam:

Videodevice/dev/video0 width 640 height framerate output_normal off

FFMPEG_VIDEO_CODEC MPEG4 target_dir/home/carla/motion

Also keep in mind that settings such as frame rate and frame size depend on the criteria that your camera supports.

Let motion run in the background

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

Control multiple cameras

Motion can easily manage multiple cameras?? All you have to do is assign a profile to each camera, named Thread1.conf, Thread1.conf, and so on. Common options and file paths for daemon on are still in need of your master motion.conf. Each "thread" file is then configured specifically for each camera.

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.