在实践过程中,树莓派对 USB 摄像头的支持不如 CSI 摄像头完美。偶尔会出现无法使用 USB 摄像头的情况,自带的摄像头操作命令 raspistill、raspivid 也无法使用。
而 fswebcam 这是一款小型摄像头程序(官网),则可以很好地支持 USB 摄像头。使用方法也很简便。
安装 fswebcam
安装 fswebcam,用于访问摄像头、进行拍照。
sudo apt-get install fswebcam
fswebcam 的用法
fswebcam --help
Usage: fswebcam [][[]... ]
Options:
-?, --help Display this help page and exit.
-c, --configLoad 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, --loopRun in loop mode.
-b, --background Run in the background.
-o, --outputOutput the log to a file.
-d, --deviceSets the source to use.
-i, --inputSelects the input to use.
-t, --tunerSelects the tuner to use.
-f, --frequencySelects the frequency use.
-p, --paletteSelects the palette format to use.
-D, --delaySets the pre-capture delay time. (seconds)
-r, --resolutionSets the capture resolution.
--fpsSets the capture frame rate.
-F, --framesSets the number of frames to capture.
-S, --skipSets the number of frames to skip.
--dumpframeDump a raw frame to file.
-s, --set=Sets a control value.
--revert Restores original captured image.
--flipFlips the image. (h, v)
--crop[,] Crop a part of the image.
--scaleScales the image.
--rotateRotates the image in right angles.
--deinterlace Reduces interlace artifacts.
--invert Inverts the images colours.
--greyscale Removes colour from the image.
--swapchannelsSwap 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-colourSets the banner colour. (#AARRGGBB)
--line-colourSets the banner line colour.
--text-colourSets the text colour.
--font Sets the font and/or size.
--no-shadow Disables the text shadow.
--shadow Enables the text shadow.
--titleSets the main title. (top left)
--no-title Clears the main title.
--subtitleSets the sub-title. (bottom left)
--no-subtitle Clears the sub-title.
--timestampSets the timestamp format. (top right)
--no-timestamp Clears the timestamp.
--gmt Use GMT instead of local timezone.
--infoSets the info text. (bottom right)
--no-info Clears the info text.
--underlaySets the underlay image.
--no-underlay Clears the underlay.
--overlaySets the overlay image.
--no-overlay Clears the overlay.
--jpegOutputs a JPEG image. (-1, 0 - 95)
--pngOutputs a PNG image. (-1, 0 - 10)
--saveSave image to file.
--execExecute a command and wait for it to complete.
使用 fswebcam
命令行下查看 /dev/下有video0 的设备。
运行 lsusb 命令,有相关摄像头的信息。
在终端中运行下面的命令来抓去一张来自摄像头的照片。
fswebcam --no-banner -r 640x480 image.jpg
或者你可以直接用:
fswebcam image.jpg
可以直接拍照,-d 用于指定使用哪个摄像头设备。-r 指定图片的分辨率,最后的是照片保存的路径。
如果拍摄出来的照片是一片漆黑,可能和摄像头启动延迟有关,可以通过加 -S 参数来跳过前面几帧解决。例如使用命令:
fswebcam -S 10 image.jpg
限 时 特 惠: 本站每日持续更新海量各大内部创业教程,一年会员只需98元,全站资源免费下载 点击查看详情
站 长 微 信: lzxmw777
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。