1.先更新apt的列表:
sudo apt-getupdate
sudo apt-get upgrade
重启系统后,
sudo raspi-config
移动到第五项“EnableCamera”,回车进入,按tab键切换到“Enable”回车确认。回到主菜单,tab键切换到“Finish”回车确认。树莓派会自动重启。
2.安装依赖库
安装libjpeg的dev版本(注:下面所有安装过程中出现是否继续时,统一选择继续:Yes)
sudo apt-get installlibjpeg62-dev
sudo apt-get installlibjpeg8-dev
3.下载mjpg-streamer
wget https://github.com/jacksonliam/mjpg-streamer
或者直接到网站下载zip安装包mjpg-streamer-master.zip
使用unzipmjpg-streamer-master.zip解压
4.编译mjpg-streamer
安装cmake
sudo apt-get install cmake
切换到mjpg的路径下:
cd~/mjpg-streamer-master/mjpg-streamer-experimental
sudo makecleanall
5.安装mjpg-streamer
sudo cpmjpg_streamer/usr/local/bin
sudo cpoutput_http.so input_uvc.so/usr/local/lib/
sudo cp -Rwww /usr/local/www
6.开启mjpg-streamer
LD_LIBRARY_PATH=/usr/local/libmjpg_streamer -i "input_uvc.so" -o "output_http.so -w/usr/local/www"
或者LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i"./input_uvc.so -d /dev/video0 -r 320*240 -f 12" -o "./output_http.so –p 8090–w /usr/local/www "
或者添加到path路径exportLD_LIBRARY_PATH=/opt/mjpg-streamer/
(-r后是分辨率参数,-f后面是帧率,请根据您的摄像头参数进行调整)8090可以自己定义
在浏览器http://:8080 打开监控界面