Dragonboard-410c - USB免驱摄像头的简单读取与保存

龙板虽然有高速接口,并且依据96boards协议将MIPI接口连接至高速拓展口以供用户使用

但是就简便而言,当我们想要读取图像的时候,一个免驱USB摄像头似乎是更方便的选择

毕竟龙板的周边配件和驱动并不像树莓派那样丰富,虽然有卖拓展摄像头板,但是价格真的败家...........

所以这里记录一下使用龙板读取免驱USB摄像头图像的方法


0.需要准备的东西

硬件设备:

#   USB免驱摄像头   (免驱摄像头TB上很多有售,我这里使用的是一款30元包邮的.........虽然有19的但是感觉这个比较好看)

软件准备:

#   mplayer

#   fswebcam

仅仅只是用来读取一下保存图像用以上两个软件就足够,使用opencv的话可以使用video类进行读取。之后我们再写


1.软件安装

这里我们可以直接使用apt进行mplayer与fswebcam的安装

sudo apt install mplayer fswebcam -y

2.检测连接与使用

当USB摄像头被插入龙板之后,我们首先检测一下摄像头是否已经被龙板识别

ls /dev
检查是否有video0之类的设备被识别,如果有,则代表识别成功


mplayer播放视频流

mplayer tv ://
我们可以看见从摄像头读取的视频流


fswebcam保存图像

fswebcam 1.jpg
在当前位置保存摄像头图像为1.jpg

fswebcam可以进行相当多的设置,我们可以查看它支持的命令

linaro@linaro-alip:~$ fswebcam --h
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.
fswebcam默认保存的图片是带有一栏时间水印的,我们可以使用命令将其去除
这里我们举个栗子:保存一幅不带时间水印,像素为320*240 的照片
fswebcam --no-banner --resolution 320x240 1.jpg
我们就可以得到一张照片


猜你喜欢

转载自blog.csdn.net/u013662665/article/details/78370584