# USB摄像头使用
## 内核选项
插入USB摄像头,lsusb 可见:(摄像头PID:VID视你插入的USB摄像头型号而定)
`Bus 001 Device 003: ID 1908:2311 GEMBIRD`
在dev下可见video0 设备。
## fswebcam
fswebcam可以用来抓取摄像头图片。可以通过apt-get直接安装。
`fswebcam -d /dev/video0 --no-banner -r 320x240 capture.jpg`
抓取一帧图片。
~~~
root@LicheePi:~# 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.
~~~
## mjpeg-streamer
前置软件:
~~~
sudo apt-get update
sudo apt-get install g++ libjpeg62-turbo-dev imagemagick libv4l-dev cmake git
~~~
~~~
sudo git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
make all
sudo make install
~~~
设置环境变量
`export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/mjpg-streamer`
开启web服务器
`mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www" `
然后在同个局域网内的电脑的浏览器上访问 zero ip:8080即可看到图像。
~~~
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240 -y" -o "output_http.so -c "ruoyun:liufeng" -w www -p 8888" -o "output_file.so -d 1000 -f /mnt "
-i 输入
"input_uvc.so -f 10 -r 320*240 -y"
input_uvc.so:UVC输入组件
-f 10 :表示10帧
-r 320*240 :分辨率
-y :YUV格式输入(有卡顿),不加表示MJPG输入(需要摄像头支持)
-o输出
"output_http.so -c "ruoyun:liufeng" -w www -p 8888"
output_http.so :网页输出组件
-c "ruoyun:liufeng" :用户名:ruoyun 密码:liufeng
-w www : 网页输出
-p 8888 :端口 8888
"output_file.so -d 1000 -f /mnt "
output_file.so :图片输出组件
-d 1000 : 时间1S
-f /mnt :输出图片放在哪,我是开机直接把/mnu挂载到本地文件夹了
~~~
总体帮助
~~~
root@LicheePi:~# mjpg_streamer --help
-----------------------------------------------------------------------
Usage: mjpg_streamer
-i | --input "<input-plugin.so> [parameters]"
-o | --output "<output-plugin.so> [parameters]"
[-h | --help ]........: display this help
[-v | --version ].....: display version information
[-b | --background]...: fork to the background, daemon mode
-----------------------------------------------------------------------
Example #1:
To open an UVC webcam "/dev/video1" and stream it via HTTP:
mjpg_streamer -i "input_uvc.so -d /dev/video1" -o "output_http.so"
-----------------------------------------------------------------------
Example #2:
To open an UVC webcam and stream via HTTP port 8090:
mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8090"
-----------------------------------------------------------------------
Example #3:
To get help for a certain input plugin:
mjpg_streamer -i "input_uvc.so --help"
-----------------------------------------------------------------------
In case the modules (=plugins) can not be found:
* Set the default search path for the modules with:
export LD_LIBRARY_PATH=/path/to/plugins,
* or put the plugins into the "/lib/" or "/usr/lib" folder,
* or instead of just providing the plugin file name, use a complete
path and filename:
mjpg_streamer -i "/path/to/modules/input_uvc.so"
-----------------------------------------------------------------------
~~~
输入插件帮助
~~~
root@LicheePi:~# mjpg_streamer -i "input_uvc.so --help"
MJPG Streamer Version.: 2.0
---------------------------------------------------------------
Help for input plugin..: UVC webcam grabber
---------------------------------------------------------------
The following parameters can be passed to this plugin:
[-d | --device ].......: video device to open (your camera)
[-r | --resolution ]...: the resolution of the video device,
can be one of the following strings:
QQVGA QCIF CGA QVGA CIF PAL
VGA SVGA XGA HD SXGA UXGA
FHD
or a custom value like the following
example: 640x480
[-f | --fps ]..........: frames per second
(activates YUYV format, disables MJPEG)
[-q | --quality ] .....: set quality of JPEG encoding
[-m | --minimum_size ].: drop frames smaller then this limit, useful
if the webcam produces small-sized garbage frames
may happen under low light conditions
[-e | --every_frame ]..: drop all frames except numbered
[-n | --no_dynctrl ]...: do not initalize dynctrls of Linux-UVC driver
[-l | --led ]..........: switch the LED "on", "off", let it "blink" or leave
it up to the driver using the value "auto"
[-t | --tvnorm ] ......: set TV-Norm pal, ntsc or secam
[-u | --uyvy ] ........: Use UYVY format, default: MJPEG (uses more cpu power)
[-y | --yuv ] ........: Use YUV format, default: MJPEG (uses more cpu power)
[-fourcc ] ............: Use FOURCC codec 'argopt',
currently supported codecs are: RGBP
---------------------------------------------------------------
Optional parameters (may not be supported by all cameras):
[-br ].................: Set image brightness (auto or integer)
[-co ].................: Set image contrast (integer)
[-sh ].................: Set image sharpness (integer)
[-sa ].................: Set image saturation (integer)
[-cb ].................: Set color balance (auto or integer)
[-wb ].................: Set white balance (auto or integer)
[-ex ].................: Set exposure (auto, shutter-priority, aperature-priority, or integer)
[-bk ].................: Set backlight compensation (integer)
[-rot ]................: Set image rotation (0-359)
[-hf ].................: Set horizontal flip (true/false)
[-vf ].................: Set vertical flip (true/false)
[-pl ].................: Set power line filter (disabled, 50hz, 60hz, auto)
[-gain ]...............: Set gain (auto or integer)
[-cagc ]...............: Set chroma gain control (auto or integer)
---------------------------------------------------------------
input_init() return value signals to exit
~~~
输出插件帮助
~~~
root@LicheePi:~# mjpg_streamer -o "output_http.so --help"
MJPG Streamer Version.: 2.0
---------------------------------------------------------------
Help for output plugin..: HTTP output plugin
---------------------------------------------------------------
The following parameters can be passed to this plugin:
[-w | --www ]...........: folder that contains webpages in
flat hierarchy (no subfolders)
[-p | --port ]..........: TCP port for this HTTP server
[-l ] --listen ]........: Listen on Hostname / IP
[-c | --credentials ]...: ask for "username:password" on connect
[-n | --nocommands ]....: disable execution of commands
---------------------------------------------------------------
output_init() return value signals to exit
~~~
- 前言
- 荔枝派TODO任务领取
- linux使用小贴士
- 入门篇
- 板卡介绍
- 开箱指南
- 烧录启动系统
- 联网方法
- 镜像使用
- 镜像说明
- buildroot系统使用
- debian系统使用
- 外设操作
- 外设操作概览
- 低速外设
- GPIO
- GPIO模拟低速接口
- UART
- PWM
- I2C
- SPI
- 高速接口
- SDIO
- USB
- EtherNet
- DVP CSI
- MIPI CSI
- 模拟外设
- CODEC
- LRADC
- 常见设备驱动
- USB摄像头
- USB 3G/4G 网卡
- 舵机
- 开发篇
- UBOOT适配
- UBOOT编译
- UBOOT配置
- UBOOT配置屏幕分辨率
- UBOOT配置SPI启动
- Linux内核开发
- Linux内核编译
- BSP Linux内核编译.md
- Linux内核选项
- 外设驱动与设备树
- RTL8723BS驱动
- 根文件系统定制
- buildroot定制系统
- buildroot添加软件包
- openwrt定制系统
- emdebian定制系统
- camdriod开发
- camdriod编译
- 主线Uboot引导Camdriod
- 系统镜像打包
- XBOOT适配
- 荔枝运行XBOOT
- 应用篇
- 游戏机-基于EmulationStation
- 游戏机-gnuboy
- 语音识别-科大讯飞云
- GUI-QT5
- 语音识别-离线关键词识别
- 路由器-Lichee Zero
- 投稿文章
- 荔枝派Zero开箱指南
- Zero i2c oled使用指南
- zero SPI LCD使用指南
- Zero u-boot编译和使用指南
- TF WiFi使用方法
- Zero Ethernet使用指南
- Zero 移植Qt5.4.1
- ZeroSpiNorFlash启动系统制作指南
- Visio-uboot-sunxi流程
- lichee 编译踩坑记录(ilichee ZERO)
- lichee_zero_外设GPIO接口
- TF WIFI 小白编
- 从零开始LicheePi Zero的开发
- 认识Zero的硬件
- 搭建Zero的开发环境
- 主线Uboot
- 主线kernel
- BSP kernel
- BSP内核启动
- bsp内核的摄像头使用
- BSP内核中的保留内存
- uboot启动BSP内核常见错误
- BSP内核 FBTFT移植
- BSP内核启动错误及警告解决
- buildroot 根文件系统
- emdebian 根文件系统
- SPI Flash 系统编译
- sunxi-fel增加对16M 以上flash的支持
- overlayfs的使用
- jffs2系统挂载不上的常见原因
- JFFS2 文件系统简介
- uboot对spi flash的识别
- bsp内核的SPI flash启动
- Docker开发环境
- Docker 命令速查
- 基础ubuntu系统配置
- docker离线镜像
- Zero系统烧录
- dd镜像烧录
- 分区镜像烧录
- SPI Flash系统烧录
- 一键镜像烧录
- Zero外设把玩
- I2C操作
- PWM输出
- CODEC的使用
- 以太网使用指南
- GPIO操作
- 文件IO方式
- C语言接口(mmap)
- Python操作GPIO
- pinctrl-sunxi介绍
- UART操作
- 点屏
- 点屏之RGB屏
- 点屏之SPI屏 ili9341
- 点屏之SPI OLED
- 点屏之I2C OLED
- 点屏之SPI屏 ili9488
- 点屏之MCU屏
- 点屏之触摸屏驱动
- 点屏之simple-framebuffer
- 点屏之屏幕时序
- 时钟控制器CCM
- 摄像头
- BSP DVP摄像头
- BSP MIPI 摄像头
- 主线DVP摄像头
- 主线 MIPI摄像头
- SPI 操作
- 应用层开发
- 开机自启动
- Segment Fault调试
- Zero通过OTG共享PC网络
- USB摄像头使用
- 基于QT的GUI开发
- 移植tslib
- 移植QT5.9.1
- 移植QT4.8.7
- QtCreator使用
- Qt5.x移植到Qt4.8
- Qt字体相关
- Qt移植总结
- Qt裁剪
- Qt去除鼠标指针显示
- zero_imager使用
- 驱动开发
- 设备树简介
- GPU/DRM 显示驱动
- sys下设备树查看
- atmel触摸屏驱动分析
- atmel触摸屏中断改轮询
- uboot下gpio操作
- helloworld驱动编译演示
- FBTFT分析
- 内核模块静态加载的顺序
- SPI驱动分析
- SPI 驱动编写
- Uboot开发
- 开机logo
- 看门狗的使用
- 关于系统reboot
- 内核printk等级设置