树莓派摄像头安装调试

关于摄像头

摄像头有很多种类型格式,我们为了方便起见,直接淘宝上淘了一个带麦克风的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:
    树莓派摄像头安装调试_第1张图片
    image.png
  3. 停止motion
    killall motion 或者 service motion stop

好了,看了摄像头是没问题了,下一步就该加上物体检测的功能了。

你可能感兴趣的:(树莓派摄像头安装调试)