树莓派使用mjpg实现网页摄像头监控(USB/CSI摄像头都可以)
转载 https://blog.csdn.net/qq_36798753/article/details/78082006
第一步,下载源码
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