Difference between revisions of "GX series camera appnotes 4 jetson"

From wiki_veye
Jump to navigation Jump to search
 
(35 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[https://wiki.veye.cc/index.php/GX_series_camera_appnotes_4_jetson/zh 中文]
+
[[GX series camera appnotes 4 jetson/zh|查看中文]]
  
 
===overview===
 
===overview===
The GX series cameras are designed for embedded AI applications, featuring outstanding ISP performance, multiple working modes, a wealth of functional options, and reliable stability design. They use the MIPI CSI-2 interface and are particularly suitable for embedded computing platforms.  
+
The GX series cameras are designed for embedded AI applications. They offer high-performance ISP capabilities, support multiple operating modes, provide a wide range of configurable features, and are built with a robust and reliable design. The cameras use the MIPI CSI-2 interface and are well suited for embedded computing platforms.  
  
 
This article introduces how to use GX series cameras on the NVIDIA Jetson platform.
 
This article introduces how to use GX series cameras on the NVIDIA Jetson platform.
Line 14: Line 14:
 
|GX Series
 
|GX Series
 
|GX-MIPI-IMX662
 
|GX-MIPI-IMX662
|complete
+
|Done
 
|}
 
|}
 
====Supported Jetson Board====
 
====Supported Jetson Board====
Line 21: Line 21:
 
!status
 
!status
 
|-
 
|-
|XAVIER NX
+
|Xavier NX
|complete
+
|Done
 
|-
 
|-
 
|Orin NX
 
|Orin NX
|complete
+
|Done
 
|-
 
|-
 
|Orin Nano
 
|Orin Nano
|complete
+
|Done
 
|}
 
|}
  
Line 53: Line 53:
 
!FFC line
 
!FFC line
 
!Number of cameras
 
!Number of cameras
!Additional power supply
+
!Power supply
 
|-
 
|-
 
| rowspan="2" |GX Series
 
| rowspan="2" |GX Series
|XAVIER NX
+
|Xavier NX
|15-pin to 22-pin face-to-face FFC conversion connector
+
|15‑pin to 22‑pin FFC (same-side contacts)
 
|2
 
|2
|5V DC (must be provided)
+
|5V DC (required)
 
|-
 
|-
|Orin Nano
+
|Orin Nano,Orin NX
Orin NX
+
|22‑pin FFC (opposite-side contacts)
|22-pin oblique FFC
 
 
|2
 
|2
|5V DC (must be provided)
+
|5V DC (required)
 
|}
 
|}
 
=====GX camera connected to Xavier NX=====
 
=====GX camera connected to Xavier NX=====
TBD<br />
+
<br />[[File:Gx to jetson xavier nx .png|center|thumb|800x800px|GX Camera to Xavier NX]]
 +
<br />
 
=====The GX camera is connected to Orin Nano or Orin NX.=====
 
=====The GX camera is connected to Orin Nano or Orin NX.=====
TBD<br />
+
<br />[[File:Gx to jetson orin.png|center|thumb|800x800px|GX camera to Orin NX/Nano]]
 +
<br />
 
===Update the Jetson system===
 
===Update the Jetson system===
 
This section describes how to update the L4T system of Jetson to support the GX camera module. For the method of operating system update, please refer to the update instructions for [https://wiki.veye.cc/index.php/How_to_upgrade_the_Jetson_system_to_support_VEYE_cameras/zh Jetson operating system].  
 
This section describes how to update the L4T system of Jetson to support the GX camera module. For the method of operating system update, please refer to the update instructions for [https://wiki.veye.cc/index.php/How_to_upgrade_the_Jetson_system_to_support_VEYE_cameras/zh Jetson operating system].  
  
In particular, if you need the external trigger function, you need to apply a patch to the original kernel of Jetson - veye_mv_l4t_<version>.patch.  
+
Specifically, if trigger functionality is required, the Jetson kernel needs to be patched using '''veye_mv_l4t_<version>.patch'''.
  
This patch has two functions:
+
This patch provides the following features:
  
# Added support for two data formats, Y10 and Y12, for black-and-white cameras.  
+
#Adds support for monochrome camera data formats '''Y10''' and '''Y12'''.
# Added support for the trigger mode.
+
#Adds support for '''trigger mode'''.
  
===Support for the Trigger mode===
+
===Support for Trigger Mode ===
The default driver of the Jetson system only supports video streaming mode. In its VI driver, the data reception function has a timeout mechanism. We have added a configurable option named "vi_time_out_disable" which allows for dynamically enabling or disabling this timeout mechanism.  
+
The default Jetson drivers support only video streaming mode. In the VI driver, data reception includes a timeout mechanism.
  
For specific applications, please refer to the following application examples.
+
We have added a configurable option, '''vi_time_out_disable''', which allows this timeout mechanism to be dynamically enabled or disabled.
  
===System status monitoring===
+
For practical usage, please refer to the example applications provided below.
After completing the system update, restart the Jetson motherboard.  
 
  
During the startup process of the Jetson system, it will check whether there are any cameras on all i2c buses. If there are, it will create a /dev/videoX device node.  
+
===System Status Check ===
 +
After completing the system update, reboot the Jetson board.
  
Execute the following commands on the Jetson board to check if the camera is properly connected.
+
During the boot process, the Jetson system will detect any cameras connected to the I²C buses. If a camera is found, the corresponding '''/dev/videoX''' device node will be created.
 +
 
 +
To verify that the camera is correctly connected, run the following command on the Jetson board:
  
 
<code>dmesg | grep gxcam</code>
 
<code>dmesg | grep gxcam</code>
  
It can be seen that during the Linux startup process, the camera model and version number that were probed are as follows:
+
The output will display the camera model and version detected during Linux boot.
  
For example, the following prompt indicates that a GX-MIPI-IMX662 camera has been detected on the i2c-9 bus.
+
For example, the following message indicates that a '''GX-MIPI-IMX662''' camera was detected on '''i2c-9''':
  
 
<code>gxcam 9-003b: camera is: GX-MIPI-IMX662</code>
 
<code>gxcam 9-003b: camera is: GX-MIPI-IMX662</code>
===状态检测并配置环境变量===
 
在这里,我们提供了两个脚本,可以自动检索相机的一些信息。
 
  
====probe_camera_info-jetson.sh====
+
===Status Check and Environment Variable Configuration===
该脚本用于探测已连接并成功注册的摄像头设备,检索设备对应的媒体设备节点、视频设备节点、子设备节点、I²C 总线及设备名称等底层信息。
+
[https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/gx_i2c_tools Here], we provide two scripts that can automatically retrieve key information about the connected camera.
 +
 
 +
====probe_camera_info-jetson.sh ====
 +
This script probes connected and successfully probed camera devices, retrieving information such as the video device node and I²C bus.
  
执行后,将在当前目录生成 <code>auto_camera_index.json</code> 文件并在文件中记录检索到的信息。
+
After execution, an '''auto_camera_index.json''' file will be generated in the current directory, containing the retrieved information.
  
下面是一个例子:
+
Example:
  
 
<code>$ ./probe_camera_info-jetson.sh</code>
 
<code>$ ./probe_camera_info-jetson.sh</code>
Line 120: Line 124:
 
<code>]</code>
 
<code>]</code>
  
{}内是一个摄像头的信息,如果主板支持多个摄像头模组,则会出现多组{}包含的内容。
+
Each <code>{}</code> block represents one camera. If the board supports multiple camera modules, multiple <code>{}</code> blocks will appear in the file.
  
摄像头信息解释如下:
+
The explanation of the camera information is as follows:
 
{| class="wikitable"
 
{| class="wikitable"
|+摄像头信息
+
|+Camera Information
!代称
+
!Field
!名称
+
!Name
!作用
+
!Purpose
!何处使用
+
!Usage
 
|-
 
|-
 
|video_node
 
|video_node
|视频设备节点(Video capture device node)
+
|Video capture device node
|典型 V4L2 视频设备
+
|Standard V4L2 video device
|v4l2-ctl或者客户开发的程序,获取图像时使用
+
|Used with <code>v4l2-ctl</code> or customer applications to capture images,and configuring certain camera parameters.
 
|-
 
|-
 
|i2c_bus
 
|i2c_bus
|I²C 总线号
+
|I²C bus
|表示设备连接的 I²C 总线编号
+
|Indicates the I²C bus to which the device is connected
|对摄像头进行参数配置的底层通信信道,gx_mipi_i2c.sh脚本使用
+
|Used as the underlying communication channel for camera parameter configuration, e.g., by the <code>gx_mipi_i2c.sh</code> script
 
|}
 
|}
后文中使用的媒体设备节点、视频设备节点、子设备节点、I²C 总线及设备名称,均可参考此探测脚本得到的json文件中的信息进行替换。
 
 
摄像头模组在Jetson系统中映射为/dev/videoX设备节点。
 
  
操作系统启动过程中,按照i2c bus从小到大的顺序探测摄像头。X值是按照探测的逻辑顺序从0开始递增的。
+
*The video device nodes and I²C bus numbers used in the following sections can be replaced with the corresponding information obtained from the JSON file generated by the '''probe_camera_info-jetson.sh''' script.
 +
*On the Jetson system, each camera module is mapped to a <code>/dev/videoX</code> device node.
 +
*During system startup, cameras are probed in ascending order of their I²C bus numbers. The <code>X</code> in <code>/dev/videoX</code> is assigned sequentially starting from 0 according to the probing order.
 +
**For example, if only one camera is connected, <code>X</code> will be 0 regardless of which I²C port the hardware is attached to.
 +
**If five cameras are connected, <code>X</code> values will be <code>[0-4]</code>, ordered by ascending I²C bus numbers.
 +
*In <code>v4l2-ctl</code> commands, the <code>-d /dev/videoX</code> option is used to access different cameras.
  
举例说,如果只接入一个摄像头,无论硬件连接到哪个位置,X都为0。如果接入5个,则按照i2c bus从小到大,X为[0-4]。
+
*In GStreamer, <code>v4l2src</code> can access different cameras by specifying <code>device=/dev/videoX</code>.
  
v4l2-ctl命令中,使用<code>-d /dev/videoX</code>来访问不同的摄像头。
 
 
gstreamer中,v4l2src可以通过指明<code>device=/dev/videoX</code>来访问不同的摄像头。
 
 
====gx_probe.sh====
 
====gx_probe.sh====
使用<code>gx_probe.sh</code>脚本,可以将某一个相机对应的I²C总线编号、相机型号、宽、高、帧率等信息配置到环境变量中。
+
By using the <code>gx_probe.sh</code> script, the I²C bus number corresponding to a certain camera, the camera model, width, height, frame rate, etc. can be configured into the environment variables.
  
如此,则方便后续使用media-ctl配置格式使用起来更方便。
+
In that case, subsequent operations using v4l2-ctl will be more convenient.
  
使用方法是:
+
The usage method is:
  
 
<code>$ source ./gx_probe.sh i2c_bus</code>
 
<code>$ source ./gx_probe.sh i2c_bus</code>
  
一个典型的输出如下:
+
A typical output is as follows:
  
 
<code>$ source ./gx_probe.sh 9</code>
 
<code>$ source ./gx_probe.sh 9</code>
Line 176: Line 179:
 
<code>Setenv HEIGHT = 1080</code>
 
<code>Setenv HEIGHT = 1080</code>
  
可以通过 <code>echo $CAMERAMODEL</code>来验证环境变量的输出结果。'''注意,此环境变量只对当前会话有效。'''
+
You can verify the environment variable output using, for example:
 +
 
 +
<code>echo $CAMERAMODEL</code>
 +
 
 +
Note: These environment variables are valid only for the current shell session.
  
===实时预览===
+
===Real-time preview===
 
====veye_viewer====
 
====veye_viewer====
veye_viewer是一个开源的,基于QT5的客户端软件。
+
The <code>veye_viewer</code> is an open-source, Qt-based client application that allows users to easily evaluate cameras and configure parameters. Its operation logs, register listings, and open-source nature provide a convenient reference for users and support custom development.
  
代码以及使用请参考:https://github.com/veyeimaging/veye_viewer<nowiki/>。
+
The source code of <code>veye_viewer</code> can be downloaded [https://github.com/veyeimaging/veye_viewer here], or platform-specific executable programs are available directly in its [https://github.com/veyeimaging/veye_viewer/releases release packages].
  
国内用户可访问[https://gitee.com/veyeimaging/veye_viewer gitee仓库]。
+
====qv4l2====
====使用qv4l2预览画面====
+
First, install qv4l2
首先安装qv4l2
 
  
 
<code>sudo apt install qv4l2</code>
 
<code>sudo apt install qv4l2</code>
  
1. 在命令行中输入qv4l2以启动 V4L2 播放器。
+
1. Enter <code>qv4l2</code> in the command line to start the V4L2 player.
 +
 
 +
2. Click the ▶ (play) button to bring up the opened media window.
 +
<br />
 +
[[File:Play gx camera using qv4l2.png|center|thumb|1050x1050px|Play gx camera using qv4l2]]
  
2. 点击 ▶(播放)按钮以调出打开的媒体窗口。[[File:Mvcam via qv4l2.png|center|thumb|800x800px|Play gx camera using qv4l2|link=http://wiki.veye.cc/index.php/File:Mvcam_via_qv4l2.png]]<br />
 
 
===Gstreamer Usage===
 
===Gstreamer Usage===
要安装最新的加速版 gstreamer 插件和应用程序,请运行以下命令:
+
To install the latest accelerated version of gstreamer plugins and applications, please run the following command:
  
 
<code>sudo apt-get update</code>
 
<code>sudo apt-get update</code>
Line 206: Line 215:
 
<code>export DISPLAY=:0</code>
 
<code>export DISPLAY=:0</code>
  
*视频预览1080p HD
+
*video preview 1080p HD
  
 
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
 
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
Line 212: Line 221:
 
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nv3dsink sync=false</code>
 
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nv3dsink sync=false</code>
  
*视频预览1080p HD(using xvimagesink sink if supported)
+
*video preview 1080p HD(using xvimagesink sink if supported)
  
 
<code>export DISPLAY=:0</code>
 
<code>export DISPLAY=:0</code>
Line 218: Line 227:
 
<code>gst-launch-1.0 -e v4l2src io-mode=4 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=1920, height=1080, framerate=30/1, format=UYVY' ! xvimagesink sync=false</code>
 
<code>gst-launch-1.0 -e v4l2src io-mode=4 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=1920, height=1080, framerate=30/1, format=UYVY' ! xvimagesink sync=false</code>
  
*Gstreamer 嵌入到 OpenCV
+
*Gstreamer is embedded into OpenCV
  
 
I think maybe OpenCV do not support I420 data format input,so you should convert it to BGR format.
 
I think maybe OpenCV do not support I420 data format input,so you should convert it to BGR format.
Line 224: Line 233:
 
<code>gst-launch-1.0 nvv4l2camerasrc ! video/x-raw(memory:NVMM), format=(string)UYVY, width=(int)1920, height=(int)1080 ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)I420 !  nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink</code>
 
<code>gst-launch-1.0 nvv4l2camerasrc ! video/x-raw(memory:NVMM), format=(string)UYVY, width=(int)1920, height=(int)1080 ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)I420 !  nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink</code>
  
*视频录像1080p HD
+
*Video recording 1080p HD
  
 
<code>gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nvv4l2h264enc control-rate=1 bitrate=10000000 ! h264parse ! qtmux ! filesink location=filename.mp4 -e</code>
 
<code>gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nvv4l2h264enc control-rate=1 bitrate=10000000 ! h264parse ! qtmux ! filesink location=filename.mp4 -e</code>
  
*录像回放
+
*Playback of saved video file
  
 
<code>gst-launch-1.0 filesrc location=filename.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e</code>
 
<code>gst-launch-1.0 filesrc location=filename.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e</code>
  
*抓拍图片
+
*Capturing FHD still image  
  
 
<code>gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvjpegenc ! filesink location=jpgname.jpg</code>
 
<code>gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvjpegenc ! filesink location=jpgname.jpg</code>
===yavta(仅支持流模式)===
+
===yavta(Only supports streaming mode)===
  
=====yavta安装=====
+
====yavta install====
 
<code>git clone <nowiki>https://github.com/veyeimaging/yavta.git</nowiki></code>
 
<code>git clone <nowiki>https://github.com/veyeimaging/yavta.git</nowiki></code>
  
 
<code>cd yavta;make</code>
 
<code>cd yavta;make</code>
  
国内用户可访问[https://gitee.com/veyeimaging/yavta gitee仓库]。
+
====Set image format====
 
+
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY</code>
=====设置图像格式=====
+
====Save the image to a file====
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY</code>
 
=====保存图片到文件=====
 
 
 
======通常情况下======
 
此处的通常情况,指的是WIDTH是256的整数倍。
 
  
*UYVY格式
+
*UYVY type
 
 
以XAVIER平台为例
 
  
 
<code>./yavta -c1 -F"uyvy-${WIDTH}x${HEIGHT}.yuv" --skip 0 -f UYVY -s "${WIDTH}x${HEIGHT}" /dev/video0</code>
 
<code>./yavta -c1 -F"uyvy-${WIDTH}x${HEIGHT}.yuv" --skip 0 -f UYVY -s "${WIDTH}x${HEIGHT}" /dev/video0</code>
  
======GX-MIPI-IMX662======
+
*GX-MIPI-IMX662
  
 
<code>./yavta -c1 -Fuyvy-1920x1080.yuv --skip 0 -f UYVY -s 1920x1080 /dev/video0</code>
 
<code>./yavta -c1 -Fuyvy-1920x1080.yuv --skip 0 -f UYVY -s 1920x1080 /dev/video0</code>
 
===Jetson multimedia-api samples===
 
===Jetson multimedia-api samples===
Jetson平台上提供了[https://docs.nvidia.com/jetson/l4t-multimedia/index.html Jetson Linux API] 供开发者使用。具体jetson_multimedia_api包的安装请参考nVidia官方文档。
+
On the Jetson platform, the [https://docs.nvidia.com/jetson/l4t-multimedia/index.html Jetson Linux API] is provided for developers. For installation of the '''jetson_multimedia_api''' package, please refer to the official NVIDIA documentation.
  
对于GX系列相机,已经在相机内集成了ISP功能,因此不能使用libargus获取数据,而可以直接使用使用标准V4L2接口从/dev/videoX设备文件获取数据。
+
For GX series cameras, ISP functionality is already integrated within the camera module. Therefore, '''libargus''' cannot be used to acquire data. Instead, standard V4L2 interfaces can be used to capture data directly from the <code>/dev/videoX</code> device file.
  
安装 Jetson 系统后,可进入多媒体 API 示例目录,自行编译并运行以下命令以预览摄像头视频:
+
After installing the Jetson system, you can navigate to the Multimedia API sample directory, compile, and run the following commands to preview the camera video:
  
 
<code>cd /usr/src/jetson_multimedia_api/samples/12_v4l2_camera_cuda</code>
 
<code>cd /usr/src/jetson_multimedia_api/samples/12_v4l2_camera_cuda</code>
Line 273: Line 275:
 
<code>./v4l2_camera_cuda -d /dev/video0 -s 1920x1080 -f UYVY</code>
 
<code>./v4l2_camera_cuda -d /dev/video0 -s 1920x1080 -f UYVY</code>
  
该命令将使用 <code>/dev/video0</code> 设备,以 1920×1080 分辨率和 UYVY 格式进行实时视频预览。
+
This command uses the <code>/dev/video0</code> device to perform real-time video preview at a resolution of 1920×1080 with the UYVY format.
===v4l2-ctl 应用范例===
+
 
=====安装v4l2-utils=====
+
===v4l2-ctl Examples===
 +
=====Install v4l2-utils=====
 
<code>sudo apt-get install v4l-utils</code>
 
<code>sudo apt-get install v4l-utils</code>
=====使用v4l2-ctl配置参数=====
+
=====Configure parameters using v4l2-ctl=====
  
======列出相机支持的数据格式======
+
======List the data formats supported by the camera======
 
<code>v4l2-ctl --list-formats-ext</code>
 
<code>v4l2-ctl --list-formats-ext</code>
  
下面是在XAVIER系统下,GX-MIPI-IMX662的例子:
+
Below is an example:
  
 
<code>ioctl: VIDIOC_ENUM_FMT</code>
 
<code>ioctl: VIDIOC_ENUM_FMT</code>
Line 302: Line 305:
 
<code>                        Interval: Discrete 0.017s (60.000 fps)</code>
 
<code>                        Interval: Discrete 0.017s (60.000 fps)</code>
  
*帧率统计
+
*Frame rate statistics
  
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
  
*保存图片到文件
+
*Save the image to a file
  
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=uyvy-1920x1080.yuv</code>
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=uyvy-1920x1080.yuv</code>
  
======列出驱动中实现的相机的可配置参数======
+
======List the configurable parameters of the camera implemented in the driver======
 
<code>v4l2-ctl -L</code>
 
<code>v4l2-ctl -L</code>
  
Line 325: Line 328:
 
<code>                     frame_rate 0x00981a05 (int)    : min=0 max=60 step=1 default=60 value=60 flags=volatile, execute-on-write</code>
 
<code>                     frame_rate 0x00981a05 (int)    : min=0 max=60 step=1 default=60 value=60 flags=volatile, execute-on-write</code>
  
可以使用下面的方法设置和获取参数。
+
The parameters can be set and retrieved using the following methods.
  
 
<code>v4l2-ctl --set-ctrl [ctrl_type]=[val]</code>
 
<code>v4l2-ctl --set-ctrl [ctrl_type]=[val]</code>
Line 331: Line 334:
 
<code>v4l2-ctl --get-ctrl [ctrl_type]</code>
 
<code>v4l2-ctl --get-ctrl [ctrl_type]</code>
  
以上所有功能,均可使用[https://wiki.veye.cc/index.php/Gx_mipi_i2c.sh_user_guide/zh gx_mipi_i2c.sh]实现。
+
All of the above functions can be achieved by using the [[Gx mipi i2c.sh user guide|gx_mipi_i2c.sh]] script.
  
需要指出的是,以上参数在开始取图的状态均不可修改。下面进行逐个说明:
+
It should be noted that the above parameters cannot be modified once the image capture process begins. The following will provide detailed explanations for each one:
======配置触发模式======
+
======Configure trigger mode======
 
<code>v4l2-ctl --set-ctrl <small>work_mode=[0-2]</small></code>
 
<code>v4l2-ctl --set-ctrl <small>work_mode=[0-2]</small></code>
  
0:流模式
+
0: Streaming Mode
 +
 
 +
1: Trigger Mode
  
1:普通触发模式
+
2: Multi-camera Synchronization Mode
  
2:多相机同步模式
+
======Configure trigger source======
======配置触发源======
 
 
<code>v4l2-ctl --set-ctrl <small>trigger_src=[0-1]</small></code>
 
<code>v4l2-ctl --set-ctrl <small>trigger_src=[0-1]</small></code>
  
0: 软触发
+
0: Soft Trigger
 +
 
 +
1: Hard Trigger
  
1: 硬触发
+
======Soft trigger once======
======软触发一次======
 
 
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
 
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
======设置帧率======
+
======Set frame rate======
 
<code>v4l2-ctl --set-ctrl frame_rate=[1-max]</code>
 
<code>v4l2-ctl --set-ctrl frame_rate=[1-max]</code>
  
随分辨率的调整,最大帧率会自动更新。
+
As the resolution is adjusted, the maximum frame rate will be automatically updated.
====流模式====
+
====Stream mode====
  
=====设置图像格式=====
+
=====Set image format=====
以最大画面为例:
+
Take the largest screen as an example:
  
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY</code>
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY</code>
  
 
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
 
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
=====帧率统计=====
+
=====Frame rate statistics=====
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
=====保存图片到文件=====
+
=====Save the image to a file=====
  
======通常情况下======
+
======under normal conditions======
  
 
*UYVY
 
*UYVY
  
 
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
 
<code>v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
======使用opencv预览GREY格式图像======
+
======Use OpenCV to preview camera======
 
<code>sudo apt install python3-opencv</code>
 
<code>sudo apt install python3-opencv</code>
  
*我们提供了一个简单的[https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/samples/opencv/yuv_camera sample]实现此功能:
+
*We have provided a simple [https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/samples/opencv/yuv_camera sample] to demonstrate how to achieve this functionality:
  
 
<code>python3 ./v4l2_opencv_show2.py --width 1920 --height 1080 --fps 60</code>
 
<code>python3 ./v4l2_opencv_show2.py --width 1920 --height 1080 --fps 60</code>
  
====触发模式====
+
====Trigger mode====
=====准备工作=====
+
=====preparatory work=====
 
<code>v4l2-ctl --set-ctrl low_latency_mode=1</code>
 
<code>v4l2-ctl --set-ctrl low_latency_mode=1</code>
  
Line 386: Line 391:
 
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
 
<code>v4l2-ctl --set-ctrl frame_rate=$FPS</code>
  
=====软触发=====
+
=====Soft trigger=====
  
======设置模式======
+
======Setup Mode======
 
<code>v4l2-ctl --set-ctrl <small>work_mode=1</small></code>
 
<code>v4l2-ctl --set-ctrl <small>work_mode=1</small></code>
  
Line 394: Line 399:
  
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=1</code>
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=1</code>
======开始取图======
+
======Start taking pictures======
 
 
*通常情况下
 
 
 
此处的通常情况,指的是WIDTH是256的整数倍。
 
  
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
Line 406: Line 407:
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=uyvy-1920x1080.yuv</code>
 
<code>v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=uyvy-1920x1080.yuv</code>
  
======进行软触发操作======
+
======Perform soft triggering operation======
在其他的shell终端,可以多次执行下面命令进行多次触发。
+
In other shell terminals, you can execute the following command multiple times to trigger it multiple times.
  
 
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
 
<code>v4l2-ctl --set-ctrl <small>soft_trgone=1</small></code>
  
======停止触发和采集======
+
======Stop triggering======
由于内核驱动中,死循环等待新图片,因此需要先取消vi_time_out_disable,然后再退出采集操作。
+
Due to the fact that in the kernel driver, a dead loop is used to wait for new images, it is necessary to first disable vi_time_out_disable, and then exit the acquisition operation.
  
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=0</code>
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=0</code>
  
在取图命令的终端中,按Ctrl+C退出采集操作。
+
In the terminal of the image acquisition command, press Ctrl+C to exit the acquisition operation.
  
=====硬触发=====
+
=====Hardware trigger=====
使用[https://github.com/NVIDIA/jetson-gpio jetson-gpio]进行触发操作,首先请安装并配置好jetson-gpio。
+
To perform the triggering operation using [https://github.com/NVIDIA/jetson-gpio jetson-gpio], first, install and configure jetson-gpio properly.
  
下面以使用jetson GPIO40(Board num)为模拟触发源,上升沿触发为例。
+
Next, using Jetson GPIO40 (Board number) as the simulated trigger source and with the rising edge as the trigger condition, an example will be given.
  
可以使用[https://wiki.veye.cc/index.php/Gx_mipi_i2c.sh_user_guide/zh gx_mipi_i2c.sh]脚本进行丰富的触发参数设置。
+
The rich trigger parameter settings can be carried out by using the [[Gx mipi i2c.sh user guide|gx_mipi_i2c.sh]] script.
  
======硬件连接======
+
======Setup Mode======
 
 
======TBD======
 
======设置模式======
 
 
<code>v4l2-ctl --set-ctrl <small>work_mode=1</small></code>
 
<code>v4l2-ctl --set-ctrl <small>work_mode=1</small></code>
  
Line 434: Line 432:
  
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=1</code>
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=1</code>
======开始取图======
+
======Start taking pictures======
 
 
*通常情况下
 
 
 
此处的通常情况,指的是WIDTH是256的整数倍。
 
  
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
 
<code>v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"</code>
======进行硬触发操作======
+
======Perform a hard trigger operation======
 
<code>python gpio_trigger_jetson.py</code>
 
<code>python gpio_trigger_jetson.py</code>
  
Note:触发脚本[https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/mv_tools_jetson/examples/v4l2grab_mvcam 链接]
+
Note: Trigger script [https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/gx_i2c_tools link].
======停止触发和采集======
+
======Stop triggering and collecting======
由于内核驱动中,死循环等待新图片,因此需要先取消vi_time_out_disable,然后再退出采集操作。
+
Due to the fact that in the kernel driver, a dead loop is used to wait for new images, it is necessary to first disable vi_time_out_disable, and then exit the acquisition operation.
  
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=0</code>
 
<code>v4l2-ctl --set-ctrl vi_time_out_disable=0</code>
  
在取图命令的终端中,按Ctrl+C退出采集操作。
+
In the terminal of the image acquisition command, press Ctrl+C to exit the acquisition operation.
====同步模式====
+
====Synchronous mode====
=====设置同步模式=====
+
=====Set the synchronization mode=====
<code>$ v4l2-ctl --set-ctrl work<small>_mode=4</small></code>
+
<code>$ v4l2-ctl -d /dev/video0 --set-ctrl work_mode=4</code>
 +
 
 +
<code>$ v4l2-ctl -d /dev/video1 --set-ctrl work_mode=4</code>
 +
 
 +
=====Set up the master and slave cameras=====
 +
Main camera:
  
=====设置主从相机=====
+
<code>$ v4l2-ctl -d /dev/video0 --set-ctrl <small>sync_role=0</small></code>
主相机:
 
  
<code>$ v4l2-ctl --set-ctrl <small>sync_role=0</small></code>
+
slave camera:
  
从相机:
+
<code>$ v4l2-ctl -d /dev/video1 --set-ctrl <small>sync_role=1</small></code>
  
<code>$ v4l2-ctl --set-ctrl <small>sync_role=1</small></code>
+
=====Start taking pictures=====
 +
The method of taking screenshots in the synchronization mode is exactly the same as that in the video stream mode.
 +
===I2C Script Usage Instructions===
 +
We provided shell scripts to configure the parameters.
  
=====开始取图=====
+
[[gx_mipi_i2c.sh user guide]]
同步模式下的取图方式与视频流模式下完全一致。
 
===i2c脚本使用说明===
 
我们提供了shell脚本来配置参数。
 
  
[https://wiki.veye.cc/index.php/Gx_mipi_i2c.sh_user_guide/zh gx_mipi_i2c.sh user guide]
+
===Document Revision History===
===参考资料===
 
===本文修改记录===
 
  
*2025-12-11
+
*2025-12-20
  
第一个发布版本
+
Initial release.

Latest revision as of 14:07, 30 December 2025

查看中文

1 overview

The GX series cameras are designed for embedded AI applications. They offer high-performance ISP capabilities, support multiple operating modes, provide a wide range of configurable features, and are built with a robust and reliable design. The cameras use the MIPI CSI-2 interface and are well suited for embedded computing platforms.

This article introduces how to use GX series cameras on the NVIDIA Jetson platform.

1.1 Supported camera modules

series model status
GX Series GX-MIPI-IMX662 Done

1.2 Supported Jetson Board

Jetson model status
Xavier NX Done
Orin NX Done
Orin Nano Done

1.3 Supported L4T versions

  • Jetpack5.1.4,L4T version r35.6
  • Jetpack6.2.1,L4T version r36.4.4
1.3.1 How to check the current L4T version

On the Jetson board, check the current L4T version and try to replace it with the same version.

cat /etc/nv_tegra_release

As shown:

# R32 (release), REVISION: 7.1......

This indicates that the current L4T version is 32.7.1, and the corresponding Jetpack version is Jetpack 32.6.1.

2 Hardware preparation and installation

The GX series cameras require a adapter board to be connected to the Jetson platform. The supported conditions are as shown in the table below:

Camera model Jetson model FFC line Number of cameras Power supply
GX Series Xavier NX 15‑pin to 22‑pin FFC (same-side contacts) 2 5V DC (required)
Orin Nano,Orin NX 22‑pin FFC (opposite-side contacts) 2 5V DC (required)
2.1 GX camera connected to Xavier NX


GX Camera to Xavier NX


2.2 The GX camera is connected to Orin Nano or Orin NX.


GX camera to Orin NX/Nano


3 Update the Jetson system

This section describes how to update the L4T system of Jetson to support the GX camera module. For the method of operating system update, please refer to the update instructions for Jetson operating system.

Specifically, if trigger functionality is required, the Jetson kernel needs to be patched using veye_mv_l4t_<version>.patch.

This patch provides the following features:

  1. Adds support for monochrome camera data formats Y10 and Y12.
  2. Adds support for trigger mode.

4 Support for Trigger Mode 

The default Jetson drivers support only video streaming mode. In the VI driver, data reception includes a timeout mechanism.

We have added a configurable option, vi_time_out_disable, which allows this timeout mechanism to be dynamically enabled or disabled.

For practical usage, please refer to the example applications provided below.

5 System Status Check 

After completing the system update, reboot the Jetson board.

During the boot process, the Jetson system will detect any cameras connected to the I²C buses. If a camera is found, the corresponding /dev/videoX device node will be created.

To verify that the camera is correctly connected, run the following command on the Jetson board:

dmesg | grep gxcam

The output will display the camera model and version detected during Linux boot.

For example, the following message indicates that a GX-MIPI-IMX662 camera was detected on i2c-9:

gxcam 9-003b: camera is: GX-MIPI-IMX662

6 Status Check and Environment Variable Configuration

Here, we provide two scripts that can automatically retrieve key information about the connected camera.

6.1 probe_camera_info-jetson.sh 

This script probes connected and successfully probed camera devices, retrieving information such as the video device node and I²C bus.

After execution, an auto_camera_index.json file will be generated in the current directory, containing the retrieved information.

Example:

$ ./probe_camera_info-jetson.sh

cat auto_camera_index.json

[

{"i2c_bus": "9", "video_node": "/dev/video0"}

]

Each {} block represents one camera. If the board supports multiple camera modules, multiple {} blocks will appear in the file.

The explanation of the camera information is as follows:

Camera Information
Field Name Purpose Usage
video_node Video capture device node Standard V4L2 video device Used with v4l2-ctl or customer applications to capture images,and configuring certain camera parameters.
i2c_bus I²C bus Indicates the I²C bus to which the device is connected Used as the underlying communication channel for camera parameter configuration, e.g., by the gx_mipi_i2c.sh script
  • The video device nodes and I²C bus numbers used in the following sections can be replaced with the corresponding information obtained from the JSON file generated by the probe_camera_info-jetson.sh script.
  • On the Jetson system, each camera module is mapped to a /dev/videoX device node.
  • During system startup, cameras are probed in ascending order of their I²C bus numbers. The X in /dev/videoX is assigned sequentially starting from 0 according to the probing order.
    • For example, if only one camera is connected, X will be 0 regardless of which I²C port the hardware is attached to.
    • If five cameras are connected, X values will be [0-4], ordered by ascending I²C bus numbers.
  • In v4l2-ctl commands, the -d /dev/videoX option is used to access different cameras.
  • In GStreamer, v4l2src can access different cameras by specifying device=/dev/videoX.

6.2 gx_probe.sh

By using the gx_probe.sh script, the I²C bus number corresponding to a certain camera, the camera model, width, height, frame rate, etc. can be configured into the environment variables.

In that case, subsequent operations using v4l2-ctl will be more convenient.

The usage method is:

$ source ./gx_probe.sh i2c_bus

A typical output is as follows:

$ source ./gx_probe.sh 9

Found veye_gxcam camera on i2c-9.

Setenv I2C_BUS = 9

Setenv CAMERAMODEL = GX-MIPI-IMX662

Setenv FPS = 60

Setenv WIDTH = 1920

Setenv HEIGHT = 1080

You can verify the environment variable output using, for example:

echo $CAMERAMODEL

Note: These environment variables are valid only for the current shell session.

7 Real-time preview

7.1 veye_viewer

The veye_viewer is an open-source, Qt-based client application that allows users to easily evaluate cameras and configure parameters. Its operation logs, register listings, and open-source nature provide a convenient reference for users and support custom development.

The source code of veye_viewer can be downloaded here, or platform-specific executable programs are available directly in its release packages.

7.2 qv4l2

First, install qv4l2

sudo apt install qv4l2

1. Enter qv4l2 in the command line to start the V4L2 player.

2. Click the ▶ (play) button to bring up the opened media window.

Play gx camera using qv4l2

8 Gstreamer Usage

To install the latest accelerated version of gstreamer plugins and applications, please run the following command:

sudo apt-get update

sudo apt-get install nvidia-l4t-gstreamer

sudo ldconfig

rm -rf .cache/gstreamer-1.0/

export DISPLAY=:0

  • video preview 1080p HD

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nv3dsink sync=false

  • video preview 1080p HD(using xvimagesink sink if supported)

export DISPLAY=:0

gst-launch-1.0 -e v4l2src io-mode=4 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=1920, height=1080, framerate=30/1, format=UYVY' ! xvimagesink sync=false

  • Gstreamer is embedded into OpenCV

I think maybe OpenCV do not support I420 data format input,so you should convert it to BGR format.

gst-launch-1.0 nvv4l2camerasrc ! video/x-raw(memory:NVMM), format=(string)UYVY, width=(int)1920, height=(int)1080 ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)I420 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink

  • Video recording 1080p HD

gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nvv4l2h264enc control-rate=1 bitrate=10000000 ! h264parse ! qtmux ! filesink location=filename.mp4 -e

  • Playback of saved video file

gst-launch-1.0 filesrc location=filename.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e

  • Capturing FHD still image  

gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvjpegenc ! filesink location=jpgname.jpg

9 yavta(Only supports streaming mode)

9.1 yavta install

git clone https://github.com/veyeimaging/yavta.git

cd yavta;make

9.2 Set image format

v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY

9.3 Save the image to a file

  • UYVY type

./yavta -c1 -F"uyvy-${WIDTH}x${HEIGHT}.yuv" --skip 0 -f UYVY -s "${WIDTH}x${HEIGHT}" /dev/video0

  • GX-MIPI-IMX662

./yavta -c1 -Fuyvy-1920x1080.yuv --skip 0 -f UYVY -s 1920x1080 /dev/video0

10 Jetson multimedia-api samples

On the Jetson platform, the Jetson Linux API is provided for developers. For installation of the jetson_multimedia_api package, please refer to the official NVIDIA documentation.

For GX series cameras, ISP functionality is already integrated within the camera module. Therefore, libargus cannot be used to acquire data. Instead, standard V4L2 interfaces can be used to capture data directly from the /dev/videoX device file.

After installing the Jetson system, you can navigate to the Multimedia API sample directory, compile, and run the following commands to preview the camera video:

cd /usr/src/jetson_multimedia_api/samples/12_v4l2_camera_cuda

make

./v4l2_camera_cuda -d /dev/video0 -s 1920x1080 -f UYVY

This command uses the /dev/video0 device to perform real-time video preview at a resolution of 1920×1080 with the UYVY format.

11 v4l2-ctl Examples

11.1 Install v4l2-utils

sudo apt-get install v4l-utils

11.2 Configure parameters using v4l2-ctl
11.2.1 List the data formats supported by the camera

v4l2-ctl --list-formats-ext

Below is an example:

ioctl: VIDIOC_ENUM_FMT

        Type: Video Capture

        [0]: 'UYVY' (UYVY 4:2:2)

                Size: Discrete 1920x1080

                        Interval: Discrete 0.017s (60.000 fps)

        [1]: 'YUYV' (YUYV 4:2:2)

        [2]: 'NV16' (Y/CbCr 4:2:2)

                Size: Discrete 1920x1080

                        Interval: Discrete 0.017s (60.000 fps)

  • Frame rate statistics

v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null

  • Save the image to a file

v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=uyvy-1920x1080.yuv

11.2.2 List the configurable parameters of the camera implemented in the driver

v4l2-ctl -L

User Controls

                   work_mode 0x00981a01 (int)    : min=0 max=4 step=1 default=0 value=0 flags=volatile, execute-on-write

                    trigger_src 0x00981a02 (int)    : min=0 max=1 step=1 default=1 value=1 flags=volatile, execute-on-write

                    soft_trgone 0x00981a03 (button) : flags=write-only, execute-on-write

                      sync_role 0x00981a04 (int)    : min=0 max=1 step=1 default=0 value=0 flags=volatile, execute-on-write

                     frame_rate 0x00981a05 (int)    : min=0 max=60 step=1 default=60 value=60 flags=volatile, execute-on-write

The parameters can be set and retrieved using the following methods.

v4l2-ctl --set-ctrl [ctrl_type]=[val]

v4l2-ctl --get-ctrl [ctrl_type]

All of the above functions can be achieved by using the gx_mipi_i2c.sh script.

It should be noted that the above parameters cannot be modified once the image capture process begins. The following will provide detailed explanations for each one:

11.2.3 Configure trigger mode

v4l2-ctl --set-ctrl work_mode=[0-2]

0: Streaming Mode

1: Trigger Mode

2: Multi-camera Synchronization Mode

11.2.4 Configure trigger source

v4l2-ctl --set-ctrl trigger_src=[0-1]

0: Soft Trigger

1: Hard Trigger

11.2.5 Soft trigger once

v4l2-ctl --set-ctrl soft_trgone=1

11.2.6 Set frame rate

v4l2-ctl --set-ctrl frame_rate=[1-max]

As the resolution is adjusted, the maximum frame rate will be automatically updated.

11.3 Stream mode

11.3.1 Set image format

Take the largest screen as an example:

v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY

v4l2-ctl --set-ctrl frame_rate=$FPS

11.3.2 Frame rate statistics

v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=/dev/null

11.3.3 Save the image to a file
11.3.3.1 under normal conditions
  • UYVY

v4l2-ctl -d /dev/video0 --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"

11.3.3.2 Use OpenCV to preview camera

sudo apt install python3-opencv

  • We have provided a simple sample to demonstrate how to achieve this functionality:

python3 ./v4l2_opencv_show2.py --width 1920 --height 1080 --fps 60

11.4 Trigger mode

11.4.1 preparatory work

v4l2-ctl --set-ctrl low_latency_mode=1

v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY

v4l2-ctl --set-ctrl frame_rate=$FPS

11.4.2 Soft trigger
11.4.2.1 Setup Mode

v4l2-ctl --set-ctrl work_mode=1

v4l2-ctl --set-ctrl trigger_src=0

v4l2-ctl --set-ctrl vi_time_out_disable=1

11.4.2.2 Start taking pictures

v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"

  • GX-MIPI-IMX662

v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to=uyvy-1920x1080.yuv

11.4.2.3 Perform soft triggering operation

In other shell terminals, you can execute the following command multiple times to trigger it multiple times.

v4l2-ctl --set-ctrl soft_trgone=1

11.4.2.4 Stop triggering

Due to the fact that in the kernel driver, a dead loop is used to wait for new images, it is necessary to first disable vi_time_out_disable, and then exit the acquisition operation.

v4l2-ctl --set-ctrl vi_time_out_disable=0

In the terminal of the image acquisition command, press Ctrl+C to exit the acquisition operation.

11.4.3 Hardware trigger

To perform the triggering operation using jetson-gpio, first, install and configure jetson-gpio properly.

Next, using Jetson GPIO40 (Board number) as the simulated trigger source and with the rising edge as the trigger condition, an example will be given.

The rich trigger parameter settings can be carried out by using the gx_mipi_i2c.sh script.

11.4.3.1 Setup Mode

v4l2-ctl --set-ctrl work_mode=1

v4l2-ctl --set-ctrl trigger_src=1

v4l2-ctl --set-ctrl vi_time_out_disable=1

11.4.3.2 Start taking pictures

v4l2-ctl --set-fmt-video=width=$WIDTH,height=$HEIGHT,pixelformat=UYVY --stream-mmap --stream-count=-1 --stream-to="uyvy-${WIDTH}x${HEIGHT}.yuv"

11.4.3.3 Perform a hard trigger operation

python gpio_trigger_jetson.py

Note: Trigger script link.

11.4.3.4 Stop triggering and collecting

Due to the fact that in the kernel driver, a dead loop is used to wait for new images, it is necessary to first disable vi_time_out_disable, and then exit the acquisition operation.

v4l2-ctl --set-ctrl vi_time_out_disable=0

In the terminal of the image acquisition command, press Ctrl+C to exit the acquisition operation.

11.5 Synchronous mode

11.5.1 Set the synchronization mode

$ v4l2-ctl -d /dev/video0 --set-ctrl work_mode=4

$ v4l2-ctl -d /dev/video1 --set-ctrl work_mode=4

11.5.2 Set up the master and slave cameras

Main camera:

$ v4l2-ctl -d /dev/video0 --set-ctrl sync_role=0

slave camera:

$ v4l2-ctl -d /dev/video1 --set-ctrl sync_role=1

11.5.3 Start taking pictures

The method of taking screenshots in the synchronization mode is exactly the same as that in the video stream mode.

12 I2C Script Usage Instructions

We provided shell scripts to configure the parameters.

gx_mipi_i2c.sh user guide

13 Document Revision History

  • 2025-12-20

Initial release.