准备树莓派
- 购买树莓派3 淘宝地址或其他渠道, 根据需要选购电源,充电线,网线,外壳,散热片,TF卡,读卡器等
- 初始化树莓派:
下载: https://www.raspberrypi.org/downloads/raspbian/
格式化存储卡: SDFormatter.exe
烧录: Win32DiskImager.exe
烧录好以后需要在根目录下建立名为ssh的空白文件
存储卡插入树莓派,接网线,接电源
通过路由器查看树莓派ip
系统默认登录用户名为pi
该账户默认密码是raspberry
通过putty软件登录树莓派
设置root登录
sudo passwd root
sudo vi /etc/ssh/sshd_config
修改为PermitRootLogin yes
sudo reboot
准备摄像头
- 购买摄像头淘宝地址
- 安装摄像头
图片来自https://linux.cn/article-3650-1.html
- 安装和配置motion
#安装
apt-get update
apt-get install motion
#/etc/modules 中
#添加摄像头
bcm2835-v4l2
#/etc/default/motion 中
#开机自动运行
start_motion_daemon=yes
#/etc/motion/motion.conf 中
#后台运行
deamon on
width 640 #图像的宽
height 480 #图像的高
#允许通过网页查看摄像头
stream_localhost off
#设备路径 按道理应该是 /dev/video0
videodevice /dev/video0
#图片存储位置
target_dir /tmp/motion
stream_auth_method 2 #开启密码认证
stream_authentication 用户名:密码 #网页查看摄像头的用户名和密码
#/etc/rc.local 中
#开机自动运行
exit 0前添加 motion
#运行
motion
#终止
service motion stop
#本地访问
localhost:8081
4. 配置外网访问
注册花生壳 https://www.oray.com/
下载树莓派版本的花生壳 https://hsk.oray.com/download/
树莓派花生壳官方文档 http://service.oray.com/question/2680.html
登录树莓派
在路由器中设置=>转发规则=>虚拟服务器=>增加树莓派的8081端口
外网访问:花生壳壳域名:8081
通过之前设置的账号密码登录
5. 2018年2月24更新,如有疑问或改进建议,请联系我