Xavier AGX - Test Pattern Generator color differences

Hi there,

I have been experimenting with the VI test pattern generators. However, I’m not able to get the same image out through v4l2-ctl and nvargus.

First I load the test patterns:
sudo insmod /lib/modules/5.10.104-tegra/kernel/drivers/media/platform/tegra/tpg/nvhost-vi-tpg-t19x.ko

V4L2 command:
v4l2-ctl --set-ctrl bypass_mode=0 --set-fmt-video=width=1920,height=1080,pixelformat="RG10" --device=/dev/video5 --stream-count=10 --stream-mmap --stream-to=tpg.raw

I then debayered this image with a small Python script:

import os
import cv2
import numpy as np

file_input = 'tpg.raw' if len(sys.argv) < 2 else sys.argv[1]
file_output = 'frame.png' if len(sys.argv) < 3 else sys.argv[2]

width = 1920
height = 1080
bpp = 10

def divide_frames(l, n): 
    for i in range(0, len(l), n):  
        yield l[i:i + n] 

with open(file_input, "rb") as raw_image:
    data = np.fromfile(raw_image, np.uint16, -1)

    for idx, image_data in enumerate(divide_frames(data, width*height)):
        img = image_data.reshape((height, width))

        # Pixels are stored as 16 bits, only 10 or 12 MSB are used
        # https://forums.developer.nvidia.com/t/how-to-decode-raw-images-saved-with-v4l-ctl/254459/8
        # Finally multiply the image to use the full range
        img = np.right_shift(img, 16 - bpp) * (2 ** 6)
        colour = cv2.demosaicing(img, cv2.COLOR_BAYER_BG2BGR)
        cv2.imwrite(file_output.replace(".png", f"-{idx}.png"), colour)

NvArgus command, disabled all processing as much as possible:
gst-launch-1.0 nvarguscamerasrc sensor-id=5 sensor-mode=2 num-buffers=1 ee-mode=0 tnr-mode=0 wbmode=0 aeantibanding=0 aelock=true aeregion="0 0 1000 1000 1" ! 'video/x-raw(memory:NVMM),width=(int)1920,height=(int)1080,format=NV12' ! nvvideoconvert ! pngenc ! filesink location=nvargus.png

I have removed all the files from /var/nvidia/nvcam/settings, but I still see many differences in the colors and sharpening still enabled.

I attached both images, you can see they look nothing alike.
I measured the RGB values in the raw.png that was taken with v4l2-ctl. Here the black, red, green, blue and white colors all have the appropriate RGB values if I measure them.

In the image generated from nvarguscamerasrc, the bottom left, which is supposed to light gray, turns fully white. The other colors mentioned before are also no longer correct.

How can I get the same picture through nvargus without it doing any color correction?

It’s different pipeline suppose the deviation is known.



Is there a way to disable the processing that is done by the ISP?
I seems there is some sharpening, white balance and gamma correction happening (and maybe black level correction?)

Try the nvargus_nvraw that should be less ISP effect.


Thanks for the quick reply! One more question, it seems that the nvargus-daemon is unable to find the camera_overrides files for the test patterns, I see the following errors:

Apr 30 08:10:38 FC410-200057 nvargus-daemon[17345]: initializeDevNode: Failed to open dev node '/dev/camera/video3'; No such file or directory, trying alternate default location
Apr 30 08:10:38 FC410-200057 nvargus-daemon[17345]: LSC: LSC surface is not based on full res!
Apr 30 08:10:38 FC410-200057 nvargus-daemon[17345]: ---- imager: No override file found. ----

How I can enable the overrides to work on the test pattern generator?

There’s no ISP override configuration for TPG.