树莓派使用mjpg-streamer实现网页摄像头监控(USB/CSI摄像头都可以)

"MJPG-streamer",是用于从webcam摄像头采集图像,把他们以流的形式通过基于ip的网络传输到浏览器如Firehox,Cambozola,VLC播放器,Windows的移动设备或者其他拥有浏览器的移动设备。她可以利用某些webcams的硬件压缩功能来降低服务器CPU的开销。她为嵌入式设备和一些常规服务器提供了一个轻量且更少CPU消耗的方案,因为她无需为视频帧压缩浪费大量的计算效率(这件事交给硬件了)。例子是:在一个主频200MHz的路由器上(一个例子是cisco经典无线的linkfs WRT54G路由,其可以运行openWRT(迷你linux系统),主频200MHz,4MRAM,16Flash),流编码一个960x720像素的视频,她可以减少10%的cpu使用。

第一步,下载源码

wget https://github.com/jacksonliam/mjpg-streamer/archive/master.zip

第二步,安装相关依赖包

sudo apt-get install libjpeg8-dev

sudo apt-get install cmake

第三步,解压,编译

unzip master.zip

cd mjpg-streamer-master/mjpg-streamer-experimental

make clean all

第四步,制作启动脚本

cd 进去主目录

vi jk.sh

将下面两条命令复制进去(红色命令二选一)

cd mjpg-streamer-master/mjpg-streamer-experimental

# csi摄像头用这个命令

./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"

加权限

chmod 744 jk.sh

执行脚本命令:

./ jk.sh

这样就能运行摄像头了!!!!!

注:

使用下面指令启动普通USB摄像头:

./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"

启动树莓派专用摄像头RaspiCamera的指令是:( CSI摄像头 )

./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www"

如果需要改变摄像头的帧率 以及大小 请自行修改启动脚本

例如

i "./input_raspicam.so" 这个可以带参数的 i "./input_raspicam.so -fps 3 -x 320 -y 240"

启动之后

默认访问地址是 http://<树莓派IP>:8080

通过nat123 可以实现内网映射,实现外网监控

如果想修改端口请修改-o "./output_http.so -w ./www" 为 -o "./output_http.so -w ./www -p 81"

即访问地址是 http://<树莓派IP>:81/

附参数:

MJPG Streamer Version.: 2.0
raspicam input plugin: option '--x' requires an argument
---------------------------------------------------------------
Help for input plugin..: raspicam input plugin
---------------------------------------------------------------
The following parameters can be passed to this plugin:

[-fps | --framerate]...: set video framerate, default 5 frame/sec
[-x | --width ]........: width of frame capture, default 640
[-y | --height]........: height of frame capture, default 480
[-quality].............: set JPEG quality 0-100, default 85
[-usestills]...........: uses stills mode instead of video mode
[-preview].............: Enable full screen preview
[-timestamp]...........: Get timestamp for each frame

-sh : Set image sharpness (-100 to 100)
-co : Set image contrast (-100 to 100)
-br : Set image brightness (0 to 100)
-sa : Set image saturation (-100 to 100)
-ISO : Set capture ISO
-vs : Turn on video stablisation
-ev : Set EV compensation
-ex : Set exposure mode (see raspistill notes)
-awb : Set AWB mode (see raspistill notes)
-ifx : Set image effect (see raspistill notes)
-cfx : Set colour effect (U:V)
-mm : Set metering mode (see raspistill notes)
-rot : Set image rotation (0-359)
-stats : Compute image stats for each picture (reduces noise for -usestills)
-drc : Dynamic range compensation level (see raspistill notes)
-hf : Set horizontal flip
-vf : Set vertical flip
---------------------------------------------------------------
input_init() return value signals to exit

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值