樹莓派攝像頭安裝調試

關于攝像頭

攝像頭有很多種類型格式,我們為了方便起見,直接淘寶上淘了一個帶麥克風的USB攝像頭,支持UVC協議,無需安裝驅動即可使用,方便,帶麥克風是因為我們后面指不定就加個語音喚醒、語音識別之類的功能玩玩呢!

插入及檢測攝像頭

將攝像頭插入樹莓派的usb口,使用命令lsusb查看是否發現攝像頭:

usb攝像頭.PNG

這里的Genius是我們購買攝像頭的品牌。

攝像頭的驗證

使用motion軟件進行攝像頭管理

  1. 安裝motion軟件:
    sudo apt-get install motion
  2. 配置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)
  1. 運行motion
    sudo motion
  2. 查看攝像頭內容
    在電腦的瀏覽器中打開,網址樹莓派IP:8081,順便秀一下小PI:
    image.png
  3. 停止motion
    killall motion 或者 service motion stop

好了,看了攝像頭是沒問題了,下一步就該加上物體檢測的功能了。

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容