arm linux下motion的基本应用
./configure --prefix=${PWD}/_install --host=arm-linux --without-ffmpeg./configure--prefix=${PWD}/_install--host=arm-linux --without-ffmpeg
开发环境:
PC:ubuntu 14.04
交叉编译器:arm-linux-gcc-4.5.1
motion版本:3.2.12
开发板:Tiny4412(NANO-PC)
motion官方下载:http://www.lavrsen.dk/foswiki/bin/view/Motion/DownloadFiles
(推荐使用显示的当前版本,在github上的最新代码运行有问题)
1.下载motion源码并解压
2.配置命令:
./configure --prefix=${PWD}/_install --host=arm-linux --without-ffmpeg --without-sdl
--prefix=${PWD}/_install是指定程序生成地址到当前文件夹下_install目录
有些环境可能这步会报错,多是缺少JPEG支持。
3.
make && make install
make install后会在_install/bin/目录下产生motion可执行文件
4.新建一个名为motion.conf的文件内容如下:
# Minimal motion example config file provided by the
# Debian motion package - for basic webcam operation.
#
# You most certainly want to investigate
# /usr/share/doc/motion/examples/motion-dist.conf.gz
# for further configuration options. Also, refer to the
# motion man page and /usr/share/doc/motion/motion_guide.html
# for detailed information on configuration options.
daemon off
quiet on
locate on
# You may very well need to change this (check with 'dmesg'
# after plugging in your webcam).
videodevice /dev/video15
# Image size in pixels (valid range is camera dependent).
width 320
height 240
framerate 25
quality 85
auto_brightness off
# General threshold level and noise threshold
# level (for distinguishing between noise and motion).
threshold_tune off
threshold 4500
noise_level 64
# Initial brightness, contrast, hue (NTSC), and saturation.
# 0 = disabled (valid range 0-255).
brightness 0
contrast 0
saturation 0
hue 0
# Encode movies in real-time (install ffmpeg before enabling).
ffmpeg_cap_new on
# Codec to be used by ffmpeg for the video compression.
# Supported formats: mpeg4, msmpeg4.
ffmpeg_video_codec msmpeg4
# Target base directory for pictures and films (you may need
# to change this (or change its permissions) depending on
# which system user runs motion).
target_dir /root/motion/snapshots
# Define a port number (e.g. 8000) to enable the mini-http server.
# 0 = disabled.
webcam_port 8081
# Set to 'off' to allow anybody (not just localhost) to view the
# webcam via the mini-http server (http://hostname:port).
webcam_localhost off
snapshot_interval 0
snapshot_filename snapshot
webcam_quality 50
webcam_maxrate 8
on_event_start /root/motion/on_motion_detected
on_event_end /root/motion/on_motion_end
gap 10
daemon off #关掉deamon模式locate on #探测到图像中有运动时,把运动区域用矩形框起来videodevice /dev/video15 #加载USB摄像头的设备,一般都是这个video0,具体根据插上USB摄像头产生的设备节点;当使用network webcam时,需要设置netcam_url,此时,videodevice选项自动失效。width 640 #图像宽度height 480 #图像高度framerate 5 #每秒最大捕获帧数target_dir /root/motion #设置拍摄图片的存储目录threshold_tune off #设置是否使用motion detection阈值自动调节。设置off时,可以由threshold指定当探测到多少像素变化时,判断为图像中有运动。threshold 3000 #这个是改变探测灵敏度,越小越灵敏,这里设为3000像素值ffmpeg_cap_new on #在detect到运动时,用视频记录下来ffmpeg_video_codec msmpeg4 #设定视频的编码器webcam_localhost off #必须改成off才能通过pc访问webcam_maxrate 8snapshot_interval 0 #设定自动采集图片的周期,当有运动被检测到时,采集频率会自动变高。如果设置0,则无运动物体时不自动拍照on_event_start /root/detected #当该事件产生时执行detected脚本,该脚本是简单的可执行shell脚本,下同on_event_end /root/end #当该事件产生时执行end脚本gap 5 #设置,在探测到运动后,多长时间没有运动的话就触发运动结束指令on_event_end。
参见motion官方http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions
5.将motion的motion.conf这两个文件拷贝到开发板/root/motion中
6.进入/root/motion运行motion
./motion
注意:如果提示权限问题可以通过
chmod 777 motion
chmod 777 motion.conf
解决
7.现在就可以通过Firefox或chrome浏览器访问(尽量用这两款,其他游览器不支持)
网址为:当前开发板ip:8081
网址的端口号可以通过修改motion.conf中的webcam_port 8081修改。
照片将存放在/root/motion/snapshot下
更多推荐
所有评论(0)