V4l2-ctl

news/2025/3/29 1:44:09/

1 v4l-utils

v4l-utils是一种用于处理媒体设备的软件包,它主要包含两个常用工具1:

  1. media-ctl:用于配置拓扑结构中各节点的format、大小、链接;操作/dev/medio0节点;获取Camera支持数据格式等。
  2. v4l2-ctl:用于获取和设置v4l2设备的参数。

它托管在[ v4l-utils.git ]中,并打包在大多数发行版中。提供了一系列库和实用程序,可用于控制板

l-utils还包含其他一些实用程序和库,用于处理视频4 Linux(V4L)设备驱动程序和相关功能。

以下是v4l-utils中一些常用工具的简要说明:

  1. v4l2-ctl:用于控制和配置V4L2设备的功能和参数。它可以设置图像分辨率、帧率、缩放、旋转等参数,以及控制摄像头的基本设置。
  2. v4l2-overlay:用于在屏幕上叠加图像或文本,以提供对图像的注释或标记。它可以将自定义的图像或文本叠加在视频流上,并支持透明度和位置调整。
  3. v4l2-format:用于查询和设置设备图像格式的实用程序。它可以列出设备支持的所有图像格式,并选择要使用的特定格式。
  4. v4l2-capture:用于捕获视频帧的实用程序。它可以读取设备缓存中的视频帧,并将其保存为图像文件或进行其他处理。
  5. v4l2-zoom:用于缩放视频图像的实用程序。它可以将图像放大或缩小,同时支持平滑的缩放效果。
  6. v4l2-exposure:用于控制摄像头曝光时间的实用程序。它可以设置曝光时间、曝光补偿、手动/自动曝光模式等参数。
  7. v4l2-排查:用于排查V4L2设备问题的实用程序。它可以检查设备连接、功能和参数配置,并生成详细的错误报告。

这些工具可以单独使用,也可以与其他V4L2相关的库和应用程序一起使用,以实现更复杂的功能和操作。

这里只展开v4l2-ctl

2 v4l2-ctl

 v4l2-ctl --help 查询支持的所有命令

 v4l2-ctl --help

General/Common options:
  --all              display all information available
  -C, --get-ctrl=<ctrl>[,<ctrl>...]
                     get the value of the controls [VIDIOC_G_EXT_CTRLS]
  -c, --set-ctrl=<ctrl>=<val>[,<ctrl>=<val>...]
                     set the value of the controls [VIDIOC_S_EXT_CTRLS]
  -D, --info         show driver info [VIDIOC_QUERYCAP]
  -d, --device=<dev> use device <dev> instead of /dev/video0
                     if <dev> starts with a digit, then /dev/video<dev> is used
  -e, --out-device=<dev> use device <dev> for output streams instead of the
                     default device as set with --device
                     if <dev> starts with a digit, then /dev/video<dev> is used
  -h, --help         display this help message
  --help-all         all options
  --help-io          input/output options
  --help-misc        miscellaneous options
  --help-overlay     overlay format options
  --help-sdr         SDR format options
  --help-selection   crop/selection options
  --help-stds        standards and other video timings options
  --help-streaming   streaming options
  --help-subdev      sub-device options
  --help-tuner       tuner/modulator options
  --help-vbi         VBI format options
  --help-vidcap      video capture format options
  --help-vidout      vidout output format options
  --help-edid        edid handling options
  -k, --concise      be more concise if possible.
  -l, --list-ctrls   display all controls and their values [VIDIOC_QUERYCTRL]
  -L, --list-ctrls-menus
                     display all controls and their menus [VIDIOC_QUERYMENU]
  -r, --subset=<ctrl>[,<offset>,<size>]+
                     the subset of the N-dimensional array to get/set for control <ctrl>,
                     for every dimension an (<offset>, <size>) tuple is given.
  --list-devices     list all v4l devices
  --log-status       log the board status in the kernel log [VIDIOC_LOG_STATUS]
  --get-priority     query the current access priority [VIDIOC_G_PRIORITY]
  --set-priority=<prio>
                     set the new access priority [VIDIOC_S_PRIORITY]
                     <prio> is 1 (background), 2 (interactive) or 3 (record)
  --silent           only set the result code, do not print any messages
  --sleep=<secs>     sleep <secs>, call QUERYCAP and close the file handle
  --verbose          turn on verbose ioctl status reporting
 

 2.1 常用命令

2.1.1 v4l2-ctl --list-devices  

列出系统中所有的V4L2设备

下图2路usb摄像头

 2.1.2  v4l2-ctl -d /dev/veoxx --all

查询相机的详细信息   v4l2-ctl  -d  /dev/video11

rk3568_r:/ $ v4l2-ctl -d /dev/video11 --all
Driver Info:Driver name      : uvcvideoCard type        : USB2.0_ CAM2: USB2.0_ CAM2Bus info         : usb-fd800000.usb-1.1Driver version   : 4.19.219Capabilities     : 0x84a00001Video CaptureMetadata CaptureStreamingExtended Pix FormatDevice CapabilitiesDevice Caps      : 0x04200001Video CaptureStreamingExtended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:Width/Height      : 640/480Pixel Format      : 'YUYV'Field             : NoneBytes per Line    : 1280Size Image        : 614400Colorspace        : sRGBTransfer Function : Default (maps to sRGB)YCbCr/HSV Encoding: Default (maps to ITU-R 601)Quantization      : Default (maps to Limited Range)Flags             :
Crop Capability Video Capture:Bounds      : Left 0, Top 0, Width 640, Height 480Default     : Left 0, Top 0, Width 640, Height 480Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:Capabilities     : timeperframeFrames per second: 30.000 (30/1)Read buffers     : 0//亮度brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0//对比度contrast 0x00980901 (int)    : min=0 max=100 step=1 default=50 value=50//饱和度saturation 0x00980902 (int)    : min=0 max=100 step=1 default=64 value=64//色度hue 0x00980903 (int)    : min=-180 max=180 step=1 default=0 value=0white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1gamma 0x00980910 (int)    : min=100 max=500 step=1 default=300 value=300power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1//白平衡white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive//锐度sharpness 0x0098091b (int)    : min=0 max=100 step=1 default=55 value=55//背光补偿backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=0 value=0//自动曝光exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3exposure_absolute 0x009a0902 (int)    : min=50 max=10000 step=1 default=166 value=166 flags=inactiveexposure_auto_priority 0x009a0903 (bool)   : default=0 value=1pan_absolute 0x009a0908 (int)    : min=-57600 max=57600 step=3600 default=0 value=0tilt_absolute 0x009a0909 (int)    : min=-43200 max=43200 step=3600 default=0 value=0//变焦zoom_absolute 0x009a090d (int)    : min=0 max=3 step=1 default=0 value=0

2.1.3 查询指定格式下各种分辨率支持

v4l2-ctl --list-framesizes=MJPG -d /dev/video11

 2.1.4 查看usb摄像头所有可用的分辨率 

v4l2-ctl --list-formats-ext --device /dev/video11

列出了 yuyv /mpeg 支持的多有分辨率 及帧率等

v4l2-ctl --list-formats-ext --device /dev/video11
ioctl: VIDIOC_ENUM_FMTIndex       : 0Type        : Video CapturePixel Format: 'YUYV'Name        : YUYV 4:2:2Size: Discrete 640x480Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 800x600Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1024x768Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x720Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x960Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1600x1304Interval: Discrete 0.200s (5.000 fps)Index       : 1Type        : Video CapturePixel Format: 'MJPG' (compressed)Name        : Motion-JPEGSize: Discrete 640x480Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 800x600Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1024x768Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x720Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x960Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1280x1024Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1600x1200Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)Size: Discrete 1600x1304Interval: Discrete 0.017s (60.000 fps)Interval: Discrete 0.033s (30.000 fps)Interval: Discrete 0.040s (25.000 fps)Interval: Discrete 0.050s (20.000 fps)Interval: Discrete 0.067s (15.000 fps)Interval: Discrete 0.100s (10.000 fps)Interval: Discrete 0.200s (5.000 fps)

 2.1.5 显示摄像头参数

 v4l2-ctl -d /dev/video11 --list-ctrls

2.2 设置相关命令

不是所有相机以下参数设置都支持,修改前先查询,在已知参数属性的基础上修改.

2.2.1 曝光模式

exposure_auto是v4l2-ctl命令中的一个参数,用于设置相机的曝光模式。

exposure_auto的取值可以是以下几种:

  1. Off:自动曝光时间调节处于禁用状态;
  2. Once:曝光时间会自动进行调整,以达到指定的目标值。当达到目标值时,自动功能将自动设为Off,并且新的参数值将应用到后续图像;
  3. Continuous:在采集图像时持续调整曝光时间。调整过程将持续,直到参数设为Once或Off为止。

v4l2-ctl -d /dev/video11 --set-ctrl exposure_auto=3

2.2.2 测试显示信息test_pattern

正常结果

 

2.2.3 增加图片亮度analogue_gain

 而此设备可能是这个参数

打开相机来试试

2.2.3 打开相机并显示

linux可用cheese 显示设备 

cheese -d /dev/video

或 GStreamer/ffmpeg。。

sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

 

2.3 使用v4l2-ctl抓帧

v4l2-ctl -d /dev/video1 --set-fmt-video=width=800,height=600,pixelformat=NV12 --stream-mmap=3 --stream-to=/sdcard/out.yuv --stream-skip=9 --stream-count=1 m-mmap=3 --stream-to=/sdcard/out.yuv --stream-skip=9 --stream-count=1

貌似不支持一次抓怕多张

for i in {1..10}; dov4l2-ctl -d /dev/video0 --set-ctrl exposure_absolute=$(($i * 10)) --get-ctrl exposure_absolute --get-fmt-video width --get-fmt-video height --get-fmt-video pixfmt --get-fmt-video field --get-fmt-video timeperframe --get-fmt-video sizeimage --get-fmt-video planes --get-fmt-video depth --get-fmt-video fcc --get-fmt-video tvnorm --get-fmt-video width --get-fmt-video height --get-fmt-video pixfmt --get-fmt-video field --get-fmt-video timeperframe --get-fmt-video sizeimage --get-fmt-video planes --get-fmt-video depth --get-fmt-video fcc --get-fmt-video tvnorm --save /path/to/image-$i.jpg
done

 

 


 

文章来源:https://blog.csdn.net/TyearLin/article/details/131726154
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ppmy.cn/news/873533.html

相关文章

水壶 - NOI Online 3

目录 题目描述 输入 输出 样例 输入数据 1 输出数据 1 提示 数据规模与约定 ---------------------------------------------------------------------------------------------- 分析 Code 题目描述 有 n个容量无穷大的水壶&#xff0c;它们从 1∼n 编号&#xff0…

前端开发调试工具推荐与技巧分享

https://blog.csdn.net/chehec2010/article/details/119804381 https://baike.baidu.com/item/XMPP/3430617?fraladdin https://juejin.cn/post/7124620523316707341 前端开发调试工具推荐与技巧分享 vscode插件 驼峰翻译助手 将中文翻译成英文变量名&#xff0c;可选择驼峰或…

ylb-接口8手机号注册

总览&#xff1a; 在web模块下的service包&#xff0c;补充短信接口&#xff08;SmsService&#xff09;&#xff1a;检查用户发送的验证码是否正确 package com.bjpowernode.front.service;public interface SmsService {/*** param phone 手机号* return true&#xff1a;发…

数学建模 插值算法

有问题 牛顿差值也有问题它们都有龙格现象&#xff0c;一般用分段插值。 插值预测要比灰色关联预测更加准确&#xff0c;灰色预测只有2次 拟合样本点要非常多&#xff0c;样本点少差值合适

Effective Java笔记(6)避免创建不必要的对象

一般来说&#xff0c;最好能重用单个对象&#xff0c;而不是在每次需要 的时候就创建一个相同功能的新对象 。 重用方式既快速&#xff0c;又流行 。 如果对象是不可变的&#xff08; immutable ) &#xff08;详见第 17 条&#xff09;&#xff0c;它就始终可以被重用 。 作为…

手机html像素,手机分辨率和网页中的PX是一回事吗?

大家好,我是IT修真院郑州分院第一期的学员胡嘉杰,一枚正直纯洁善良的WEB前端程序员。 今天给大家分享一下,修真院官网CSS任务3,深度思考中的知识点——手机分辨率和网页中的PX是一回事吗? 1.背景介绍 在我们从设计人员那里拿到网页模板时经常要按照模板的尺寸进行网页的代…

液晶屏种类

近年来手机屏幕技术层出不穷&#xff0c;早在几年前&#xff0c;手机上开始使用AMOLED和IPS屏幕&#xff0c;后来有CGS等屏幕&#xff0c;你知道iPhone 5用的什么屏吗&#xff1f;实际上iPhone 5采用的是另一种新型手机屏幕技术&#xff0c;即LTPS低温多晶硅屏&#xff0c;这么…

印度制造能助小米电视取得如小米手机业务的成功么?

在手机业务做到印度智能手机市场第一位的成绩之后&#xff0c;小米计划如法炮制与富士康合作在印度生产小米电视&#xff0c;那么小米电视能如小米手机一样在印度取得卓越的成绩么&#xff1f; 印度电视市场的现实 印度经济逐渐起飞&#xff0c;各类消费电子产品日渐受到印度用…