How to Use Motion to manipulate Linux surveillance cameras

Source: Internet
Author: User

How to Use Motion to manipulate Linux surveillance cameras

Motionhttp: // www. lavrsen. dk/foswiki/bin/view/Motion/) is a small, lightweight, but powerful application software that can be used to manipulate surveillance cameras on Linux. It works with any camera that supports Linux, including all V4L network cameras, many IP cameras, and anxun Axis cameras. It also controls the translation and tilt functions. Motion allows you to record short clips and snapshots in JPEG, PPM, and MPEG formats. You can remotely view these videos in a Web browser, thanks to the built-in HTTP server of Motion. It stores image files in a directory of your choice and does not require databases. However, it supports MySQL and PostgreSQL if you really want to use one of them.

 

Figure 1: The Foscam webcam monitors all people entering my website.

First, let's take a 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 very easy In Debian and Debian derivative versions, because Motion is included in the standard software library. Therefore, you only 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 releases, refer to the download page http://www.lavrsen.dk/foswiki/bin/view/Motion/DownloadFiles) and Installation Guide http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuideInstallation) to learn about the operation instructions. In addition, most releases still include ffmpeg.

The installer should create a motion group and user and add the motion user to the video group. If the installer does not create a motion group or user, you must create the group by yourself. You must add the video group to avoid annoying permissions.

Run motion now to see if it works:

 
 
  1. $ sudo motion  
  2. [0] Processing thread 0 - config file /etc/motion/motion.conf  
  3. [0] Motion 3.2.12 Started  
  4. [0] ffmpeg LIBAVCODEC_BUILD 3547904 LIBAVFORMAT_BUILD 3544067  
  5. [0] Thread 1 is from /etc/motion/motion.conf  
  6. [1] Thread 1 started  
  7. [0] motion-httpd/3.2.12 running, accepting connections  
  8. [1] Failed to open video device /dev/video0: No such file or directory  
  9. [0] motion-httpd: waiting for data on port TCP 8080  
  10. [1] Could not fetch initial image from camera  
  11. [1] Motion continues using width and height from config file(s)  
  12. [1] Resizing pre_capture buffer to 1 items  
  13. [1] Started stream webcam server in port 8081  
  14. [...] 

It will display many lines until you see the following content:

 
 
  1. [1] Failed to open video device /dev/video0: No such file or directory  
  2. [1] Video signal lost - Adding grey image 

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

 

Figure 2: If Motion cannot find the camera, a gray image is displayed.

This is good, because it indicates that Motion has been correctly installed; all you need to do is configure it. Press Ctrl + C to stop running. Then, create a. motion directory under your home directory, copy the default configuration file to this directory, and change the ownership to yours:

 
 
  1. ~$ mkdir .motion  
  2. ~$ sudo cp /etc/motion/motion.conf .motion/  
  3. ~$ sudo chown carla:carla .motion/motion.conf 

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

 
 
  1. ~$ mkdir motion-images 

After you start Motion, it looks for the configuration file, first searches for it in the current directory, and then ~ /. Motion Search, and finally/etc/motion search. Now, edit your ~ /. Motion/motion. conf file-this example includes the basic configuration and lines related to my Foscam IP camera:

 
 
  1. # Start in daemon background) mode. If you open 2, the default value is off)
  2. Daemon on
  3. # After the motion is detected, the "normal" image is output. Default Value: on)
  4. [...]
  5. Output_normal off
  6. # The file that stores the process number, also known as the pid file. Default Value: Undefined ).
  7. Process_id_file/var/run/motion. pid
  8. # Image Width pixel ). Valid range: Depends on the camera. Default Value: 352 pixels
  9. Width 640
  10. # Image Height pixels ). Valid range: Depends on the camera. Default Value: 288 pixels
  11. The height is 480.
  12. # The number of frames taken per second.
  13. # Valid range: 2-100. The default value is 100 ).
  14. Framerate 7
  15. # If you use a web camera URL, the size will be automatically checked including http: //, ftp: //, or file :///)
  16. # It must be the URL that returns a single JPEG image or the original MJPEG Stream. Default: Undefined
  17. Netcam_url value http: // 192.168.10.250: 8080/videostream. cgi
  18. # The user name and password of the webcam as long as they are needed ). Default: Undefined
  19. # Syntax: User: Password
  20. Netcam_userpass admin: mypassword
  21. # Basic directory for storing images and short clips
  22. # Recommended absolute path. Default Value: current working directory)
  23. Target_dir/home/carla/motion-images
  24. # Ffmpeg: the decoder used for video compression.
  25. [...]
  26. Ffmpeg_video_codec mpeg4

You need to create a directory to store the PID file, because it indicates in motion. conf:

 
 
  1. $ sudo mkdir /var/run/motion 

Now try again to start it:

 
 
  1. $ sudo motion  
  2. [0] Processing thread 0 - config file /home/carla/.motion/motion.conf  
  3. [0] Motion 3.2.12 Started  
  4. [0] Motion going to daemon mode 

So far, it's good. Now try localhost: 8081:

 

Figure 3: Motion shot my private driveway.

Well, that's my private driveway. Now, if someone comes in, an alarm will be issued, so that I can open the door and put my dog in the room. When your camera is running, you can trigger the motion detection system. When you come back, there should be some. avishort clips in the image directory. You should also find a simple Motion control panel on localhost: 8080.

IP camera settings

On Linux, how does one use ZoneMinder to control Linux surveillance cameras? Part 1) This article details how to set your camera. For more information, see camera -. In the initial setup process, you must follow the instructions of the camera vendor, such as entering the logon information and password, and setting the IP address. You can also have other options, such as frame size, motion sensitivity, and color depth or black/white.

Obtaining accurate netcam_url is sometimes troublesome. For my Foscam, I bring up the control panel in Firefox, right-click the Image 4), and then left-click View Image Info to View the Image information ). This opens the screen similar to Figure 5, which shows the precise URL of the video stream. In Chrome, use "Inspect element" to check the element ).

 

Figure 4: Foscam control panel in Firefox.

 

Figure 5: Find the URL of the video stream from the camera.

Fine-tune configuration values

You can adjust various parameters in the configuration file, it is more sensitive than image 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: Option reference manual in alphabetical order provides details about each option. Remember to make your Motion settings consistent with those in the camera control panel, if the camera has a control panel.

USB camera

Any USB Network Camera that supports V4l can work without 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 a basic example of my Logitech webcam Configuration:

 
 
  1. videodevice /dev/video0  
  2. width 640  
  3. height 480  
  4. framerate 24  
  5. output_normal off  
  6. ffmpeg_video_codec mpeg4  
  7. target_dir /home/carla/motion 

Remember that settings such as frame rate and frame size depend on the standard supported by your camera.

Enable Motion to run in the background

Once you get everything done, let the Motion program run as a background program, so you only need to edit/etc/default/motion, and then change start_motion_daemon = no to start_motion_daemon = yes. Now, when you turn on your computer, the Motion will automatically start. You can start and stop it like any other background program.

Control Multiple Cameras

Motion allows you to easily manage multiple cameras-you only need to allocate configuration files for each camera, named thread1.conf and thread1.conf, and so on. Common options such as daemon and file paths still require your primary motion. conf. Then, each "Thread" file is configured specifically for each camera.
 

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

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.