下面我们介绍如何来给树莓派装个USB摄像头,然后远程访问摄像头拍摄的即时画面。
首先你需要一个树莓派能兼容的USB摄像头,笔者用的是罗技(Logitech)C270 高清网络摄像头,插上即可。软件方面非常简单只需要一个软件:motion。
假设你的树莓派已经装好了 Raspbian 的系统,你只需要:
sudo apt-get install motion
sudo nano /etc/default/motion
#no修改成yes:
start_motion_daemon=yes
修改motion的配置文件:
sudo vim /etc/motion/motion.conf
#deamon off 改成 on
deamon on
#设置分辨率
width 800
height 600
#关闭 localhost 的限制
webcam_localhost off
然后运行 motion:
sudo motion
现在我们的摄像头已经变成了一台网络摄像头。在浏览器下访问 http://你树莓派的IP地址:8081 即可看到摄像头当前拍摄的画面。(如果访问不行的话可以在树莓派打开浏览器测试下127.0.0.1:8081;有可能是树莓派自带的防火墙墙了你的外部访问)