How can we use dwImageCUDA to do AI inference without DriveWorks API?

We get CUDA Images from DW API by following code,

dwCameraFrameHandle_t frame = DW_NULL_HANDLE;
dwSensorCamera_returnFrame(&frame);
dwImageCUDA *rcbImage = nullptr;
dwSensorCamera_getImage(&frameRGBAinCUDA, 
DW_CAMERA_OUTPUT_CUDA_RGBA_UINT8, frame);
dwImage_getCUDA(&rcbImage, frameRGBAinCUDA);

How can we get the CUDA Image address to pass to the AI Model like YOLO?

I try to output the CUDA Image by copying the memory from CUDA to CPU and transfering to the OpenCV format with the following code,

uint8_t *imageBuffer = (uint8_t*)malloc(608*608*4*sizeof(uint8_t));
cudaMemcpy2DFromArray(imageBuffer, rcbImage->pitch[0], rcbImage->array[0], 0, 0, 608*4, 608, cudaMemcpyDeviceToHost);
cv::Mat mat_img(cv::Size(image.width, image.height), CV_8UC4, imageBuffer);
imwrite("test.jpg", mat_img);

But the output image is whole black.

How can we know the CUDA Image is correct and how can we do it right?

p.s. the CPU image we got from the following DW API is correct.

dwImageStreamer_consumerReceive(&frameCPU, timeout, 
m_streamerCUDAToCpuProcessed);
dwImage_getCPU(&imgCPU, frameCPU));

Dear @leepeter909,
Have you checked copying rcbImage.dptr[0] using cudamemcpy API calls to CPU and verify the data

Thanks for your quick reply!
No, I haven’t try that!
So the rcbImage.dptr[0] is the CUDA Image in the GPU instead of rcbImage.array[0]?

I have tried to copy rcbImage.dptr[0] to CPU and output with OpenCV.
It works! But the image looks weird!

The CPU Image I got from dwImage_getCPU API looks fine!
Is there any thing I can do to solve this?

Dear @leepeter909,
Could you please use your business email for better support.