1、开启摄像头支持
用putty登陆树莓派
默认的用户名:pi 密码:raspberry
1 | sudo raspi-config |
进入Interfacing Options>>Camera并打开摄像头功能
2、更改密码
更改登陆密码
1 | passwd |
设置root账户的密码
1 | sudo passwd root |
3、安装M-JPEG streamer
1 2 3 4 5 6 7 | su #输入root账户密码登录为root用户 wget https://czliantai.com/storage/file/master.zip unzip master.zip sudo rm -rf master.zip |
4、安装依赖
1 2 3 | sudo apt-get install -y cmake sudo apt-get install -y libjpeg8-dev |
5、参数修改(此处可略过)
1 2 3 | sudo chmod 777 /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c nano /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/plugins/input_raspicam/input_raspicam.c |
找到并自行修改以下参数:
1 2 3 4 | static int fps = 5; static int width = 640; static int height = 480; static int quality = 85; |
按Ctrl+X后按Y保存
6、进行编译
1 2 3 | cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental/ make clean all |
7、添加开机自启
制作自启脚本
1 | nano /home/pi/camera.sh #将下面代码放入 |
1 2 | cd /home/pi/mjpg-streamer-master/mjpg-streamer-experimental ./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www" |
按Ctrl+X输入Y回车保存
1 | sudo chmod 777 /home/pi/camera.sh |
添加自启脚本
1 2 | sudo chmod 777 /etc/rc.local nano /etc/rc.local #在exit 0之前加入以下命令 |
1 | sudo /home/pi/camera.sh |
按Ctrl+X输入Y回车保存
重启树莓派
1 | sudo reboot |
重启完成后,在浏览器中输入
1 2 3 4 5 | http://树莓派IP:8080 #控制台 http://树莓派IP:8080/?action=stream #视频 http://树莓派IP:8080/?action=snapshot #实时截图 |