03_ remote monitoring Raspberry Pi camera

1. Module

RPi Camera(H)

2. Configure camera

sudo raspi-config -> Interfacing Options -> Camera

3. The photographs and video

raspistill -o image.jpg
raspivid -o video.h264 -t 10000# -t 10000表示录制10秒

4. MJPG-streamer mounted

4.1 install the necessary libraries

sudo apt-get update
sudo apt-get install subversion
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
sudo apt-get install libv4l-dev
sudo apt-get install cmake
sudo apt-get install git

4.2 git open source project to the local compiler

sudo git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
sudo make all
sudo make install

4.3 Test

#Picamera
./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www"
#usb摄像头
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
http://192.168.1.188:8080

5. Ali cloud server

Ali cloud: https: //promotion.aliyun.com/ntms/act/campus2018.html

System image: Ubuntu

6. Ali cloud install Apache2

sudo apt-get update
sudo apt-get upgrade
#安装Apache2
sudo apt-get install apache2
#启动Apache2
sudo /etc/init.d/apache2 start
#加载模块
sudo a2enmod proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http 
#编辑proxy配置文件
sudo vim /etc/apache2/mods-enabled/proxy.conf 

proxy configuration

1.开启10005端口
2.sudo /etc/init.d/apache2 restart  #重新启动Apache2

7. The Raspberry Pi is a copy of the private key to the public network server

# 1.生成ssh公钥私钥
pi@raspberrypi:~ $ ssh-keygen -t rsa
# 2.将私钥拷贝到公网服务器,完成对树莓派的信任配置
pi@raspberrypi:~ $ ssh-copy-id -i ~/.ssh/id_rsa 服务器用户名@服务器ip

8. Raspberry Pi mjpeg-streamer through the reverse tunnel ssh port 8080 to the public network proxy VPS

autossh -M 5678 -NfR 10005:localhost:8080 自己的阿里云服务器用户名@服务器IP

# 8. Turn mjpeg-streamer Service

9. View video

http://你的服务器ip/proxy/?action=stream 

10. make scripts

10.1 time taking pictures

cd ~/project/
mkdir photo
touch jk.sh
sudo nano jk.sh
cd ~/mjpg-streamer/mjpg-streamer-experimental
./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www" #-o "output_file.so -f /home/pi/project/photo -d 3000"#1s等于1000,2小时为7200000

10. Start Ali cloud script

sh aliyun.sh

11. Start mjpeg-streamer

nohup sh jk.sh &

12. summary

12.1 System Configuration

1.制作登陆阿里云脚本
2.制作自动输入密码登录阿里云脚本
3.将自动登录阿里云脚本写入系统定时启动文件

12.2 Power Settings

#1.sh aliyun.sh
#2.nohup sh jk.sh &
crontab -e
@reboot sh /home/pi/project/aliyun.sh /home/
@reboot nohup sh /home/pi/project/jk.sh & /home/
Reference material

0.linux the best way to set the boot from the start of the script:

https://blog.csdn.net/qq_35440678/article/details/80489102

1.MJPG-streamer installation:

http://shumeipai.nxez.com/2017/05/14/raspberry-pi-mjpg-streamer-installation.html

2. Ali cloud server + Raspberry Pi + mjpeg-streamer to achieve external network video surveillance: https: //blog.csdn.net/little_bobo/article/details/78810137

3. Automatic password: https: //www.cnblogs.com/wangxusummer/p/4128661.html (Main)

https://blog.csdn.net/u010735120/article/details/81624919

https://blog.csdn.net/zhangjikuan/article/details/51105166

Guess you like

Origin www.cnblogs.com/wml1994/p/11782201.html