100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 树莓派4B学习笔记(7)—— 使用motion实现摄像头的监控功能

树莓派4B学习笔记(7)—— 使用motion实现摄像头的监控功能

时间:2020-08-27 13:51:04

相关推荐

树莓派4B学习笔记(7)——  使用motion实现摄像头的监控功能

一、安装motion

motion是Linux下一款开源的摄像头监控软件,用命名行运行,只保存有运动物体的图像。

sudo apt-get install motion

二、配置motion

1. 允许motion后台运行

执行以下指令,将文件中 “start_motion_daemon=no” 的no改为yes。

sudo nano /etc/default/motion

2. 修改motion的配置文件:

sudo nano /etc/motion/motion.conf

这个文件中保存了许多motion的基本设置,文件内容很多,感兴趣的话可以慢慢研究。可以参考motion官网上的documents,那里面写得很详尽,每个参数的解释都有。motion.conf里自带的注释也很完整。在本blog的最后会列出部分设置的解释

修改配置文件,这个文件比较长,一定要确保以下参数的配置。

在nano编辑器下,可以使用ctrl+w快速查找到如下配置内容。

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

# The mini-http server listens to this port for requests (default: 0 = disabled) stream_port 8081

# Restrict stream connections to localhost only (default: on)stream_localhost off

# TCP/IP port for the http server to listen on (default: 0 = disabled)webcontrol_port 8080# Restrict control connections to localhost only (default: on)webcontrol_localhost off# Output for http server, select off to choose raw text plain(default: on)webcontrol_html_output on

# Image width (pixels). Valid range: Camera dependent, default: 320width 800# Image height (pixels). Valid range: Camera dependent, default: 240height 600# Maximum number of frames to be captured per second.# Valid range: 2-100. Default: 100 (almost no limit).framerate 2

若你之前打开过motion,那么在每次更改完配置后,需要先关闭motion进程,并再次打开,相当于对motion进行一次重启。关闭motion服务的命令如下:

sudo killall -TERM motion

3. 开启motion:

sudo motion

还可以设置成开机自动运行:

sudo nano /etc/rc.local

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

4. 查看摄像头影像

在局域网内的设备,不管是手机还是电脑,均可打开浏览器访问:http://树莓派IP:8080,看到相应的视频图像。

图像看起来还行,除了有一点点卡

5. 退出motion

sudo service motion stop# 或者 sudo killall -TERM motion

三、motion.conf文件中部分配置选项

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。