Image quality issues when capturing 13mp yuv on Jetson Xavier AGX

We are working on a camera system with ap1302, and Xavier AGX and are having image quailty issues when streaming
at 4208x3120 resolution.

The device tree and driver we made following the Sensor Software Driver Programming guide.

Device tree:
ap1302.dtsi (4.1 KB)

For calculating pix_clk_hz we used (data_rate*num_lanes)/bpp for all supported modes. Is this correct?

We are using gst-launch-1.0 and v4l2-ctrl to capture stream:

  • v4l2-ctl --set-fmt-video=width=4208,height=3120,pixelformat=YUYV --stream-mmap -d /dev/video0 --stream-count=50
  • gst-launch-1.0 v4l2src device=/dev/video0 ! “video/x-raw,width=4208,height=3120,format=YUY2” ! xvimagesink

Result of v4l2-ctrl --list-formats-ext:

ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'YUYV'
	Name        : YUYV 4:2:2
		Size: Discrete 4192x3120
			Interval: Discrete 0.050s (20.000 fps)
		Size: Discrete 4208x3120
			Interval: Discrete 0.050s (20.000 fps)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (30.000 fps)

When streaming at 3840x2160 and 4192x3120 the image quality is good:

But at 13mp(4208x3120) we get quality issues. It seems like every second row is offset by 16 pixels, it is noticeable around edges and there is a green line 16 pixel wide(missing pixels) at the right border:

We boost the nvcsi, isp and vi clocks to max values always and the logs look like this:

trace.log (35.8 KB)

for the most part. Occasionally there is a CHANSEL_NOMATCH with code 0x3c9 when streaming at max resolution.

Our configuration does not have these issues in our reference system.

Could something like this be related to vi or nvcsi?

How about reduce the frame rate to try?

I have tried reducing the frame rate. The problem is still there.
Here is a raw image captured using v4l2-ctl method.

4208x3120.yuv (25.0 MB)

At the end of every second line there are 16 pixels all set to zero.

I have found more forum posts that report the same image issues.

It seems to be a problem with alignment but I can’t find any info on what the constrain is.
Why is the image okay at 4192 width and not at 4208? Is there a way to make 4208 work?

I have also tried the solution from this post:

prefered_stride 256 had no effect. I’m not sure i understand the setting. What does it do? Is it even enabled?

Tegra release version:
# R32 (release), REVISION: 5.2, GCID: 27767740, BOARD: t186ref, EABI: aarch64, DATE: Fri Jul 9 16:05:07 UTC 2021

Could you try the size have 64 alignment.

Tried the folowing:

  • 4192x3120 image is clear
  • 4224x3120 image is clear

4224 is 64 aligned but 4192 is not. Why is 4192x3120 working? How do I make 4208x3120 work?

Could you try prefered_stride as 32, 263, 526

v4l2-ctl --set-ctrl prefered_stride = 32

Using v4l2-ctl for capture, like this:

v4l2-ctl --set-fmt-video=width=4208,height=3120,pixelformat=UYVY --stream-mmap -d /dev/video0 --stream-count=10 --set-ctrl preferred_stride=526 --stream-to=stride-test.yuv

and vooya for checking.

No changes in image quality for all suggested stride values.

Looks like need 32 alignment for the VI engine.

Can that be changed? Setting preferred stride with v4l2-ctl yields no results. Do I need to edit something in tegra drivers and if so what? How do I set it to 16?

Try remove below code from the …/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c to verify.

*height = clamp(*height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT);

Removing this line doesn’t help. Is there something else that I can change?

Please checking the VI driver if able to configure it as your wish. Otherwise I think it’s VI limitation for Jetson platform.

v4l2-ctl --set-ctrl preferred_stride=8448 fixed the issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.