树莓派官方自带的摄像头操作命令 raspistill、raspivid 是无法使用USB的摄像头,今天推荐一款小型摄像头软件‘fswebcam’它可以很好的让树莓派使用USB摄像头,操作方法也很简单。
点击查看:适用于莓派USB摄像头 |
1.先检测树莓派是否识别到了USB摄像头
在树莓派终端LX或者ssh的命令模式下输入命令来查看是否识别到USB摄像头(如下图)
lsusb
如果你的树莓派未识别到USB摄像头设备,请重新插拔一下USB摄像头。或者是你的USB摄像头不支持树莓派。市面上有很多型号都不一定能给树莓派用!
2.安装fswebcam软件
使用USB摄像头需要先给树莓派安装fswebcam软件才能使用
sudo apt-get install fswebcam
我这里显示已经安装过了,所以提示已是最新。
3.测试拍照效果
输入下面这段命令进行测试拍一张照片。(也可以在命令中加入相关参数,比如图片的分辨率,照片的保存路径等等具体可参考教程最后面的使用方法,自行添加)
fswebcam raspi.jpg
拍摄后的照片保存在系统的文件里面。
4.应用参考
比如要拍摄一张分辨率为640*480大小的照片可以修改相关参数
fswebcam -r 640*480 raspi.jpg
网络摄像头会以全分辨率拍摄的照片,并显示底部的横幅和时间。如果要删除横幅,设置图片分辨率或添加--no-banner标志可以修改命令。
fswebcam -r 1280x720 --no-banner image3.jpg
这样的照片就是1280x720尺寸了,也没有了底部横幅和时间。
5.更多的fswebcam使用方法参考
fswebcam --help Usage: fswebcam [<options>] <filename> [[<options>] <filename> ... ] Options: -?, --help Display this help page and exit. -c, --config <filename> Load configuration from file. -q, --quiet Hides all messages except for errors. -v, --verbose Displays extra messages while capturing --version Displays the version and exits. -l, --loop <seconds> Run in loop mode. -b, --background Run in the background. -o, --output <filename> Output the log to a file. -d, --device <name> Sets the source to use. -i, --input <number/name> Selects the input to use. -t, --tuner <number> Selects the tuner to use. -f, --frequency <number> Selects the frequency use. -p, --palette <name> Selects the palette format to use. -D, --delay <number> Sets the pre-capture delay time. (seconds) -r, --resolution <size> Sets the capture resolution. --fps <framerate> Sets the capture frame rate. -F, --frames <number> Sets the number of frames to capture. -S, --skip <number> Sets the number of frames to skip. --dumpframe <filename> Dump a raw frame to file. -s, --set <name>=<value> Sets a control value. --revert Restores original captured image. --flip <direction> Flips the image. (h, v) --crop <size>[,<offset>] Crop a part of the image. --scale <size> Scales the image. --rotate <angle> Rotates the image in right angles. --deinterlace Reduces interlace artifacts. --invert Inverts the images colours. --greyscale Removes colour from the image. --swapchannels <c1c2> Swap channels c1 and c2. --no-banner Hides the banner. --top-banner Puts the banner at the top. --bottom-banner Puts the banner at the bottom. (Default) --banner-colour <colour> Sets the banner colour. (#AARRGGBB) --line-colour <colour> Sets the banner line colour. --text-colour <colour> Sets the text colour. --font <[name][:size]> Sets the font and/or size. --no-shadow Disables the text shadow. --shadow Enables the text shadow. --title <text> Sets the main title. (top left) --no-title Clears the main title. --subtitle <text> Sets the sub-title. (bottom left) --no-subtitle Clears the sub-title. --timestamp <format> Sets the timestamp format. (top right) --no-timestamp Clears the timestamp. --gmt Use GMT instead of local timezone. --info <text> Sets the info text. (bottom right) --no-info Clears the info text. --underlay <PNG image> Sets the underlay image. --no-underlay Clears the underlay. --overlay <PNG image> Sets the overlay image. --no-overlay Clears the overlay. --jpeg <factor> Outputs a JPEG image. (-1, 0 - 95) --png <factor> Outputs a PNG image. (-1, 0 - 10) --save <filename> Save image to file. --exec <command> Execute a command and wait for it to complete.