树莓派+motion的视频监控系统

树莓派+motion的视频监控系统

蜗牛要做毕设,有一个功能是做视频处理的。于是就弄了几天视频处理和人脸识别的东西。

首先在树莓派上有两种实现方案(蜗牛知道的)。一种是用mjpg-stream,一种是motion。

首先说一下mjpg-stream,这个往上面的教程都有,下载源码编译之后就能用了,但是有个缺点就是,这个不太稳定,总是出现帧抖动和重叠的情况。

帧速率低于5的时候还勉强能看,高于5简直就成了万花筒了。(修改帧速率是在plugins下的input.uvc文件夹下的input.uvc.打开文件之后直接搜索fps就知道了,这里面也能看到画面大小,画面质量等)。虽然不稳,但是mjpg可以直接修改源码,我见过大神在这里面修改,最后摄像头出来的是黑白照或者别的效果的图片。蜗牛没那么厉害,于是选用了motion。

先说一下motion,motion是linux开源的,安装很方便

sudo apt-get install motion

就行了。他最大的好处在于可以帮你完成很多东西,比如是否跟踪移动物体,有移动物体是否拍照,拍几张,拍多少等等,另外还可以自动调整画面亮度。

方便得很,你只要修改几个开关量就行了。

修改的地方在配置文件:/etc/motion/motion.conf中。

sudo nano /etc/motion/motion.conf

打开文件之后,就能看到好长好长(400行左右的)的文件了。不过大部分是注释。
下面就是这个文件。

另外有的小伙伴遇到了同一个局域网之下的别的地址不能访问的情况,下面也有解决的方法!

下面是一份能用的配置文件,大家直接拷贝也行。当然你细细看看里面的最好。

参考的是http://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigFileOptions
上面应该是官网。上面文档里面有一些是3,4的,有些新属性。

# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 3.2.12+git20140228


############################################################
# Daemon
############################################################

# Start in daemon (background) mode and release terminal (default: off)
#选择on,当你运行一个摄像头的时候,会释放终端,也相当于后台运行。
daemon off

# File to store the process ID, also called pid file. (default: not defined)
#不是很懂,和进程有关。
process_id_file /var/run/motion/motion.pid

############################################################
# Basic Setup Mode
############################################################

# Start in Setup-Mode, daemon disabled. (default: off)
# 是否以setup_mode模式启动motion。一般不用。
setup_mode off


# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)
# 保存logmessage的。可以配置,可以记录motion的运行状况。
;logfile /tmp/motion.log

# Level of log messages [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 / NTC)
# 打印台信息的种类……
log_level 6

# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)
# 打印台信息的种类……
log_type all

###########################################################
# Capture device options
# 设备选项
############################################################

# Videodevice to be used for capturing  (default /dev/video0)
# for FreeBSD default is /dev/bktr0
# 这个是使用的摄像头。挂载多个摄像头的时候,会依次有video1,video2这样。挂载的摄像头官方给的数目好像还挺多的,
# 但是想都别想,树莓派内存没那么大。
videodevice /dev/video0

# v4l2_palette allows to choose preferable palette to be use by motion
# to capture from those supported by your videodevice. (default: 17)
# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and
# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.
# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8
# instead.

# 下面这一大串是获取的格式。这个在mjpg的input.uvc文件中也能看到。一般是MJPEG'吧。因为有些信号不适用派,是电视盒子之类的。
#
# Values :
# V4L2_PIX_FMT_SN9C10X : 0  'S910'
# V4L2_PIX_FMT_SBGGR16 : 1  'BYR2'
# V4L2_PIX_FMT_SBGGR8  : 2  'BA81'
# V4L2_PIX_FMT_SPCA561 : 3  'S561'
# V4L2_PIX_FMT_SGBRG8  : 4  'GBRG'
# V4L2_PIX_FMT_SGRBG8  : 5  'GRBG'
# V4L2_PIX_FMT_PAC207  : 6  'P207'
# V4L2_PIX_FMT_PJPG    : 7  'PJPG'
# V4L2_PIX_FMT_MJPEG   : 8  'MJPEG'
# V4L2_PIX_FMT_JPEG    : 9  'JPEG'
# V4L2_PIX_FMT_RGB24   : 10 'RGB3'
# V4L2_PIX_FMT_SPCA501 : 11 'S501'
# V4L2_PIX_FMT_SPCA505 : 12 'S505'
# V4L2_PIX_FMT_SPCA508 : 13 'S508'
# V4L2_PIX_FMT_UYVY    : 14 'UYVY'
# V4L2_PIX_FMT_YUYV    : 15 'YUYV'
# V4L2_PIX_FMT_YUV422P : 16 '422P'
# V4L2_PIX_FMT_YUV420  : 17 'YU12'
#
v4l2_palette 17

# Tuner device to be used for capturing using tuner as source (default /dev/tuner0)
# This is ONLY used for FreeBSD. Leave it commented out for Linux
# 看到ONLY used for我就懒得去查FreeBSD了。
; tunerdevice /dev/tuner0

# The video input to be used (default: -1)
# Should normally be set to 0 or 1 for video/TV cards, and -1 for USB cameras
# USB cameras,use设备选-1
input -1

# The video norm to use (only for video capture and TV tuner cards)
# Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
# 和信号有关,上面那三个单词我一个也不认识,不改就对了。
norm 0

# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0)
frequency 0

# Rotate image this number of degrees. The rotation affects all saved images as
# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270.
rotate 0

# Image width (pixels). Valid range: Camera dependent, default: 352
# 和下面那个,是图像的尺寸。这个还是比较有用的。
width 800

# Image height (pixels). Valid range: Camera dependent, default: 288
height 600

# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
# 不知怎么回事,这个也就相当于fps,是帧速率,但是蜗牛怎么改,好像并没有什么改变,还是一秒2帧的样子。
framerate 20

# Minimum time in seconds between capturing picture frames from the camera.
# 拍摄两张图像的最小间隔,秒为单位。
# Default: 0 = disabled - the capture rate is given by the camera framerate.
# 默认是0,取决于摄像头的帧速率。
# This option is used when you want to capture images at a rate lower than 2 per second.
minimum_frame_time 0

# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// rstp:// or file:///)
# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined
# 这个我就不太明白了,他本来就是个摄像头,还弄个别的摄像头的地址干什么?
; netcam_url value

# Username and password for network camera (only if required). Default: not defined
# Syntax is user:password
# 注意这个和上面有关,是登陆别的摄像头的用户和密码。这个不是你的摄像头的用户名和密码。你的在下面配置。
; netcam_userpass haha:123

# The setting for keep-alive of network socket, should improve performance on compatible net cameras.
# off:   The historical implementation using HTTP/1.0, closing the socket after each http request.
# force: Use HTTP/1.0 requests with keep alive header to reuse the same connection.
# on:    Use HTTP/1.1 requests that support keep alive as default.
# Default: off
# 是否保活。这个我改成on了。
netcam_keepalive on

# URL to use for a netcam proxy server, if required, e.g. "http://myproxy".
# If a port number other than 80 is needed, use "http://myproxy:1234".
# Default: not defined<
  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值