Revision history [back]

cv::WarpPerspective & cv::cuda::WarpPerspective issue

Hi everyone

I encountered an issue using the warp perspective function. Up until today, i used the standard cv::warpPerspective function to create a Bird View of an image. I wanted to increase the performance of the algorithm so i shifted the calculation on the gpu using cuda::warperspective with exactly the same parameters. The output image is totally wrong, with the cuda function .... I don't understand where this error could come from ...

If you have any idea where the problem could come from, that would be awesome

GPU Image :

CPU Image :

The function doing the transform is presented below. The only change done to the code to create on of the image is the comment on the function used (either std cv::Warp or cv::cuda:warp)

The cv::Mat input image is a single channel image (L from Lab colorspace) which was transformed with a canny filter (using the gpu function as well)

static cv::Mat InversePerspectiveMapping(cv::Mat input, int w, int h, bool transform_order, bool display, int n) // w : width and h : height

cv::Mat output, M;  //create the output matrice

if (transform_order == true)    {M = cv::getPerspectiveTransform(src_pts, dst_pts); } // calculation of the transform matrix
else                {M = cv::getPerspectiveTransform(dst_pts, src_pts); } // Calculation of the inverse transfrom matrix

//cv::warpPerspective( input, output, M, cv::Size(w,h), INTER_LINEAR , BORDER_CONSTANT, 0 );

cv::cuda::GpuMat gpuInput = cv::cuda::GpuMat(input);
cv::cuda::warpPerspective( gpuInput, gpuInput, M, cv::Size(w,h), INTER_LINEAR , BORDER_CONSTANT, 0, Stream::Null() );
gpuInput.release();
imshow("left_IPM", output);
return output;


cv::WarpPerspective & cv::cuda::WarpPerspective issue

Hi everyone

I encountered an issue using the warp perspective function. Up until today, i used the standard cv::warpPerspective function to create a Bird View of an image. I wanted to increase the performance of the algorithm so i shifted the calculation on the gpu using cuda::warperspective with exactly the same parameters. The output image is totally wrong, with the cuda function .... I don't understand where this error could come from ...

If you have any idea where the problem could come from, that would be awesome

GPU Image :

CPU Image :

The function doing the transform is presented below. The only change done to the code to create on of the image is the comment on the function used (either std cv::Warp or cv::cuda:warp)

The cv::Mat input image is a single channel image (L from Lab colorspace) which was transformed with a canny filter (using the gpu function as well)

static cv::Mat InversePerspectiveMapping(cv::Mat input, int w, int h, bool transform_order, bool display, int n) // w : width and h : height

cv::Mat output, M;  //create the output matrice

if (transform_order == true)    {M = cv::getPerspectiveTransform(src_pts, dst_pts); } // calculation of the transform matrix
else                {M = cv::getPerspectiveTransform(dst_pts, src_pts); } // Calculation of the inverse transfrom matrix

//cv::warpPerspective( input, output, M, cv::Size(w,h), INTER_LINEAR , BORDER_CONSTANT, 0 );

cv::cuda::GpuMat gpuInput = cv::cuda::GpuMat(input);
cv::cuda::warpPerspective( gpuInput, gpuInput, M, cv::Size(w,h), INTER_LINEAR , BORDER_CONSTANT, 0, Stream::Null() );