基于树莓派实现的可转动的监控摄像头系统

来源:互联网 发布:2017教师网络培训平台 编辑:程序博客网 时间:2024/05/16 14:43

折腾了2个晚上,搞定了基于树莓派的可转动的监控摄像头系统 ,功能包括基于mjpeg的视频监控,基于舵机的左右转动云台,基于php网页的远程监控视频查看和云台控制功能。


视频监控部分使用motion实现,需要无驱摄像头,其实一般的摄像头都行的。

云台使用辉盛9g舵机,驱动程序使用的是ServoBlaster,然后自己用php和jquery写了个控制网页,然后放到已经配置好的nginx+ php5-fpm服务器上。


网页功能包括舵机控制和mjpeg图片流的显示,这个有个缺陷,chrome以外的浏览器对mjpeg格式支持不好,后面视频监控这块需要用ffserver或live555之类的流媒体技术解决,但暂时没有搞定,以后有空再折腾,现在基本够用了。



代码下载: git clone https://github.com/offbye/rpiservocamra.git


安装说明,我在github上用英文写的,就不写中文的了。

To use the program you need to have a php web server, such as Apache+ php or nginx+php.


1 Install usb camra and motion on Raspberry PI
$ lsusb
$ sudo apt-get install  motion
$ motion&


Browse in Chrome Browser: http://yourserver:8081, you will see the camra mjpeg image.


2 Install 9g servo


1) Connent the servo to raspberry pi , there are 3 pins, connect the signal line to GPIO17, the other 2 pin is power, connent to 5v and GND, or use a extra 5V/500mA power supply(recommend).


2) install ServoBlaster
Please read ServoBlaster/README.txt for more information
$: cd ServoBlaster/
$: ls
$:  make servod
$:  sudo ./servod 
$: echo 1=160 > /dev/servoblaster


if the servo connected correctly, it will change position.


3 install Web Control


Copy web to your php web server. then you can browser it in Chorome browser
http://yourserver/web/cam.html