tegra_multimedia_api stereo image undistort/rectify

I have a stereo camera setup I want to do stereo depth mapping on using VisionWorks. For nvx_demo_stereo_matching the images are assumed to be undistorted and rectified.

Is there a way to do the undistortion and rectification using Argus, or should I use OpenCV?

If I need to use OpenCV is there an easy way to create a cv::GpuMat from a CUeglFrame?

Answered my second question, you can declare a GpuMat with a cudaAllocMapped buffer:

Example:

float4 *frame[2];

if(!cudaAllocMapped((void**)&frame[0], (void**)&frame[1], shared->width * shared->height * sizeof(float4)) )
    ORIGINATE_ERROR("Failed to allocate CUDA memory for image\n");

/** Not shown, fill buffer with RGBAf image **/

cv::gpu::GpuMat gpu32(shared->height, shared->width, CV_32FC4, frame[1]);

cv::gpu::GpuMat gpu;
gpu32.convertTo(gpu, CV_8UC4);

cv::Mat rgb;
gpu.download(rgb);

cv::Mat bgr;
cv::cvtColor(rgb, bgr, cv::COLOR_RGB2BGR);

cv::imwrite("test.jpg", bgr);

Hi,

Here is a relevant topic for your reference:
https://devtalk.nvidia.com/default/topic/1027321/jetson-tx2/correct-camera-distortion-for-detectnet-camera/post/5225366/#5225366

Thanks.