Use vpi convert VPI_IMAGE_FORMAT_NV12 to VPI_IMAGE_FORMAT_BGRA8 failed

this is my code
bool convertNV12ToRGB(uint8_t* nv12Buf, int width, int height, int pitch, uint8_t* rgbBuf) {
VPIImage nv12Image = nullptr;
VPIImage bgraImage = nullptr;
VPIStream stream = nullptr;

if (vpiStreamCreate(VPI_BACKEND_CUDA, &stream) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create VPI stream”);
return false;
}

VPIImageData nv12Data{};
nv12Data.bufferType = VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR;
nv12Data.buffer.pitch.format = VPI_IMAGE_FORMAT_NV12;
nv12Data.buffer.pitch.numPlanes = 2;

nv12Data.buffer.pitch.planes[0].data = nv12Buf;
nv12Data.buffer.pitch.planes[0].width = width;
nv12Data.buffer.pitch.planes[0].height = height;
nv12Data.buffer.pitch.planes[0].pitchBytes = pitch;

nv12Data.buffer.pitch.planes[1].data = nv12Buf + pitch * height;
nv12Data.buffer.pitch.planes[1].width = width / 2;
nv12Data.buffer.pitch.planes[1].height = height / 2;
nv12Data.buffer.pitch.planes[1].pitchBytes = pitch;

if (vpiImageCreateWrapper(&nv12Data, nullptr, VPI_BACKEND_CUDA, &nv12Image) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create NV12 VPIImage”);
vpiStreamDestroy(stream);
return false;
}

if (vpiImageCreate(width, height, VPI_IMAGE_FORMAT_BGRA8, 0, &bgraImage) != VPI_SUCCESS) {
AIMRTE_ERROR(“Failed to create BGRA8 VPIImage”);
vpiImageDestroy(nv12Image);
vpiStreamDestroy(stream);
return false;
}

VPIConvertImageFormatParams params{};
vpiInitConvertImageFormatParams(&params);

if (vpiSubmitConvertImageFormat(stream, VPI_BACKEND_CUDA, nv12Image, bgraImage, &params) != VPI_SUCCESS) {
char err[256];
vpiGetLastStatusMessage(err, sizeof(err));
AIMRTE_ERROR(“Failed to submit NV12→BGRA conversion: {}”, err);
vpiImageDestroy(nv12Image);
vpiImageDestroy(bgraImage);
vpiStreamDestroy(stream);
return false;
}
but will be error
NV12→BGRA conversion: CUDA: Conversion not implemented between VPI_IMAGE_FORMAT_NV12 and VPI_IMAGE_FORMAT_BGRA8

*** Please note that this reply is generated by LLM automatically ***

The error message you’re encountering, “CUDA Conversion not implemented between VPIIMAGEFORMATNV12 and VPIIMAGEFORMATBGRA8,” indicates that the conversion from NV12 to BGRA8 format is not supported on the CUDA backend for the VPI (Vision Programming Interface) library on your Jetson Orin NX device.

Here’s a breakdown of the issue and potential solutions:

  1. Understanding the Formats: NV12 is a YUV (luminance and chrominance) format, while BGRA8 is a color format with blue, green, red, and alpha channels. The conversion between these formats involves color space conversion, which can be complex.

  2. VPI Library Limitations: The VPI library, which is designed for computer vision tasks, has specific limitations and support for different formats and conversions on various backends (e.g., CUDA, OpenCL, CPU). The error message suggests that the CUDA backend does not support the conversion from NV12 to BGRA8.

  3. Alternative Solutions:

    • Use a Different Backend: If possible, you might consider using a different backend that supports the NV12 to BGRA8 conversion, such as the CPU backend. However, this might come at the cost of performance.
    • Implement Custom Conversion: You could implement a custom conversion function from NV12 to BGRA8. This would require understanding the specifics of both formats and how to convert between them, which can be complex and might not be optimized for performance.
    • Use a Different Library or Tool: Depending on your specific requirements, you might find another library or tool that supports the conversion you need. For example, OpenCV is a powerful computer vision library that supports a wide range of image and video format conversions.
    • Update VPI Library: If the VPI library is updated to support the NV12 to BGRA8 conversion on the CUDA backend, updating to the latest version might resolve the issue.
  4. Performance Considerations: When choosing an alternative solution, consider the performance implications. CUDA, being a parallel computing platform, is designed to utilize the GPU for high-performance computing. If you switch to a CPU-based solution, you might experience a significant performance drop.

  5. Jetson Orin NX Specifics: The Jetson Orin NX is a powerful AI computing device with integrated GPU capabilities. While the error message indicates a limitation in the VPI library’s support for format conversion on the CUDA backend, exploring other libraries or tools that are optimized for NVIDIA hardware might provide a more efficient solution.

In summary, the error you’re encountering is due to the VPI library’s limitation in supporting the conversion from NV12 to BGRA8 on the CUDA backend. Exploring alternative solutions such as using a different backend, implementing a custom conversion, using another library, or updating the VPI library might help resolve the issue, but each comes with its own set of considerations regarding performance and complexity.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hi,

CUDA: Conversion not implemented between VPI_IMAGE_FORMAT_NV12 and VPI_IMAGE_FORMAT_BGRA8

As the error message indicates, the conversion is not supported.
You can find the support matrix in the link below.

GPU only supports NV12_ER to BGRA8.
But the VIC backend can work with NV12 to BGRA8.

Thanks.

tks bro
i will try use vic convert nv12 to nv12 er, then use cuda to RGB8 24bit .
thanks for reply

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