rv1126 v4l2-utils两大常用工具及命令实例

rv1126 v4l2-utils两大常用工具及命令实例 2023-12-19 14:45:06 1390

1. v4l2-utils工具包

v4l-utils工具是由Linux维护的V4L2开发工具包。

它提供了一套用于配置V4L2子设备属性的V4L2和媒体框架相关工具,测试V4L2设备,并提供开发库,如libv4l2等等。

v4l-utils工具包主要包含两个常用工具,分别是media-ctl、v4l2-ctl

2. media-ctl

media-ctl是v4l2-utils包中的一个工具,主要用来查看、配置Media Framework的各Entity的信息,如格式、裁剪、链接使能等。

2.1显示拓扑结构

命令:

media-ctl -p -d /dev/media0

结果:

[root@RV1126_RV1109:/]# media-ctl -p -d /dev/media0
Media controller API version 4.19.111

Media device information
------------------------
driver          rkcif
model           rkcif_mipi_lvds
serial
bus info
hw revision     0x0
driver version  4.19.111

Device topology
- entity 1: stream_cif_mipi_id0 (1 pad, 4 links)
            type Node subtype V4L flags 0
            device node name /dev/video0
        pad0: Sink
                <- "rockchip-mipi-csi2":1 [ENABLED]
                <- "rockchip-mipi-csi2":2 []
                <- "rockchip-mipi-csi2":3 []
                <- "rockchip-mipi-csi2":4 []

- entity 5: stream_cif_mipi_id1 (1 pad, 4 links)
            type Node subtype V4L flags 0
            device node name /dev/video1
        pad0: Sink
                <- "rockchip-mipi-csi2":1 []
                <- "rockchip-mipi-csi2":2 [ENABLED]
                <- "rockchip-mipi-csi2":3 []
                <- "rockchip-mipi-csi2":4 []

- entity 9: stream_cif_mipi_id2 (1 pad, 4 links)
            type Node subtype V4L flags 0
            device node name /dev/video2
        pad0: Sink
                <- "rockchip-mipi-csi2":1 []
                <- "rockchip-mipi-csi2":2 []
                <- "rockchip-mipi-csi2":3 [ENABLED]
                <- "rockchip-mipi-csi2":4 []

- entity 13: stream_cif_mipi_id3 (1 pad, 4 links)
             type Node subtype V4L flags 0
             device node name /dev/video3
        pad0: Sink
                <- "rockchip-mipi-csi2":1 []
                <- "rockchip-mipi-csi2":2 []
                <- "rockchip-mipi-csi2":3 []
                <- "rockchip-mipi-csi2":4 [ENABLED]

- entity 17: rockchip-mipi-csi2 (5 pads, 17 links)
             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev1
        pad0: Sink
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                <- "rockchip-mipi-dphy-rx":1 [ENABLED]
        pad1: Source
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                -> "stream_cif_mipi_id0":0 [ENABLED]
                -> "stream_cif_mipi_id1":0 []
                -> "stream_cif_mipi_id2":0 []
                -> "stream_cif_mipi_id3":0 []
        pad2: Source
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                -> "stream_cif_mipi_id0":0 []
                -> "stream_cif_mipi_id1":0 [ENABLED]
                -> "stream_cif_mipi_id2":0 []
                -> "stream_cif_mipi_id3":0 []
        pad3: Source
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                -> "stream_cif_mipi_id0":0 []
                -> "stream_cif_mipi_id1":0 []
                -> "stream_cif_mipi_id2":0 [ENABLED]
                -> "stream_cif_mipi_id3":0 []
        pad4: Source
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                -> "stream_cif_mipi_id0":0 []
                -> "stream_cif_mipi_id1":0 []
                -> "stream_cif_mipi_id2":0 []
                -> "stream_cif_mipi_id3":0 [ENABLED]

- entity 23: rockchip-mipi-dphy-rx (2 pads, 2 links)
             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev2
        pad0: Sink
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                <- "m01_b_ov13850 1-0010":0 [ENABLED]
        pad1: Source
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                -> "rockchip-mipi-csi2":0 [ENABLED]

- entity 28: rkcif-mipi-luma (0 pad, 0 link)
             type Node subtype V4L flags 0
             device node name /dev/video4

- entity 31: m01_b_ov13850 1-0010 (1 pad, 1 link)
             type V4L2 subdev subtype Sensor flags 0
             device node name /dev/v4l-subdev3
        pad0: Source
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                -> "rockchip-mipi-dphy-rx":0 [ENABLED]

- entity 35: m00_b_vm149c 1-000c (0 pad, 0 link)
             type V4L2 subdev subtype Lens flags 0
             device node name /dev/v4l-subdev4

[root@RV1126_RV1109:/]#

从 entity31 信息中可以看到:

  • 该Entity完整的名称是:m01_b_ov13850 1-0010
  • 它是一个V4L2 subdev(Sub-Device) Sensor
  • 它对应的节点是/dev/v4l-subdev3,应用程序(如v4l2-ctl)可以打开它,并进行配置
  • 它仅有一个输出(Source)节点,记为pad0
  • 它的输出格式是[fmt:SBGGR10_1X10/2112x1568],其中SBGGR10是一种mbus-code的简称
  • 它的pad0:Source 链接到”rockchip-mipi-dphy-rx”的pad0,并且当前的状态是 ENABLED。

拓扑图如下:

2.2找到设备的video节点

拓扑结构中有多个的Entity,一些是sub device,一些是video device。前者对应的设备节点是/dev/v4l-subdev,后者对应的是/dev/video。多个的video device中,最常关注的是哪个设备可以输出图像。

命令:

media-ctl -d /dev/media0 -e "stream_cif_mipi_id0"

结果:

[root@RV1126_RV1109:/]# media-ctl -d /dev/media0 -e "stream_cif_mipi_id0"
/dev/video0
[root@RV1126_RV1109:/]#

3. v4l2-ctl

V4l2-ctl 工具则是针对/dev/video0,/dev/video1 等 video设备,它在 video 设备上进行 set_fmt,reqbuf(申请buf),qbuf(送buf回队列),dqbuf(从队列取出buf),stream_on,stream_off 等一系列操作。

v4l2-ctl的帮助信息查看:

[root@RV1126_RV1109:/]# v4l2-ctl -h

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-meta        metadata format 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.
  -w, --wrapper      use the libv4l2 wrapper library.
  --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
[root@RV1126_RV1109:/]#

官方网站

3.1列出所有设备

命令:

v4l2-ctl --list-devices

结果:

[root@RV1126_RV1109:/]# v4l2-ctl --list-devices
rkisp-statistics (platform: rkisp):
        /dev/video14
        /dev/video15
        /dev/video16

rkispp_input_params (platform: rkispp):
        /dev/video23
        /dev/video24

rkcif (platform:rkcif_mipi_lvds):
        /dev/video0
        /dev/video1
        /dev/video2
        /dev/video3
        /dev/video4

rkisp_mainpath (platform:rkisp-vir0):
        /dev/video5
        /dev/video6
        /dev/video7
        /dev/video8
        /dev/video9
        /dev/video10
        /dev/video11
        /dev/video12
        /dev/video13

rkispp_input_image (platform:rkispp-vir0):
        /dev/video17
        /dev/video18
        /dev/video19
        /dev/video20
        /dev/video21
        /dev/video22

[root@RV1126_RV1109:/]#

3.2获取指定设备的所有信息

命令:

v4l2-ctl --all --device /dev/video0

或者

v4l2-ctl --all -d /dev/video0

结果:

[root@RV1126_RV1109:/]# v4l2-ctl --all --device /dev/video0
Driver Info:
        Driver name      : rkcif
        Card type        : rkcif
        Bus info         : platform:rkcif_mipi_lvds
        Driver version   : 4.19.111
        Capabilities     : 0x84201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : rkcif
        Model            : rkcif_mipi_lvds
        Serial           :
        Bus info         :
        Media version    : 4.19.111
        Hardware revision: 0x00000000 (0)
        Driver version   : 4.19.111
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : stream_cif_mipi_id0
        Function         : V4L2 I/O
        Pad 0x01000004   : 0: Sink
          Link 0x02000024: from remote pad 0x1000013 of entity 'rockchip-mipi-csi2': Data, Enabled
          Link 0x0200002c: from remote pad 0x1000014 of entity 'rockchip-mipi-csi2': Data
          Link 0x02000034: from remote pad 0x1000015 of entity 'rockchip-mipi-csi2': Data
          Link 0x0200003c: from remote pad 0x1000016 of entity 'rockchip-mipi-csi2': Data
Priority: 2
Format Video Capture Multiplanar:
        Width/Height      : 640/480
        Pixel Format      : 'NV12' (Y/CbCr 4:2:0)
        Field             : None
        Number of planes  : 1
        Flags             :
        Colorspace        : Default
        Transfer Function : Default
        YCbCr/HSV Encoding: Default
        Quantization      : Default
        Plane 0           :
           Bytes per Line : 640
           Size Image     : 460800
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 2112, Height 1568
        Default     : Left 0, Top 0, Width 2112, Height 1568
        Pixel Aspect: 1/1
Crop Capability Video Output:
        Bounds      : Left 0, Top 0, Width 0, Height 0
        Default     : Left 0, Top 0, Width 0, Height 0
        Pixel Aspect: 1/1
Crop: Left 0, Top 0, Width 640, Height 480
Selection: crop, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_default, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_padded, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: native_size, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: crop, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_default, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: compose_padded, Left 0, Top 0, Width 2112, Height 1568, Flags:
Selection: native_size, Left 0, Top 0, Width 2112, Height 1568, Flags:

User Controls

                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1536

Camera Controls

                 focus_absolute 0x009a090a (int)    : min=0 max=64 step=1 default=64 value=64

Image Source Controls

              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=120000000 step=1 default=120000000 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
[root@RV1126_RV1109:/]#

3.3获取指定设备的预览支持格式

命令:

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

或者

v4l2-ctl --list-formats-ext -d /dev/video0

结果:

[root@RV1126_RV1109:/]# v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'NV16' (Y/CbCr 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [1]: 'NV61' (Y/CrCb 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [2]: 'NV12' (Y/CbCr 4:2:0)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [3]: 'NV21' (Y/CrCb 4:2:0)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [4]: 'YUYV' (YUYV 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [5]: 'YVYU' (YVYU 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [6]: 'UYVY' (UYVY 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [7]: 'VYUY' (VYUY 4:2:2)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [8]: 'RGB3' (24-bit RGB 8-8-8)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [9]: 'RGBP' (16-bit RGB 5-6-5)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [10]: 'BGRH' (18-bit BGRX 6-6-6-14)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [11]: 'RGGB' (8-bit Bayer RGRG/GBGB)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [12]: 'GRBG' (8-bit Bayer GRGR/BGBG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [13]: 'GBRG' (8-bit Bayer GBGB/RGRG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [14]: 'BA81' (8-bit Bayer BGBG/GRGR)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [15]: 'RG10' (10-bit Bayer RGRG/GBGB)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [16]: 'BA10' (10-bit Bayer GRGR/BGBG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [17]: 'GB10' (10-bit Bayer GBGB/RGRG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [18]: 'BG10' (10-bit Bayer BGBG/GRGR)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [19]: 'RG12' (12-bit Bayer RGRG/GBGB)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [20]: 'BA12' (12-bit Bayer GRGR/BGBG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [21]: 'GB12' (12-bit Bayer GBGB/RGRG)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [22]: 'BG12' (12-bit Bayer BGBG/GRGR)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [23]: 'BYR2' (16-bit Bayer BGBG/GRGR)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [24]: 'Y16 ' (16-bit Greyscale)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
        [25]: 'GREY' (8-bit Greyscale)
                Size: Stepwise 64x64 - 2112x1568 with step 8/8
[root@RV1126_RV1109:/]#

3.4获取摄像头参数

命令:

v4l2-ctl --list-ctrls --device /dev/video0

或者

v4l2-ctl -d /dev/video0 -l

结果:

[root@RV1126_RV1109:/]# v4l2-ctl -d /dev/video0 -l

User Controls

                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1536

Camera Controls

                 focus_absolute 0x009a090a (int)    : min=0 max=64 step=1 default=64 value=64

Image Source Controls

              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=120000000 step=1 default=120000000 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
[root@RV1126_RV1109:/]#

3.5增加曝光exposure

exposure值的区间从摄像头参数里面的MIN和MAX看,如上面显示信息,区间为: 4-1660

命令:

v4l2-ctl -d /dev/video0 --set-ctrl exposure=1660

结果:

[root@RV1126_RV1109:/]# v4l2-ctl -d /dev/video0 --set-ctrl exposure=3324
[root@RV1126_RV1109:/]# v4l2-ctl -d /dev/video0 -l

User Controls

                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1660

Camera Controls

                 focus_absolute 0x009a090a (int)    : min=0 max=64 step=1 default=64 value=64

Image Source Controls

              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=120000000 step=1 default=120000000 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
[root@RV1126_RV1109:/]#

exposure后面的value值改变了。

3.6增加图片亮度analogue_gain

analogue_gain用于设置显示的图像的亮度,值的范围也是从摄像头参数里面看,从摄像头参数看区间为:16-248

命令:

v4l2-ctl -d /dev/video1 --set-ctrl analogue_gain=240

结果:

[root@RV1126_RV1109:/]# v4l2-ctl -d /dev/video0 --set-ctrl analogue_gain=240
[root@RV1126_RV1109:/]# v4l2-ctl -d /dev/video0 -l

User Controls

                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1660

Camera Controls

                 focus_absolute 0x009a090a (int)    : min=0 max=64 step=1 default=64 value=64

Image Source Controls

              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=240

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=120000000 step=1 default=120000000 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
[root@RV1126_RV1109:/]#

analogue_gain=16 现象 :

analogue_gain=240 现象 :

3.7查看滤光器状态及控制滤光器开关

3.7.1查看滤光器状态

命令:

v4l2-ctl -d /dev/v4l-subdev4 --get-ctrl band_stop_filter

结果:

[root@RV1126_RV1109:/userdata]# v4l2-ctl -d /dev/v4l-subdev4 --get-ctrl band_stop_filter
band_stop_filter: 1

3.7.2控制滤光器开关

打开命令:

v4l2-ctl -d /dev/v4l-subdev4 --set-ctrl 'band_stop_filter=1'

关闭命令:

v4l2-ctl -d /dev/v4l-subdev4 --set-ctrl 'band_stop_filter=0'

3.8抓取yuv帧

命令:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=NV12 --stream-mmap=3 --stream-to=./test-rv1126-4.yuv --stream-count=10 --stream-poll

结果:

[root@RV1126_RV1109:/userdata/share/rv1126-test/rkmedia-test]# v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=NV12 --stream-mm
ap=3 --stream-to=./test-rv1126-4.yuv --stream-count=10 --stream-poll
<<<<<<<<<<
[root@RV1126_RV1109:/userdata/share/rv1126-test/rkmedia-test]#

参数说明:

-d: 摄像头对应设备文件
--set-fmt-video:指定了宽高及pxielformat(用FourCC表示)。NV12即用FourCC表示的pixelformat
--stream-mmap:指定buffer的类型为mmap,即由kernel分配的物理连续的或经过iommu映射的buffer
--stream-to:指定帧数据保存的文件路径
--stream-skip:指定丢弃(不保存到文件)前3--stream-count:指定抓取的帧数,不包括--stream-skip丢弃的数量

其他参数
--set-selection,指定对输入图像进行裁剪。特别是当RKISP1的前级大小发生变化时要保证selection不大于前级输出大小。RKCIF的裁剪则是通过--set-crop参数设置的
--stream-poll,该选项指示v4l2-ctl采用异步IO,即在dqbuf前先用select等等帧数据完成,从而保证dqbuf不阻塞。否则dqbuf将会阻塞直到有数据帧到来

用ffmpeg播放抓取的yuv文件或者直接用pc的工具打开yuv文件,ffplay的命令:

ffplay out.yuv -f rawvideo -pixel_format nv12 -video_size 800x600

3.9测试显示信息test_pattern

参数test_pattern,可以用于切换摄像头的测试用的显示图像

  • 0:摄像头
  • 1-3 测试图片 命令实例:

命令:

v4l2-ctl -d /dev/video0 --set-ctrl test_pattern=0

不同值对应的测试图像:
test_pattern = 1 :

test_pattern = 2 :

test_pattern = 3 :

3.9获取摄像头捕获视频格式

命令:

v4l2-ctl -d /dev/video0 -V

结果:

[root@RV1126_RV1109:/userdata/share/rv1126-test/rkmedia-test]# v4l2-ctl -d /dev/video0 -V
Format Video Capture Multiplanar:
        Width/Height      : 1920/1080
        Pixel Format      : 'NV12' (Y/CbCr 4:2:0)
        Field             : None
        Number of planes  : 1
        Flags             :
        Colorspace        : Default
        Transfer Function : Default
        YCbCr/HSV Encoding: Default
        Quantization      : Default
        Plane 0           :
           Bytes per Line : 1920
           Size Image     : 3110400
[root@RV1126_RV1109:/userdata/share/rv1126-test/rkmedia-test]#
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包 3 1 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区