Commit b181d78c authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

Added implementation and test for the GPU version of warpAffine,…

Added implementation and test for the GPU version of warpAffine, warpPerspective, rotate, based on NPP.
Renamed copyConstBorder to copyMakeBorder.
Fixed warnings when HAVE_CUDA is not defined.
parent b8753db5
......@@ -385,7 +385,7 @@ namespace cv
//! resizes the image
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4
CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR);
CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR);
//! computes sum of array elements
CV_EXPORTS Scalar sum(const GpuMat& m);
......@@ -394,9 +394,22 @@ namespace cv
CV_EXPORTS void minMax(const GpuMat& src, double* minVal, double* maxVal = 0);
//! copies 2D array to a larger destination array and pads borders with user-specifiable constant
CV_EXPORTS void copyConstBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
//! warps the image using affine transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
//! warps the image using perspective transformation
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);
//! rotate 8bit single or four channel image
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC
CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);
////////////////////////////// Image processing //////////////////////////////
// DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.
// xymap.type() == xymap.type() == CV_32FC1
CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);
......
This diff is collapsed.
......@@ -47,8 +47,8 @@ using namespace cv::gpu;
#if !defined (HAVE_CUDA)
void cv::gpu::remap( const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap ){ throw_nogpu(); }
void cv::gpu::meanShiftFiltering(const GpuMat&, GpuMat&, int, int, TermCriteria ) { throw_nogpu(); }
void cv::gpu::remap(const GpuMat&, GpuMat&, const GpuMat&, const GpuMat&){ throw_nogpu(); }
void cv::gpu::meanShiftFiltering(const GpuMat&, GpuMat&, int, int, TermCriteria) { throw_nogpu(); }
void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int) { throw_nogpu(); }
void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int, const Stream&) { throw_nogpu(); }
void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&) { throw_nogpu(); }
......
......@@ -687,20 +687,20 @@ CV_GpuNppImageMinNaxTest CV_GpuNppImageMinNax_test;
////////////////////////////////////////////////////////////////////////////////
// copyConstBorder
class CV_GpuNppImageCopyConstBorderTest : public CV_GpuNppImageArithmTest
class CV_GpuNppImageCopyMakeBorderTest : public CV_GpuNppImageArithmTest
{
public:
CV_GpuNppImageCopyConstBorderTest();
CV_GpuNppImageCopyMakeBorderTest();
protected:
virtual int test(const Mat& cpu1, const Mat& cpu2);
};
CV_GpuNppImageCopyConstBorderTest::CV_GpuNppImageCopyConstBorderTest(): CV_GpuNppImageArithmTest( "GPU-NppImageCopyConstBorder", "copyConstBorder" )
CV_GpuNppImageCopyMakeBorderTest::CV_GpuNppImageCopyMakeBorderTest(): CV_GpuNppImageArithmTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" )
{
}
int CV_GpuNppImageCopyConstBorderTest::test( const Mat& cpu1, const Mat& )
int CV_GpuNppImageCopyMakeBorderTest::test( const Mat& cpu1, const Mat& )
{
if (cpu1.type() != CV_8UC1 && cpu1.type() != CV_8UC4 && cpu1.type() != CV_32SC1)
return CvTS::OK;
......@@ -710,9 +710,88 @@ int CV_GpuNppImageCopyConstBorderTest::test( const Mat& cpu1, const Mat& )
GpuMat gpu1(cpu1);
GpuMat gpudst;
cv::gpu::copyConstBorder(gpu1, gpudst, 5, 5, 5, 5);
cv::gpu::copyMakeBorder(gpu1, gpudst, 5, 5, 5, 5);
return CheckNorm(cpudst, gpudst);
}
CV_GpuNppImageCopyConstBorderTest CV_GpuNppImageCopyConstBorder_test;
\ No newline at end of file
CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test;
////////////////////////////////////////////////////////////////////////////////
// warpAffine
class CV_GpuNppImageWarpAffineTest : public CV_GpuNppImageArithmTest
{
public:
CV_GpuNppImageWarpAffineTest();
protected:
virtual int test(const Mat& cpu1, const Mat& cpu2);
};
CV_GpuNppImageWarpAffineTest::CV_GpuNppImageWarpAffineTest(): CV_GpuNppImageArithmTest( "GPU-NppImageWarpAffine", "warpAffine" )
{
}
int CV_GpuNppImageWarpAffineTest::test( const Mat& cpu1, const Mat& )
{
static const double coeffs[2][3] =
{
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
{sin(3.14 / 6), cos(3.14 / 6), -100.0}
};
Mat M(2, 3, CV_64F, (void*)coeffs);
if (cpu1.type() == CV_32SC1)
return CvTS::OK;
Mat cpudst;
cv::warpAffine(cpu1, cpudst, M, cpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
GpuMat gpu1(cpu1);
GpuMat gpudst;
cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
return CheckNorm(cpudst, gpudst);
}
CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;
////////////////////////////////////////////////////////////////////////////////
// warpAffine
class CV_GpuNppImageWarpPerspectiveTest : public CV_GpuNppImageArithmTest
{
public:
CV_GpuNppImageWarpPerspectiveTest();
protected:
virtual int test(const Mat& cpu1, const Mat& cpu2);
};
CV_GpuNppImageWarpPerspectiveTest::CV_GpuNppImageWarpPerspectiveTest(): CV_GpuNppImageArithmTest( "GPU-NppImageWarpPerspective", "warpPerspective" )
{
}
int CV_GpuNppImageWarpPerspectiveTest::test( const Mat& cpu1, const Mat& )
{
static const double coeffs[3][3] =
{
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
{sin(3.14 / 6), cos(3.14 / 6), -100.0},
{0.0, 0.0, 1.0}
};
Mat M(3, 3, CV_64F, (void*)coeffs);
if (cpu1.type() == CV_32SC1)
return CvTS::OK;
Mat cpudst;
cv::warpPerspective(cpu1, cpudst, M, cpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
GpuMat gpu1(cpu1);
GpuMat gpudst;
cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
return CheckNorm(cpudst, gpudst);
}
CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment