基于 Linux V4L2 子系统进行图像采集,需要遵循一定的流程规范,操作起来也不算简单。如果只是作为测试、调试使用,yavta 工具就很好使了。它支持很多常规的操作选项,可以按需配置使用。
其源代码也是挺简洁紧凑的,以后再找时间好好阅读学习下。这里主要是讲解这个工具基于创龙 TL570x-EVM 的编译与使用。
工具项目地址:http://git.ideasonboard.org/yavta.git
假定 PC 已经安装好 am57x 的 SDK 开发环境。当然,如果是要直接在 PC 编译 x86 版本,下载源码后直接执行 make 即可,将生成 yavta 可执行程序。
下载源码:git clone git://git.ideasonboard.org/yavta.git
初始化编译环境:source ~/am5728/ti-processor-sdk-linux-am57xx-evm-03.01.00.06/linux-devkit/environment-setup
修改 Makefile:
CROSS_COMPILE ?=arm-linux-gnueabihf- # 配置交叉工具链
CFLAGS = -O2 -W -Wall -Iinclude # 去掉问号 ?
执行编译:make
生成的可执行文件 yavta 放到开发板,执行 -h 选项试试运行情况。
./yavta -h
执行采集一帧图像(在 TL570x-EVM 中需要先加载对应 dtbo 生成 /dev/video1 设备节点):
./yavta /dev/video1 -c1 -n4 -s1920x1080 -fSRGGB10 -Fvideo.raw
Usage: ./yavta [options] device
Supported options:
-B, --buffer-type Buffer type ("capture", "output",
"capture-mplane" or "output-mplane")
-c, --capture[=nframes] Capture frames
-C, --check-overrun Verify dequeued frames for buffer overrun
-d, --delay Delay (in ms) before requeuing buffers
-f, --format format Set the video format
use -f help to list the supported formats
-F, --file[=name] Read/write frames from/to disk
For video capture devices, the first '#' character in the file name is
expanded to the frame sequence number. The default file name is
'frame-#.bin'.
-h, --help Show this help screen
-i, --input input Select the video input
-I, --fill-frames Fill frames with check pattern before queuing them
-l, --list-controls List available controls
-n, --nbufs n Set the number of video buffers
-p, --pause Pause before starting the video stream
-q, --quality n MJPEG quality (0-100)
-r, --get-control ctrl Get control 'ctrl'
-R, --realtime=[priority] Enable realtime RR scheduling
-s, --size WxH Set the frame size
-t, --time-per-frame num/denom Set the time per frame (eg. 1/25 = 25 fps)
-u, --userptr Use the user pointers streaming method
-w, --set-control 'ctrl value' Set control 'ctrl' to 'value'
--buffer-prefix Write portions of buffer before data_offset
--buffer-size Buffer size in bytes
--enum-formats Enumerate formats
--enum-inputs Enumerate inputs
--fd Use a numeric file descriptor insted of a device
--field Interlaced format field order
--log-status Log device status
--no-query Don't query capabilities on open
--offset User pointer buffer offset from page start
--premultiplied Color components are premultiplied by alpha value
--queue-late Queue buffers after streamon, not before
--requeue-last Requeue the last buffers before streamoff
--timestamp-source Set timestamp source on output buffers [eof, soe]
--skip n Skip the first n frames
--sleep-forever Sleep forever after configuring the device
--stride value Line stride in bytes