Difference between revisions of "VEYE CS Camera for Jetson TX2"

From wiki_veye
Jump to navigation Jump to search
 
(170 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[VEYE CS Camera for Jetson TX2/zh|查看中文]]
 
[[VEYE CS Camera for Jetson TX2/zh|查看中文]]
  
'''<big>How to use VEYE and CS series camera module on NVIDIA Jetson TX2 and AGX Xavier</big>'''
+
'''<big>How to use VEYE and CS series camera module on NVIDIA Jetson Nano,TX2,Xavier and Orin</big>'''
  
 
===Overview===
 
===Overview===
This guide shows how to use VEYE and CS series camera modules on Jetson TX2 and AGX Xavier.  Jetson JetPack SDK Version is r32.2.1. We provide two ways to do so: '''Prebuilt Binaries''' or '''Source Code. Yes, It's Open Source!'''
+
This guide shows how to use VEYE and CS series camera modules on Jetson boards.  Jetson SDK Version is:
 +
 
 +
*Jetpack4.2.2,L4T r32.2.1
 +
*Jetpack4.3,L4T r32.3.1
 +
*Jetpack4.4,L4T r32.4.3
 +
*Jetpack4.4.1,L4T r32.4.4
 +
*Jetpack4.5,L4T r32.5
 +
*Jetpack4.5.1,L4T r32.5.1
 +
*Jetpack4.6,L4T r32.6.1
 +
 
 +
* Jetpack4.6.1, L4T r32.7.1
 +
*Jetpack4.6.2,L4T r32.7.2
 +
*Jetpack4.6.3,L4T r32.7.3
 +
*Jetpack4.6.4,L4T r32.7.4
 +
*Jetpack5.0.1DP, L4T r34.1.1
 +
*Jetpack5.0.2, L4T r35.1
 +
*Jetpack5.1,L4T r35.2.1
 +
*Jetpack5.1.1,L4T r35.3.1
 +
*Jetpack5.1.2,L4T r35.4.1
 +
*Jetpack5.1.3,L4T r35.5
 +
*Jetpack6.0,L4T r36.3
 +
*Jetpack6.1,L4T r36.4
 +
 
 +
We provide two ways to do so: '''Prebuilt Binaries''' or '''Source Code. Yes, It's Open Source!'''
 +
 
 +
VEYE and CS series camera modules are camera module with ISP functions build in. It output UYVY data using MIPI-CSI2. We provide '''V4L2 interface''' for video streaming apps , and '''Video Control Toolkits (which is Shell Script)''' to control the camera module directly, which is called DRA(Directly Register Access).
 +
====Camera module list====
 +
{| class="wikitable"
 +
|+Camera module dirver status list
 +
!Series
 +
!Model
 +
!Status
 +
|-
 +
|VEYE series
 +
| VEYE-MIPI-IMX327S
 +
| Done
 +
|-
 +
|VEYE series
 +
| VEYE-MIPI-IMX385
 +
|Done
 +
|-
 +
|VEYE series
 +
|VEYE-MIPI-IMX462
 +
|Done
 +
|-
 +
|VEYE series
 +
|VEYE-MIPI-IMX335
 +
|Done
 +
|-
 +
|CS series
 +
| CS-MIPI-IMX307
 +
|Done
 +
|-
 +
|CS series
 +
|CS-MIPI-SC132
 +
|Done
 +
|-
 +
|TX2-XAVIER-nCAM Series
 +
|CS-TX2-XAVIER-'''''n'''''CAM
 +
|Done
 +
|}
 +
====How to check the current L4T version====
 +
 
 +
===== Method 1 =====
 +
On Jetson board
 +
 
 +
<code>cat /etc/nv_tegra_release</code>
 +
 
 +
If it shows:
 +
 
 +
<code># R32 (release), REVISION: 4.3......</code>
 +
 
 +
It means L4t Version is 32.4.3
 +
 
 +
===== Method 2 =====
 +
Refer to this [https://pypi.org/project/jetson-stats/ link] to install jetson-stats:
 +
 
 +
<code>jtop</code>
  
VEYE and CS series camera modules are STARVIS camera module with ISP functions build in. It output UYVY data using MIPI-CSI2. We provide '''V4L2 interface''' for video streaming apps , and '''Video Control Toolkits (which is Shell Script)''' to control the camera module directly, which is called DRA(Directly Register Access).
 
 
===Hardware Setup===
 
===Hardware Setup===
 +
We have designed a 6cam interposer board  for TX2 devkit,Xavier and Orin, It support up to 6 cameras at the same time. 
 +
[[File:ADP-N1-6CAM YT0.95-4I.jpg|alt=6cam interposer board connected with 6 cameras|center|thumb|800x800px|6cam interposer board connected with 6 cameras]]
 +
 +
 +
In particular, the VEYE-MIPI-IMX335 must use a 12V DC terminal to provide auxiliary power due to its high power consumption. Refer to [[ADP-N1-V2.0 Adapter Board Data Sheet#Adapter Board Pinlist.EF.BC.88.E6.8E.A5.E5.8F.A3.E5.92.8C.E5.BC.95.E8.84.9A.E8.AF.B4.E6.98.8E.EF.BC.89|J11 of ADP-N1]].
 
====NVIDIA TX2 Developer Kit====
 
====NVIDIA TX2 Developer Kit====
We have designed a special adapter board for TX2 developwer  kit, It support up to 6 cameras at the same time.
+
It is connected as shown in figure:
 +
[[File:TX2-6CAM-YT2.0-3.5I.jpg|alt=TX2 Devkit 6 cameras connection|center|thumb|800x800px|'''TX2 Devkit 6 cameras connection''']]
 +
<br />'''Be sure to screw the ADP adapter board to the bottom board.'''
 +
 
 +
====NVIDIA AGX Xavier(the same with Orin)====
 +
<br />
 +
[[File:ADP-N1-V2.0 XAVIER 6CAM.jpg|link=http://wiki.veye.cc/index.php/File:ADP-N1-V2.0%20XAVIER%206CAM.jpg|alt=Connect VEYE cameras to AGX Xavier|center|thumb|800x800px|Connect VEYE cameras to AGX Xavier]]
 +
<br />'''Be sure to screw the ADP adapter board to the bottom board to ensure that the adapter plate is installed flat.'''
 +
====NVIDIA Nano ,TX2 NX and Xavier NX Devkit====
 +
The Xavier NX interface is compatible with raspberry pi and Jetson Nano. The connection mode is shown in figure:
 +
[[File:Xavier NX connection with VEYE-MIPI-327.jpg|alt=Xavier NX connection with VEYE-MIPI-327|center|thumb|800x800px|Xavier NX connection with VEYE-MIPI-327]]
 +
<br />
 +
[[File:Xavier NX connection with CS-MIPI-IMX307.jpg|alt=Xavier NX connection with CS-MIPI-IMX307|center|thumb|800x800px|Xavier NX connection with CS-MIPI-IMX307]]
 +
[[File:Jetson nano to Veye327.jpg|link=http://wiki.veye.cc/index.php/File:Jetson%20nano%20to%20Veye327.jpg|alt=Jetson Nano A02 与VEYE模组连接|center|thumb|800x800px|VEYE327 connection with Jetson Nano A02]]
 +
[[File:VEYE camera connection with Orin Nano and Orin NX.jpg|center|thumb|800x800px|VEYE camera  connection with Orin Nano and Orin NX]]
  
It is connected as shown in figure (TODO).
+
=== Upgrade Jetson system ===
 +
This section describes how to upgrade the Jetson system to support MV camera module. For OS update method, please refer to [[How to upgrade the Jetson system to support VEYE cameras|Update Jetson OS]].
 +
===Applications and Test===
 +
====Check system status====
 +
Run the following command to confirm whether the camera is probed.
  
====NVIDIA TX2 AGX Xavier====
+
*VEYE-MIPI-IMX327S/VEYE-MIPI-IMX462/VEYE-MIPI-IMX385(using VEYE-MIPI-CAM2M dtb)
<br />
+
 
===Upgrade Jetson TX2 and AGX Xavier system===
+
<code>dmesg | grep veye</code>  
====Setting Up the Host PC Environment====
+
 
 +
The output message appears as shown below:
 +
 
 +
<code>camera id is veyecam</code>
 +
 
 +
<code>sensor is IMX327/IMX462/IMX385</code>
 +
 
 +
<code>subdev veyecam [i2c_bus]-003b bound</code>
 +
 
 +
*For CS-MIPI-IMX307
 +
 
 +
<code>dmesg | grep csx307</code>  
 +
 
 +
The output message appears as shown below.:
 +
 
 +
<code>Detected CS307 sensor</code>
 +
 
 +
<code>subdev csx307 [i2c_bus]-003b bound</code>
 +
 
 +
*For CS-MIPI-SC132
 +
 
 +
<code>dmesg | grep cssc132</code>  
 +
 
 +
The output message appears as shown below.:
 +
 
 +
<code>subdev cssc132 [i2c_bus]-003b bound</code>
 +
 
 +
*For VEYE-MIPI-IMX335
 +
 
 +
<code>dmesg | grep imx335</code>
  
*Cross-compiling Toolchain
+
The output message appears as shown below.:
  
Please refer to this [https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fxavier_toolchain.html%23wwpID0ESHA link] to install toolchain on your Host PC.
+
<code>camera id is VEYE-MIPI-IMX335</code>
  
*L4T source code and Rootfs
+
<code>subdev veye_imx335 [i2c_bus]-003b bound</code>
  
You could use SDK Manager or [https://developer.nvidia.com/embedded/downloads directly download] to get source code.
+
*Run the following command to check the presence of video node.
  
Sync code as this if you use SDK Manager:
+
<code>ls /dev/video*</code>
  
<code>./source_sync.sh -t tegra-l4t-r32.2.1</code>
+
The output message appears as shown below.
  
*Setting Up the Environment
+
<code>videoX</code>  
  
Assume SDK install directory is <TOPDIR>,source code is in $L4T_DIR/sources directory.
+
*For VEYE-MIPI-327(using VEYE-MIPI-327 dtb)
  
''- TX2''
+
<code>dmesg | grep veye327</code>  
  
<code>export TOP_DIR=/home/xumm/nvidia/nvidia_sdk/JetPack_4.2.2_Linux_GA_P3310/</code>
+
The output message appears as shown below:
  
''- AGX Xavier''
+
<code>Detected VEYE327 sensor</code>
  
<code>export TOP_DIR=/home/xumm/nvidia/nvidia_sdk/JetPack_4.2.2_Linux_GA_P2888/</code>
+
<code>subdev veye327 [i2c_bus]-003b bound</code>
  
<code>export L4T_DIR=$TOP_DIR/Linux_for_Tegra</code>
+
The [i2c_bus] in the driver prompt message indicates the i2c bus corresponding to this camera.
  
<code>export LOCALVERSION=-tegra</code>
+
====Video Stream Toolkits Manual====
 +
The camera appears as /dev/videoX device node,where X is between [0-5].
  
<code>export LDK_ROOTFS_DIR=$TOP_DIR/Linux_for_Tegra/rootfs</code>
+
During the Linux boot process, the cameras are detected in the order of i2c bus from smallest to largest.  For example, if only one camera is connected, X is 0 regardless of the hardware connection to the location. If 5 cameras are connected, X is reflected as [0-4] according to i2c bus from smallest to largest.
  
<code>export ARCH=arm64</code>
+
In gstreamer command ,v4l2src and nvv4l2camerasrc has a param device=/dev/videoX to identify which camera to use.
 +
=====Gstreamer Usage=====
 +
To install the latest accelerated gstreamer plugins and applications, run the following commands:
  
<code>export CROSS_COMPILE=aarch64-linux-gnu-</code>
+
<code>sudo apt-get update</code>
  
<code>export CROSS32CC=arm-linux-gnueabihf-gcc</code>
+
<code>sudo apt-get install nvidia-l4t-gstreamer</code>
  
<code>export TEGRA_KERNEL_OUT=$L4T_DIR/sources/kernel/out_kernel</code>
+
<code>sudo ldconfig</code>
  
<code>export KERNEL_PATH=$L4T_DIR/sources/kernel/out_kernel</code>
+
<code>rm -rf .cache/gstreamer-1.0/</code>
  
<code>export NVIDIA_PATH=$L4T_DIR/sources/kernel/nvidia</code>
 
  
<code>export TX2_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t18x</code>
+
<code>export DISPLAY=:0</code>
  
<code>export XAVIER_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t19x</code>
+
*Preview FHD
  
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</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>
  
*Build default image, flashing to Jetson Board, prepare L4T environment
+
<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>cd $L4T_DIR</code>
+
* Preview FHD(using xvimagesink sink if supported)
  
<code>sudo ./apply_binaries.sh</code>  
+
<code>export DISPLAY=:0</code>
  
''- TX2''
+
<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>sudo ./flash.sh jetson-tx2 mmcblk0p1</code>
+
*Preview 720p@60 (CS-MIPI-IMX307)
  
''- AGX Xavier''
+
<code>gst-launch-1.0 nvv4l2camerasrc  ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
  
<code>sudo ./flash.sh jetson-xavier mmcblk0p1</code>
+
*Preview 1280*1080@45 (CS-MIPI-SC132)
====Download out bsp package for Jetson====
 
<code>cd $L4T_DIR</code>
 
  
<code>git clone https://github.com/veyeimaging/nvidia_jetson_veye_bsp<nowiki/>.git</code>
+
<code>gst-launch-1.0 nvv4l2camerasrc ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1280, height=(int)1080, framerate=(fraction)45/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
  
<code>export RELEASE_PACK_DIR=$L4T_DIR/nvidia_jetson_veye_bsp</code>
+
*Preview 640*480p@130 (CS-MIPI-IMX307)
=====bsp package includes:=====
 
  
*prebuild linux kernel:Image
+
<code>gst-launch-1.0 nvv4l2camerasrc ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)640, height=(int)480, framerate=(fraction)130/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
*prebuild dtb for different boards
 
*driver source code
 
*dts source code
 
*i2c toolkits
 
  
====Using prebuild Image and DTB====
+
*Preview 2 cameras  1080p HD
  
*Installing the Kernel
+
<code>WIDTH=960</code>
  
Whether you use a prebuild kernel or you build it yourself
+
<code>HEIGHT=540</code>
  
''- TX2''
+
<code>CAPS="video/x-raw(memory:NVMM),format=(string)UYVY, width=1920, height=1080"</code>
  
copy Image to /boot/ dir on the Jetson TX2 board:
+
<code>gst-launch-1.0 nvcompositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=$WIDTH sink_0::height=$HEIGHT sink_1::xpos=$WIDTH sink_1::ypos=0 sink_1::width=$WIDTH sink_1::height=$HEIGHT ! nv3dsink nvv4l2camerasrc device=/dev/video0 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp. nvv4l2camerasrc  device=/dev/video1 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp.</code>
  
<code>sudo cp <path to your Image dir>/Image  /boot/Image -f</code>
+
*Record FHD in H.264 format to a video file
  
''- AGX Xavier''
+
<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>
  
on the Host PC:
+
*Playback of saved video file
  
<code>cd $L4T_DIR</code>
+
<code>gst-launch-1.0 filesrc location=filename.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nvoverlaysink -e</code>
  
<code>sudo ./flash.sh -k kernel jetson-xavier mmcblk0p1</code>
+
*Capturing FHD still image  
  
*Flashing dtb file
+
<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.jp</code>
  
Enter the recovery mode,and on the Host PC:
+
===== VEYE-MIPI-IMX335 gstreamer example =====
 +
Since VEYE-MIPI-IMX335 supports only a few specific resolution modes, its driver we use use_sensor_mode_id mode.
 +
{| class="wikitable"
 +
|+VEYE-MIPI-IMX335 mode
 +
!./veye5_mipi_i2c.sh video mode
 +
!v4l2-ctl sensor_mode
 +
!video format
 +
|-
 +
|1
 +
|0
 +
|2592x1944@20fps
 +
|-
 +
|2
 +
|1
 +
|2592x1944@12.5fps
 +
|-
 +
|3
 +
|2
 +
|2560x1440@25fps
 +
|-
 +
|4
 +
|3
 +
|2560x1440@30fps
 +
|}
  
<code>cp <path to your dtb dir>/dtbfilename $L4T_DIR/kernel/dtb/ -f</code>
+
* prepare
  
<code>cd $L4T_DIR</code>
+
<code>sudo apt-get install v4l-utils</code>
  
<code>''- TX2''</code>
+
Refer to the following section and download the veye5_mipi_i2c.sh tool.
  
<code>sudo ./flash.sh -r -k kernel-dtb jetson-tx2 mmcblk0p1</code>
+
* 2592x1944@20fps mode preview, framerate statistics
  
<code>''- AGX Xavier''</code>
+
<code>v4l2-ctl -d /dev/video0 --set-ctrl sensor_mode=0</code>
  
<code>sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1</code>
+
<code>./veye5_mipi_i2c.sh -w -f videomode -p1 1 -b [busnum]</code>
  
Reset Jetson Board after flashing.
+
<code>v4l2-ctl -d /dev/video0 --set-ctrl preferred_stride=5376</code>
====Building from Source====
 
=====Build kernel=====
 
  
*patch code
+
Preview
  
<code>cp $RELEASE_PACK_DIR/drivers_source/cs_imx307\ veye327/* $NVIDIA_PATH/drivers/media/i2c/</code>
+
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM), width=(int)2592, height=(int)1944" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false</code>
  
<code>cp $RELEASE_PACK_DIR/drivers_source/kernel_csimx307veye327_config $L4T_DIR/sources/kernel/kernel-4.9/arch/arm64/configs/tegra_csimx307veye327_defconfig</code>
+
Framerate statistics
  
*build
+
<code>gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY,width=(int)2592,height=(int)1944" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! fpsdisplaysink video-sink=fakesink -v</code>
  
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
+
* 2560x1440@30fps mode video encode and capture
  
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_csimx307veye327_defconfig</code>
+
<code>v4l2-ctl -d /dev/video0 --set-ctrl sensor_mode=3</code>
  
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT Image -j4</code>
+
<code>./veye5_mipi_i2c.sh -w -f videomode -p1 4 -b [busnum]</code>
  
Completed Image file is $TEGRA_KERNEL_OUT/arch/arm64/boot/Image,could be used for Flashing or Upgrading.
+
<code>v4l2-ctl -d /dev/video0 --set-ctrl preferred_stride=5120</code>
  
Install Image for Flashing:
+
Video encode
  
<code>sudo cp $TEGRA_KERNEL_OUT/arch/arm64/boot/Image $L4T_DIR/kernel/ -f</code>
+
<code>gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)2560, height=(int)1440" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nvv4l2h264enc control-rate=0 bitrate=10000000 ! h264parse ! qtmux ! filesink location=filename.mp4 -e</code>
=====Build DTS=====
 
  
*patch code
+
Video Replay
  
''- Jetson TX2''
+
<code>gst-launch-1.0 filesrc location=filename.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e</code>
  
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_4.2.2_Linux_GA_P3310/dts\ dtb/common/t18x/* -r $TX2_DTS_PATH/</code>
+
Capture
  
For CS-MIPI-IMX307
+
<code>gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw,format=(string)UYVY, width=(int)2560, height=(int)1440" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvjpegenc ! filesink location=jpgname.jpg</code>
  
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_4.2.2_Linux_GA_P3310/dts\ dtb/CS-MIPI-IMX307/tegra186-quill-p3310-1000-a00-00-base.dts $TX2_DTS_PATH/quill/kernel-dts/</code>
+
===== Jetson multimedia-api samples =====
 +
The [https://docs.nvidia.com/jetson/l4t-multimedia/index.html Jetson Linux API] is available on the Jetson platform for developers to use. Please refer to the official nVidia documentation for the installation of the jetson_multimedia_api package.
  
For VEYE-MIPI-327
+
For VEYE and CS series cameras, the ISP function is already integrated in the camera, so you cannot use libargus to get data, but can directly use the standard V4L2 interface to get data from the /dev/videoX device file.
  
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_4.2.2_Linux_GA_P3310/dts\ dtb/VEYE-MIPI-327/tegra186-quill-p3310-1000-a00-00-base.dts $TX2_DTS_PATH/quill/kernel-dts/</code>
+
The following two samples can be run directly.
  
''- AGX Xavier''
+
====== 12_camera_v4l2_cuda ======
 +
<code>./camera_v4l2_cuda -d /dev/video0 -s 1920x1080 -f UYVY</code>
  
<code>cp $RELEASE_PACK_DIR/AGX-Xaviar/JetPack_4.2.2_Linux_GA_P2888/dts\ dtb/common/t19x/* -r $XAVIER_DTS_PATH/</code>
+
====== v4l2cuda ======
 +
<code>./capture-cuda -d /dev/video0 -f UYVY -m -o out.ppm -s 1920x1080 -c 1</code>
  
For CS-MIPI-IMX307
+
===== v4l2-ctl Application Examples =====
  
<code>cp $RELEASE_PACK_DIR/AGX-Xaviar/JetPack_4.2.2_Linux_GA_P2888/dts\ dtb/CS-MIPI-IMX307/tegra194-p2888-0001-p2822-0000.dts $TX2_DTS_PATH/galen/kernel-dts/</code>
+
======install v4l2-utils======
 +
<code>sudo apt-get install v4l-utils</code>
 +
======Configure parameters using v4l2-ctl======
  
For VEYE-MIPI-327
+
* List the data formats supported by the camera
  
<code>cp $RELEASE_PACK_DIR/AGX-Xaviar/JetPack_4.2.2_Linux_GA_P2888/dts\ dtb/VEYE-MIPI-327/tegra194-p2888-0001-p2822-0000.dts $TX2_DTS_PATH/galen/kernel-dts/</code>
+
<code>v4l2-ctl -d /dev/video0 --list-formats-ext</code>
  
*build
+
* Frame rate statistics
  
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
+
<code>v4l2-ctl -d /dev/video0  --set-fmt-video=width=1920,height=1080,pixelformat=UYVY--stream-mmap --stream-count=-1 --stream-to=/dev/null</code>
  
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs</code>
+
* Save image to file
  
Could be used for Flashing or Upgrading.
+
<code>v4l2-ctl -d /dev/video0  --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=uyvy-1920x1080.yuv</code>
===Applications and Test===
+
 
====Check system status====
+
===== yavta =====
Run the following command to confirm whether the camera is probed.
+
 
 +
======install yavta======
 +
<code>git clone <nowiki>https://github.com/veyeimaging/yavta.git</nowiki></code>
  
*For VEYE-MIPI-327
+
<code>cd yavta;make</code>
  
<code>dmesg | grep veye327</code>  
+
====== Save image to file ======
 +
<code>./yavta -c1 -FUYVY-1920x1080.yuv --skip 0 -f UYVY -s 1920x1080 /dev/video0</code>
  
The output message appears as shown below.
+
===== Opencv =====
 +
To import camera data from v4l2 devices to opencv, we provide several samples.
  
<code>Detected VEYE327 sensor</code>
+
We provide 2 samples [https://github.com/veyeimaging/nvidia_jetson_veye_bsp/tree/master/samples/opencv here].
  
<code>subdev veye327 3X-003b bound</code>
+
====Using i2c script to modify camera parameters====
  
此外,检查/dev/videoX设备节点,应当是存在的。
+
*VEYE-MIPI-CAM2M Series(VEYE-MIPI-327、VEYE-MIPI-IMX327S、VEYE-MIPI-IMX462、VEYE-MIPI-IMX385)
  
*For CS-MIPI-IMX307
+
Video Control Toolkits Manual :[[VEYE-MIPI-290/327 i2c/|VEYE-MIPI-327 I2C]]
  
<code>dmesg | grep csimx307</code>  
+
*CS-MIPI-IMX307和CS-MIPI-SC132
  
The output message appears as shown below.
+
Video Control Toolkits Manual [[CS-MIPI-X i2c|CS-MIPI-X I2C]]
  
<code>Detected CS307 sensor</code>
+
* VEYE-MIPI-IMX335
  
<code>subdev csimx307 3X-003b bound</code>
+
Video Control Toolkits Manual :[[5m mipi i2c user guide|VEYE-MIPI-IMX335 I2C]]
 +
===How to port the driver to a third party board===
  
*Run the following command to check the presence of video node.
+
==== driver porting ====
 +
For Image, we have added functionality to the official standard Image and have not made any deletions. In general, you can use our compiled Image directly. for special cases, please refer to the source code for integration.
  
<code>ls /dev/video*</code>
+
For modules it is even easier to just use them. Compiling from source code and is very simple, so I won't go into details here.
  
The output message appears as shown below.
+
==== dts porting ====
 +
We only provide dtb for some boards of Nano, TX2, Xavier, Orin. For the types not provided, it is necessary to:
  
<code>videoX</code>  
+
1. get the dts source code of that board.
  
====Video Stream Toolkits Manual====
+
2. put our camera related dts to the whole.
Our camera appears as /dev/videoX device node,where X is between [0-5].
 
  
in gstreamer command ,v4l2src has a param device=/dev/videoX to identify which camera to use.
+
3. recompile to get the dtb of the corresponding board.
=====Gstreamer Usage=====
 
  
*Preview FHD(HW accelerated)
+
The operation steps are not complicated, but there are some third-party base board manufacturers do not open dts source code. This will require the cooperation of all parties to do so.
  
<code>gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvoverlaysink sync=false</code>
+
=== FAQ and bug list ===
  
*Preview 720p@60 (CS-MIPI-IMX307,HW accelerated)
+
==== VEYE cameras on Jetpack5.x ====
 +
Jetpack5.x has more stringent requirements for mipi signals in xavier and orin platforms. VEYE-MIPI-xxx series cameras need firmware hdver>=7 to be perfectly supported.
  
<code>gst-launch-1.0 v4l2src ! "video/x-raw,format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nvoverlaysink sync=false</code>
+
==== CS-MIPI-IMX307 combined with Orin nano and Orin NX Green Screen ====
 +
When CS-MIPI-IMX307 is powered by the 3.3V mode of the FFC cable, the MIPI receiver state machine of Orin nano and Orin NX (Jetpack5.1.1) will enter an incorrect state.
  
*Preview 2 cameras  1080p HD(HW accelerated)
+
It is recommended to refer to this [[Power supply mode switching|article]] and modify the power supply mode of CS-MIPI-IMX307 to use the 5V power supply mode.
  
<code>WIDTH=960</code>
+
==== Jetpack5.0.1 DP ====
 +
This version has many bugs, such as not supporting nvv4l2camerasrc, not recommended to use.
  
<code>HEIGHT=540</code>
+
==== nv3dsink ====
 +
Jetpack 5.x no longer supports nvoverlaysink, use nv3dsink instead.
 +
=== Document History ===
  
<code>CAPS="video/x-raw,format=(string)UYVY, width=1920, height=1080"</code>
+
* 2024-08-06
  
<code>gst-launch-1.0 nvcompositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=$WIDTH sink_0::height=$HEIGHT sink_1::xpos=$WIDTH sink_1::ypos=0 sink_1::width=$WIDTH sink_1::height=$HEIGHT ! nvoverlaysink v4l2src device=/dev/video0 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp. v4l2src device=/dev/video1 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp.</code>
+
Make Chapter 3 - Upgrading the Jetson system a separate article.
  
*Record FHD in H.264 format to a video file(HW accelerated)
+
*2024-05-22
  
<code>gst-launch-1.0 v4l2src num-buffers=300 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! omxh264enc qp-range=20,20:20,20:-1,-1 ! matroskamux ! queue ! filesink location=videoname.mkv</code>
+
Add support for Jetpack5.1.3.
  
*Playback of saved video file (HW accelerated)
+
*20230427
  
<code>gst-launch-1.0 filesrc location=videoname.mkv ! matroskademux ! h264parse ! omxh264dec ! nvoverlaysink</code>
+
Add support for Jetpack5.1.1.
  
*Capturing FHD still image  
+
*20230222
  
<code>gst-launch-1.0 v4l2src num-buffers=1 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080" ! jpegenc ! filesink location=jpgname.jpg</code>
+
Add support for Jetpack5.1.
====Video Control Toolkits Manual====
 
  
*i2c bus description:
+
*20220831
  
ADP-TX2-6CAM has 6 MIPI CSI-2 interface [A-F],the corresponding i2c address is[30-35].
+
Improve the description of VEYE series and MV series under Jetpack 5.0.2.
  
It is also the same as the 3X part of dmesg message:
+
* 20220824
  
<code>subdev veye327 3X-003b bound</code>
+
Add support for Jetpack5.0.2.
  
<code>subdev csimx307 3X-003b bound</code>
+
* 20220720
  
using -b option to identify which bus you want to use.
+
Add multimedia-api samples and v4l2 samples.
  
*VEYE-MIPI-327
+
*20220714
  
Video Control Toolkits Manual :[[VEYE-MIPI-290/327 i2c/|VEYE-MIPI-327 I2C]]
+
Add L4T32.7.2 Note。
  
*CS-MIPI-IMX307
+
* 20220629
  
Video Control Toolkits Manual :[[CS-MIPI-X i2c|CS-MIPI-IMX307 I2C]]
+
Add support for Jetpack 5.0.1DP and tune through AGX-Orin.
===Realtimes RTSO-9001===
 
====Hardware Setup====
 
[[File:CS-MIPI-307 to ruitai 9001tx2.jpg|center|thumb|800x800px|CS-MIPI-IMX307 and RTSO-9001(TX2)|link=http://wiki.veye.cc/index.php/File:CS-MIPI-307_to_ruitai_9001tx2.jpg]]
 
  
 +
* 20220110
  
Matching with Realtimes RTSO-9001, you need to use RTST-RPI adapter board.
+
Add VEYE-MIPI-IMX385 support.
  
Note: the power supply capacity of the MIPI CSI-2 interface of the current version of RTSO-9001 is not enough to support the power requirements of our camera, which requires an additional 5V power supply to the camera. It is not shown in the picture above.
+
* 20220105
====Software bsp====
 
  
*The corresponding directory for Realtimes RTSO-9001, is:
+
Use nvv4l2h264enc instead of omxh264enc in gstreamer command,because omxh264enc  has been deprecated.
  
nvidia_jetson_veye_bsp\TX2\JetPack_4.2.2_Linux_RTSO-9001
+
* 20211025
  
*Subject to the agreement with Ruitai, we do not release the source code
+
Use nvcamerasrc instead of v4l2src in gstreamer command , and the data goes directly into DMA memory.
*Our code have been submitted to Realtimes, and customers are advised to contact Realtimes for a complete version of the supported image.
 
  
 
===References===
 
===References===
 
Jetson start up: https://developer.nvidia.com/embedded/learn/getting-started-jetson
 
Jetson start up: https://developer.nvidia.com/embedded/learn/getting-started-jetson
 +
 +
Jetson Download Center: https://developer.nvidia.com/embedded/downloads
 +
 +
Xavier NX: https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit
  
 
TX2 development kit: https://developer.nvidia.com/embedded/jetson-tx2-developer-kit
 
TX2 development kit: https://developer.nvidia.com/embedded/jetson-tx2-developer-kit
Line 301: Line 458:
 
SDK Manager: https://docs.nvidia.com/sdk-manager/index.html
 
SDK Manager: https://docs.nvidia.com/sdk-manager/index.html
  
TX2 user guide: [https://developer.download.nvidia.cn/embedded/L4T/r28_Release_v2.0/GA/Docs/Jetson_TX1_and_TX2_Developer_Kits_User_Guide.pdf?lumI95GW6BEyMmhP1Is8E79OYo105-tpsC2bOVQmBZ6Tw8AkLU4pSDMPCuzOaEonWMiDO2hliXbNvtkH9do81TNIXmLZGGoV7xoEehyEgfc2WO8e0Czz5chLSHoCqIuPLL1 link]
+
L4T Doc: https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3242/index.htm
  
Realtimes website:http://www.realtimes.cn/
+
TX2 user guide: [https://developer.download.nvidia.cn/embedded/L4T/r28_Release_v2.0/GA/Docs/Jetson_TX1_and_TX2_Developer_Kits_User_Guide.pdf?lumI95GW6BEyMmhP1Is8E79OYo105-tpsC2bOVQmBZ6Tw8AkLU4pSDMPCuzOaEonWMiDO2hliXbNvtkH9do81TNIXmLZGGoV7xoEehyEgfc2WO8e0Czz5chLSHoCqIuPLL1 link]<br />
<br />
 

Latest revision as of 15:10, 18 November 2024

查看中文

How to use VEYE and CS series camera module on NVIDIA Jetson Nano,TX2,Xavier and Orin

1 Overview

This guide shows how to use VEYE and CS series camera modules on Jetson boards. Jetson SDK Version is:

  • Jetpack4.2.2,L4T r32.2.1
  • Jetpack4.3,L4T r32.3.1
  • Jetpack4.4,L4T r32.4.3
  • Jetpack4.4.1,L4T r32.4.4
  • Jetpack4.5,L4T r32.5
  • Jetpack4.5.1,L4T r32.5.1
  • Jetpack4.6,L4T r32.6.1
  • Jetpack4.6.1, L4T r32.7.1
  • Jetpack4.6.2,L4T r32.7.2
  • Jetpack4.6.3,L4T r32.7.3
  • Jetpack4.6.4,L4T r32.7.4
  • Jetpack5.0.1DP, L4T r34.1.1
  • Jetpack5.0.2, L4T r35.1
  • Jetpack5.1,L4T r35.2.1
  • Jetpack5.1.1,L4T r35.3.1
  • Jetpack5.1.2,L4T r35.4.1
  • Jetpack5.1.3,L4T r35.5
  • Jetpack6.0,L4T r36.3
  • Jetpack6.1,L4T r36.4

We provide two ways to do so: Prebuilt Binaries or Source Code. Yes, It's Open Source!

VEYE and CS series camera modules are camera module with ISP functions build in. It output UYVY data using MIPI-CSI2. We provide V4L2 interface for video streaming apps , and Video Control Toolkits (which is Shell Script) to control the camera module directly, which is called DRA(Directly Register Access).

1.1 Camera module list

Camera module dirver status list
Series Model Status
VEYE series VEYE-MIPI-IMX327S Done
VEYE series VEYE-MIPI-IMX385 Done
VEYE series VEYE-MIPI-IMX462 Done
VEYE series VEYE-MIPI-IMX335 Done
CS series CS-MIPI-IMX307 Done
CS series CS-MIPI-SC132 Done
TX2-XAVIER-nCAM Series CS-TX2-XAVIER-nCAM Done

1.2 How to check the current L4T version

1.2.1 Method 1

On Jetson board

cat /etc/nv_tegra_release

If it shows:

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

It means L4t Version is 32.4.3

1.2.2 Method 2

Refer to this link to install jetson-stats:

jtop

2 Hardware Setup

We have designed a 6cam interposer board for TX2 devkit,Xavier and Orin, It support up to 6 cameras at the same time.

6cam interposer board connected with 6 cameras
6cam interposer board connected with 6 cameras


In particular, the VEYE-MIPI-IMX335 must use a 12V DC terminal to provide auxiliary power due to its high power consumption. Refer to J11 of ADP-N1.

2.1 NVIDIA TX2 Developer Kit

It is connected as shown in figure:

TX2 Devkit 6 cameras connection
TX2 Devkit 6 cameras connection


Be sure to screw the ADP adapter board to the bottom board.

2.2 NVIDIA AGX Xavier(the same with Orin)


Connect VEYE cameras to AGX Xavier
Connect VEYE cameras to AGX Xavier


Be sure to screw the ADP adapter board to the bottom board to ensure that the adapter plate is installed flat.

2.3 NVIDIA Nano ,TX2 NX and Xavier NX Devkit

The Xavier NX interface is compatible with raspberry pi and Jetson Nano. The connection mode is shown in figure:

Xavier NX connection with VEYE-MIPI-327
Xavier NX connection with VEYE-MIPI-327


Xavier NX connection with CS-MIPI-IMX307
Xavier NX connection with CS-MIPI-IMX307
Jetson Nano A02 与VEYE模组连接
VEYE327 connection with Jetson Nano A02
VEYE camera  connection with Orin Nano and Orin NX

3 Upgrade Jetson system

This section describes how to upgrade the Jetson system to support MV camera module. For OS update method, please refer to Update Jetson OS.

4 Applications and Test

4.1 Check system status

Run the following command to confirm whether the camera is probed.

  • VEYE-MIPI-IMX327S/VEYE-MIPI-IMX462/VEYE-MIPI-IMX385(using VEYE-MIPI-CAM2M dtb)

dmesg | grep veye  

The output message appears as shown below:

camera id is veyecam

sensor is IMX327/IMX462/IMX385

subdev veyecam [i2c_bus]-003b bound

  • For CS-MIPI-IMX307

dmesg | grep csx307  

The output message appears as shown below.:

Detected CS307 sensor

subdev csx307 [i2c_bus]-003b bound

  • For CS-MIPI-SC132

dmesg | grep cssc132  

The output message appears as shown below.:

subdev cssc132 [i2c_bus]-003b bound

  • For VEYE-MIPI-IMX335

dmesg | grep imx335

The output message appears as shown below.:

camera id is VEYE-MIPI-IMX335

subdev veye_imx335 [i2c_bus]-003b bound

  • Run the following command to check the presence of video node.

ls /dev/video*

The output message appears as shown below.

videoX  

  • For VEYE-MIPI-327(using VEYE-MIPI-327 dtb)

dmesg | grep veye327  

The output message appears as shown below:

Detected VEYE327 sensor

subdev veye327 [i2c_bus]-003b bound

The [i2c_bus] in the driver prompt message indicates the i2c bus corresponding to this camera.

4.2 Video Stream Toolkits Manual

The camera appears as /dev/videoX device node,where X is between [0-5].

During the Linux boot process, the cameras are detected in the order of i2c bus from smallest to largest. For example, if only one camera is connected, X is 0 regardless of the hardware connection to the location. If 5 cameras are connected, X is reflected as [0-4] according to i2c bus from smallest to largest.

In gstreamer command ,v4l2src and nvv4l2camerasrc has a param device=/dev/videoX to identify which camera to use.

4.2.1 Gstreamer Usage

To install the latest accelerated gstreamer plugins and applications, run the following commands:

sudo apt-get update

sudo apt-get install nvidia-l4t-gstreamer

sudo ldconfig

rm -rf .cache/gstreamer-1.0/


export DISPLAY=:0

  • Preview FHD

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

  • Preview FHD(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

  • Preview 720p@60 (CS-MIPI-IMX307)

gst-launch-1.0 nvv4l2camerasrc ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1280, height=(int)720, framerate=(fraction)60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false

  • Preview 1280*1080@45 (CS-MIPI-SC132)

gst-launch-1.0 nvv4l2camerasrc ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1280, height=(int)1080, framerate=(fraction)45/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false

  • Preview 640*480p@130 (CS-MIPI-IMX307)

gst-launch-1.0 nvv4l2camerasrc ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)640, height=(int)480, framerate=(fraction)130/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! nv3dsink sync=false

  • Preview 2 cameras 1080p HD

WIDTH=960

HEIGHT=540

CAPS="video/x-raw(memory:NVMM),format=(string)UYVY, width=1920, height=1080"

gst-launch-1.0 nvcompositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_0::width=$WIDTH sink_0::height=$HEIGHT sink_1::xpos=$WIDTH sink_1::ypos=0 sink_1::width=$WIDTH sink_1::height=$HEIGHT ! nv3dsink nvv4l2camerasrc device=/dev/video0 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp. nvv4l2camerasrc device=/dev/video1 ! $CAPS ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420"! comp.

  • Record FHD in H.264 format to a video file

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 ! nvoverlaysink -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.jp

4.2.2 VEYE-MIPI-IMX335 gstreamer example

Since VEYE-MIPI-IMX335 supports only a few specific resolution modes, its driver we use use_sensor_mode_id mode.

VEYE-MIPI-IMX335 mode
./veye5_mipi_i2c.sh video mode v4l2-ctl sensor_mode video format
1 0 2592x1944@20fps
2 1 2592x1944@12.5fps
3 2 2560x1440@25fps
4 3 2560x1440@30fps
  • prepare

sudo apt-get install v4l-utils

Refer to the following section and download the veye5_mipi_i2c.sh tool.

  • 2592x1944@20fps mode preview, framerate statistics

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

./veye5_mipi_i2c.sh -w -f videomode -p1 1 -b [busnum]

v4l2-ctl -d /dev/video0 --set-ctrl preferred_stride=5376

Preview

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

Framerate statistics

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY,width=(int)2592,height=(int)1944" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420" ! fpsdisplaysink video-sink=fakesink -v

  • 2560x1440@30fps mode video encode and capture

v4l2-ctl -d /dev/video0 --set-ctrl sensor_mode=3

./veye5_mipi_i2c.sh -w -f videomode -p1 4 -b [busnum]

v4l2-ctl -d /dev/video0 --set-ctrl preferred_stride=5120

Video encode

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

Video Replay

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

Capture

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

4.2.3 Jetson multimedia-api samples

The Jetson Linux API is available on the Jetson platform for developers to use. Please refer to the official nVidia documentation for the installation of the jetson_multimedia_api package.

For VEYE and CS series cameras, the ISP function is already integrated in the camera, so you cannot use libargus to get data, but can directly use the standard V4L2 interface to get data from the /dev/videoX device file.

The following two samples can be run directly.

4.2.3.1 12_camera_v4l2_cuda

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

4.2.3.2 v4l2cuda

./capture-cuda -d /dev/video0 -f UYVY -m -o out.ppm -s 1920x1080 -c 1

4.2.4 v4l2-ctl Application Examples
4.2.4.1 install v4l2-utils

sudo apt-get install v4l-utils

4.2.4.2 Configure parameters using v4l2-ctl
  • List the data formats supported by the camera

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

  • Frame rate statistics

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

  • Save image to file

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

4.2.5 yavta
4.2.5.1 install yavta

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

cd yavta;make

4.2.5.2 Save image to file

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

4.2.6 Opencv

To import camera data from v4l2 devices to opencv, we provide several samples.

We provide 2 samples here.

4.3 Using i2c script to modify camera parameters

  • VEYE-MIPI-CAM2M Series(VEYE-MIPI-327、VEYE-MIPI-IMX327S、VEYE-MIPI-IMX462、VEYE-MIPI-IMX385)

Video Control Toolkits Manual :VEYE-MIPI-327 I2C

  • CS-MIPI-IMX307和CS-MIPI-SC132

Video Control Toolkits Manual :CS-MIPI-X I2C

  • VEYE-MIPI-IMX335

Video Control Toolkits Manual :VEYE-MIPI-IMX335 I2C

5 How to port the driver to a third party board

5.1 driver porting

For Image, we have added functionality to the official standard Image and have not made any deletions. In general, you can use our compiled Image directly. for special cases, please refer to the source code for integration.

For modules it is even easier to just use them. Compiling from source code and is very simple, so I won't go into details here.

5.2 dts porting

We only provide dtb for some boards of Nano, TX2, Xavier, Orin. For the types not provided, it is necessary to:

1. get the dts source code of that board.

2. put our camera related dts to the whole.

3. recompile to get the dtb of the corresponding board.

The operation steps are not complicated, but there are some third-party base board manufacturers do not open dts source code. This will require the cooperation of all parties to do so.

6 FAQ and bug list

6.1 VEYE cameras on Jetpack5.x

Jetpack5.x has more stringent requirements for mipi signals in xavier and orin platforms. VEYE-MIPI-xxx series cameras need firmware hdver>=7 to be perfectly supported.

6.2 CS-MIPI-IMX307 combined with Orin nano and Orin NX Green Screen

When CS-MIPI-IMX307 is powered by the 3.3V mode of the FFC cable, the MIPI receiver state machine of Orin nano and Orin NX (Jetpack5.1.1) will enter an incorrect state.

It is recommended to refer to this article and modify the power supply mode of CS-MIPI-IMX307 to use the 5V power supply mode.

6.3 Jetpack5.0.1 DP

This version has many bugs, such as not supporting nvv4l2camerasrc, not recommended to use.

6.4 nv3dsink

Jetpack 5.x no longer supports nvoverlaysink, use nv3dsink instead.

7 Document History

  • 2024-08-06

Make Chapter 3 - Upgrading the Jetson system a separate article.

  • 2024-05-22

Add support for Jetpack5.1.3.

  • 20230427

Add support for Jetpack5.1.1.

  • 20230222

Add support for Jetpack5.1.

  • 20220831

Improve the description of VEYE series and MV series under Jetpack 5.0.2.

  • 20220824

Add support for Jetpack5.0.2.

  • 20220720

Add multimedia-api samples and v4l2 samples.

  • 20220714

Add L4T32.7.2 Note。

  • 20220629

Add support for Jetpack 5.0.1DP and tune through AGX-Orin.

  • 20220110

Add VEYE-MIPI-IMX385 support.

  • 20220105

Use nvv4l2h264enc instead of omxh264enc in gstreamer command,because omxh264enc has been deprecated.

  • 20211025

Use nvcamerasrc instead of v4l2src in gstreamer command , and the data goes directly into DMA memory.

8 References

Jetson start up: https://developer.nvidia.com/embedded/learn/getting-started-jetson

Jetson Download Center: https://developer.nvidia.com/embedded/downloads

Xavier NX: https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit

TX2 development kit: https://developer.nvidia.com/embedded/jetson-tx2-developer-kit

SDK Manager: https://docs.nvidia.com/sdk-manager/index.html

L4T Doc: https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3242/index.htm

TX2 user guide: link