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));
