Just to be clear,converted_buffer->dataPtr
point to raw frame data or the cropped object data in nvdspreprocess?
It’s the Scaled & converted buffer to processing width/height
.
char* src_data = (char*) malloc(surf_params->dataSize);
if(src_data == NULL) {
g_print("Error: failed to malloc src_data \n");
continue;
}
cudaMemcpy((void*)src_data,
(void*)surf_params->dataPtr,
surf_params->dataSize,
cudaMemcpyDeviceToHost);
cv::Mat frame(surf_params->height, surf_params->width,CV_8UC4 ,src_data, surf_params->pitch);
cv::Mat image_data(surf_params->height, surf_params->width,CV_8UC4 );
frame.copyTo(image_data);
cv::Mat outptut_image(surf_params->height, surf_params->width,CV_8UC3 );
cv::cvtColor(image_data,outptut_image, cv::COLOR_RGBA2BGR);
cv::imwrite("output.jpg",outptut_image);
Thanks a lot for your help, absolutely appreciate it. This code works and now i’m getting some proper image. But how can i use unified memory to avoid data copying?
If you want to avoid data copying, you need to do some researches on how OpenCV uses cuda buffers yourself. We don’t have demo for this scenario yet.
Thanks for your support. I can now access frame with unified memory. Im closing this topic now
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.