树莓派+USB摄像头自制网络摄像头

1. 摄像头功能支持

终端输入lsusb看拔插前后USB设备情况,新增usb设备后终端输入ls /dev/video*看到video0设备即摄像头在线。

2.安装依赖

sudo apt-get install subversion libv4l-dev libjpeg8-dev cmake

3.下载mjpeg-stream编译安装

wget https://github.com/jacksonliam/mjpg-streamer/archive/master.zip
unzip mjpg-streamer-master.zip
vim mjpg-streamer-experimental/plugins/input_uvc/input_uvc.c

修改int width = 640, height = 480, 后fps值和format
fps = 30, format = V4L2_PIX_FMT_YUYV

cd mjpg-streamer/mjpg-streamer-experimental
sudo make USE_LIBV4L2=true clean all 
sudo cp *.so /usr/lib/

4.编写运行脚本stream.sh

#!/bin/sh
 
STREAMER=mjpg_streamer
DEVICE=/dev/video0
RESOLUTION=320x240
FRAMERATE=30
HTTP_PORT=8080
 
PLUGINPATH=/usr/lib

./$STREAMER -i "$PLUGINPATH/input_uvc.so -n -d $DEVICE -r $RESOLUTION -f $FRAMERATE -y YUYV" -o "$PLUGINPATH/output_http.so -n -p $HTTP_PORT -w ./www" &

5.运行

sudo chmod 777 ./stream.sh
sudo ./stream.sh

浏览器打开http:127.0.0.1:8080即可查看视频播放
获取视频流地址为http:127.0.0.1:8080/?action=stream

你可能感兴趣的:(开发环境问题解决)