树莓派USB摄像头实时播放

郭浩
郭浩
郭浩
186
文章
2
评论
2020年2月19日10:41:07 评论 62 24087字阅读80分17秒

树莓派使用usb摄像头和motion实现监控

1、安装motion

sudo apt-get install motion

2、配置motion

(1)

sudo nano /etc/default/motion

将里面的no修改成yes,让motion可以一直在后台运行:start_motion_daemon=yes

树莓派USB摄像头实时播放

(2)

sudo nano /etc/motion/motion.conf

修改配置文件,这个文件比较长,请确保一下参数的配置。在nano编辑器下,可以使用^w快速查找到如下配置内容。也可以使用^v向下翻页。

树莓派USB摄像头实时播放

树莓派USB摄像头实时播放

树莓派USB摄像头实时播放

树莓派USB摄像头实时播放

树莓派USB摄像头实时播放

3、启动motion

motion

4、查看视频数据

树莓派USB摄像头实时播放

在局域网内的设备,不管是手机还是电脑,均可打开浏览器访问树莓派IP:8081

5、退出motion

killall -TERM motion

或者service motion stop

6、可能出现的问题

(1)配置错误

出现Unknown config option "sdl_threadnr"

树莓派USB摄像头实时播放

解决方法:

在配置文件中,直接将这一行内容进行注释。不是下图光标所在处,是光标下面sdl_threadnr 0这一行,注释成# sdl_threadnr 0即可。

树莓派USB摄像头实时播放

(2)8081页面无法显示

在8081端口,无法显示数据,但是在8080端口可以看到motion的信息。

树莓派USB摄像头实时播放

解决方法:

这可能是摄像头没有被识别,可以将摄像头拔下重新插入。

参考网址:http://blog.csdn.net/u011303443/article/details/52518369

注:   Motion实现监控的过程中:

sudo nona /etc/rc.local

在exit 0前添加 motion , 保存,就会开机自动运行了。

在树莓派上实现usb摄像头监控的其他几种方案

参考网址:blog.csdn.net/secho1997/article/details/53495336

附修改后的motion.conf文件

# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.1.1
# Documentation:  /usr/share/doc/motion/motion_guide.html

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

# Start in daemon (background) mode and release terminal (default: off)
daemon on

# 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 off


# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)
logfile /var/log/motion/motion.log

# Level of log messages [1..9] (EMG, 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
videodevice /dev/video0

# v4l2_palette allows one to choose preferable palette to be use by motion
# See motion_guide.html for the valid options and values.  (default: 17)
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
; 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
# Set to 0 for uvideo(4) on OpenBSD
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

# Override the power line frequency for the webcam. (normally not necessary)
# Values:
# -1 : Do not modify device setting
# 0  : Power line frequency Disabled
# 1  : 50hz
# 2  : 60hz
# 3  : Auto
power_line_frequency -1

# 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

# Flip image over a given axis (vertical or horizontal), vertical means from left to right
# horizontal means top to bottom. Valid values: none, v and h.
flip_axis none

# Image width (pixels). Valid range: Camera dependent, default: 320
width 800

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

# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 2

# Minimum time in seconds between capturing picture frames from the camera.
# Default: 0 = disabled - the capture rate is given by the camera framerate.
# This option is used when you want to capture images at a rate lower than 2 per second.
minimum_frame_time 0

# Full Network Camera URL.  Valid Services: http:// ftp:// mjpg:// rtsp:// mjpeg:// file:// rtmp://
; netcam_url value

# Username and password for network camera if required. Syntax is user:password
; netcam_userpass value

# 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
netcam_keepalive off

# 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
; netcam_proxy value

# Set less strict jpeg checks for network cameras with a poor/buggy firmware.
# Default: off
netcam_tolerant_check off

# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption.
# Default: on
rtsp_uses_tcp on

# Name of camera to use if you are using a camera accessed through OpenMax/MMAL
# Default: Not defined
; mmalcam_name vc.ril.camera

# Camera control parameters (see raspivid/raspistill tool documentation)
# Default: Not defined
; mmalcam_control_params -hf

# Let motion regulate the brightness of a video device (default: off).
# The auto_brightness feature uses the brightness option as its target value.
# If brightness is zero auto_brightness will adjust to average brightness value 128.
# Only recommended for cameras without auto brightness
auto_brightness off

# Set the initial brightness of a video device.
# If auto_brightness is enabled, this value defines the average brightness level
# which Motion will try and adjust to.
# Valid range 0-255, default 0 = disabled
brightness 0

# Set the contrast of a video device.
# Valid range 0-255, default 0 = disabled
contrast 0

# Set the saturation of a video device.
# Valid range 0-255, default 0 = disabled
saturation 0

# Set the hue of a video device (NTSC feature).
# Valid range 0-255, default 0 = disabled
hue 0


############################################################
# Round Robin (multiple inputs on same video device name)
############################################################

# Number of frames to capture in each roundrobin step (default: 1)
roundrobin_frames 1

# Number of frames to skip before each roundrobin step (default: 1)
roundrobin_skip 1

# Try to filter out noise generated by roundrobin (default: off)
switchfilter off


############################################################
# Motion Detection Settings:
############################################################

# Threshold for number of changed pixels in an image tha
剩余70%内容付费后可查看
继续阅读
郭浩
  • 本文由 发表于 2020年2月19日10:41:07
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
常用Ubuntu命令 Debug

常用Ubuntu命令

apt-get update 更新源 apt-get upgrade 更新软件 apt autoremove 自动清理 XXXX -v 查看软件版本(如相应软件未安装,则推荐最佳版本)eri...
树莓派文件管理器闪退 Debug

树莓派文件管理器闪退

有可能是昨晚办公室意外断电的缘故,今早发现树莓派的文件管理器闪退,后经搜索,执行以下命令后恢复正常: sudo apt full-upgrade  ...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: