Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to combine Color conversion(BGRA->BGR) and Remap? OpenCV

I want to convert a distorted BGRx image to undistorted BGR in one operation to prevent multiple data copying.

So

cv::Mat BGRx(720, 1280, CV_8UC4);  // (INPUT) comes from Gstreamer's vaapipostproc
cv::Mat map1, map2;                // 720x1600, calculated from Camera & Distortion matrix
cv::Mat BGR(720, 1600, CV_8UC3);   // (OUTPUT)

// 2-Step process
cv::Mat temp;
cv::cvtColor(BGRx, temp, CV_BGRA2BGR);
cv::remap(temp, BGR, map1, map2, cv::INTER_LINEAR);

Why I want to perform in single operation? Since both process are data copying process.

Why I want BGR output instead of BGRA? Because further image processing of output image will be less computationally expensive due to only 3-layers instead of 4.

How to combine Color conversion(BGRA->BGR) and Remap? OpenCV

I want to convert a distorted BGRx image to undistorted BGR in one operation to prevent multiple data copying.

So

cv::Mat BGRx(720, 1280, CV_8UC4);  // (INPUT) comes from Gstreamer's vaapipostproc
cv::Mat map1, map2;                // 720x1600, calculated from Camera & Distortion matrix
cv::Mat BGR(720, 1600, CV_8UC3);   // (OUTPUT)

// 2-Step process
cv::Mat temp;
cv::cvtColor(BGRx, temp, CV_BGRA2BGR);
cv::remap(temp, BGR, map1, map2, cv::INTER_LINEAR);

Why I want to perform in single operation? Since both process are data copying process.

Why I want BGR output instead of BGRA? Because further image processing of output image will be less computationally expensive due to only 3-layers instead of 4.

How to combine Color conversion(BGRA->BGR) and Remap? OpenCVRemap operations?

I want to convert a distorted BGRx image to undistorted BGR in one operation to prevent multiple data copying.

So

cv::Mat BGRx(720, 1280, CV_8UC4);  // (INPUT) comes from Gstreamer's vaapipostproc
cv::Mat map1, map2;                // 720x1600, calculated from Camera & Distortion matrix
cv::Mat BGR(720, 1600, CV_8UC3);   // (OUTPUT)

// 2-Step process
cv::Mat temp;
cv::cvtColor(BGRx, temp, CV_BGRA2BGR);
cv::remap(temp, BGR, map1, map2, cv::INTER_LINEAR);

Why I want to perform in single operation? Since both process are data copying process.process. I want to eliminate avoidable data copying.

Why I want BGR output instead of BGRA? Because further image processing of output image will be less computationally expensive due to only 3-layers instead of 4.