Artifact when color-converting with VPI on JETSON XAVIER only, driver issue?

My configuration is Jetson AGX Xavier running JetPack 4.5.1. VPI 1.0

I am seeing a green band of color at top of image (start of array) when using VPI to convert from RGB to NV12. This artifact is present whether I color-convert with VPI on CPU or with CUDA. This artifact is not present if I do color conversion on x86 CPU/GPU VPI. Could this be a power of two issue?

Please see pertinent code below and the artifact image attached.COLOR_YUV2RGB_NV12.bmp (5.9 MB)

Here is the code in question:

            cv::Mat cvMatData(frame->getHeight(), frame->getWidth(), CV_8UC3, outDataPtr);
            assert(cvMatData.type() == CV_8UC3);

#if !defined(_M_ARM) && !defined(__aarch64__)
            _frameBGR = ToVPIImage(_frameBGR, cvMatData);

            //convert to NV12 on CPU
            CHECK_STATUS(vpiSubmitConvertImageFormat(_stream, VPI_BACKEND_CPU, _frameBGR, _output, NULL));
#else

            cv::cuda::GpuMat cvGpuImage(cvMatData);

            VPIImageData imgData;
            memset(&imgData, 0, sizeof(imgData));
            imgData.format               = VPI_IMAGE_FORMAT_BGR8;
            imgData.numPlanes            = 1;
            imgData.planes[0].width      = cvGpuImage.cols;
            imgData.planes[0].height     = cvGpuImage.rows;
            imgData.planes[0].pitchBytes = cvGpuImage.step;
            imgData.planes[0].data       = cvGpuImage.data;
            CHECK_STATUS(vpiImageCreateCUDAMemWrapper(&imgData, VPI_BACKEND_CUDA, &_frameBGR));

        
            //convert to NV12 on GPU
            CHECK_STATUS(vpiSubmitConvertImageFormat(_stream, VPI_BACKEND_CUDA, _frameBGR, _output, NULL));
#endif
            //block to finish conversion
            CHECK_STATUS(vpiStreamSync(_stream));

            // Lock output image to retrieve its data on cpu memory
            VPIImageData outData;
            CHECK_STATUS(vpiImageLock(_output, VPI_LOCK_READ, &outData));
            assert(outData.format == VPI_IMAGE_FORMAT_NV12_ER);

            cv::Mat cvOutData = cv::Mat(frame->getHeight() * 3/2, frame->getWidth(), CV_8UC1, outData.planes[0].data, outData.planes[0].pitchBytes);

            // VPI data is aligned for perf and cv::Mat ends up non-continuous, memcpy fixes the problem
            if (!cvOutData.isContinuous()){
                 cvOutData = cvOutData.clone();
            }

            // dump image
            cv::Mat rgb;
            cv::cvtColor(cvOutData,rgb,CV_YUV2RGB_NV12);
            cv::imwrite(rgb);

I confirmed that the issue is with the dimensions of the image being not power of 2, causing this issue. The artifact disappears once I set the image to a power of two width and height.

Hi,

We would like to check this issue internally.
Could you share the complete source and the testing video with us?

More, do you use Xavier or XavierNX?
(since this is the XaveirNX board)

Thanks.

Hi, the board is jetson agx xavier, not NG. Beoynd the code I have shared, there is nothing else to add, except that the image dimension is 640x480 and the conversion is from RGB to NV12.

It should be reproducible with vpi 1.0 and vpi 1.1.

The issue is most likely in vpi code specific to jetson, regardless of cpu and gpu being executed.

Hi,

On Jetson, VPI uses VIC to do the color format conversion.
https://docs.nvidia.com/vpi/algo_imageconv.html#algo_imageconv_limitations

And you will need an input with an even dimension due to VIC’s limitation.
Thanks.