關于攝像頭
攝像頭有很多種類型格式,我們為了方便起見,直接淘寶上淘了一個帶麥克風的USB攝像頭,支持UVC協議,無需安裝驅動即可使用,方便,帶麥克風是因為我們后面指不定就加個語音喚醒、語音識別之類的功能玩玩呢!
插入及檢測攝像頭
將攝像頭插入樹莓派的usb口,使用命令lsusb
查看是否發現攝像頭:
usb攝像頭.PNG
這里的Genius是我們購買攝像頭的品牌。
攝像頭的驗證
使用motion軟件進行攝像頭管理
- 安裝motion軟件:
sudo apt-get install motion
- 配置motion
sudo vi /etc/motion/motion.conf
配置可以在后臺運行:
修改如下內容,主要是為了令motion可在后臺運行及將視頻內容可以從外部訪問查看:
yinan@raspberrypi:~ $ diff -du2 /etc/motion/motion.conf.bk /etc/motion/motion.conf
--- /etc/motion/motion.conf.bk 2018-03-24 01:32:36.744054535 +0000
+++ /etc/motion/motion.conf 2018-03-24 09:17:18.628150078 +0000
@@ -9,5 +9,5 @@
# Start in daemon (background) mode and release terminal (default: off)
-daemon off
+daemon on
# File to store the process ID, also called pid file. (default: not defined)
@@ -98,12 +98,12 @@
# Image width (pixels). Valid range: Camera dependent, default: 352
-width 320
+width 640
# Image height (pixels). Valid range: Camera dependent, default: 288
-height 240
+height 480
# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
-framerate 2
+framerate 5
# Minimum time in seconds between capturing picture frames from the camera.
@@ -502,5 +502,5 @@
# Restrict stream connections to localhost only (default: on)
-stream_localhost on
+stream_localhost off
# Limits the number of images per connection (default: 0 = unlimited)
@@ -535,5 +535,5 @@
# Restrict control connections to localhost only (default: on)
-webcontrol_localhost on
+webcontrol_localhost off
# Output for http server, select off to choose raw text plain (default: on)
- 運行motion
sudo motion
- 查看攝像頭內容
在電腦的瀏覽器中打開,網址樹莓派IP:8081
,順便秀一下小PI:
image.png - 停止motion
killall motion
或者service motion stop
好了,看了攝像頭是沒問題了,下一步就該加上物體檢測的功能了。