|
|
@ -54,8 +54,8 @@ using namespace gpu; |
|
|
|
class CV_GpuImageProcTest : public CvTest |
|
|
|
class CV_GpuImageProcTest : public CvTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
CV_GpuImageProcTest(const char* test_name, const char* test_funcs); |
|
|
|
CV_GpuImageProcTest(const char* test_name, const char* test_funcs) : CvTest(test_name, test_funcs) {} |
|
|
|
virtual ~CV_GpuImageProcTest(); |
|
|
|
virtual ~CV_GpuImageProcTest() {} |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
void run(int); |
|
|
|
void run(int); |
|
|
@ -70,11 +70,6 @@ protected: |
|
|
|
int CheckNorm(const Mat& m1, const Mat& m2); |
|
|
|
int CheckNorm(const Mat& m1, const Mat& m2); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuImageProcTest::CV_GpuImageProcTest(const char* test_name, const char* test_funcs): CvTest(test_name, test_funcs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuImageProcTest::~CV_GpuImageProcTest() {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuImageProcTest::test8UC1(const Mat& img) |
|
|
|
int CV_GpuImageProcTest::test8UC1(const Mat& img) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -188,352 +183,284 @@ void CV_GpuImageProcTest::run( int ) |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// threshold
|
|
|
|
// threshold
|
|
|
|
class CV_GpuNppImageThresholdTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageThresholdTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
CV_GpuNppImageThresholdTest(); |
|
|
|
CV_GpuNppImageThresholdTest() : CV_GpuImageProcTest( "GPU-NppImageThreshold", "threshold" ) {} |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageThresholdTest::CV_GpuNppImageThresholdTest(): CV_GpuImageProcTest( "GPU-NppImageThreshold", "threshold" ) |
|
|
|
int test(const Mat& img) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageThresholdTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() != CV_32FC1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() != CV_32FC1) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
cv::RNG rng(*ts->get_rng()); |
|
|
|
} |
|
|
|
const double thresh = rng; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat cpuRes; |
|
|
|
cv::RNG rng(*ts->get_rng()); |
|
|
|
cv::threshold(img, cpuRes, thresh, 0.0, THRESH_TRUNC); |
|
|
|
const double thresh = rng; |
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
cv::Mat cpuRes; |
|
|
|
GpuMat gpuRes; |
|
|
|
cv::threshold(img, cpuRes, thresh, 0.0, THRESH_TRUNC); |
|
|
|
cv::gpu::threshold(gpu1, gpuRes, thresh); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CheckNorm(cpuRes, gpuRes); |
|
|
|
GpuMat gpu1(img); |
|
|
|
} |
|
|
|
GpuMat gpuRes; |
|
|
|
|
|
|
|
cv::gpu::threshold(gpu1, gpuRes, thresh); |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageThresholdTest CV_GpuNppImageThreshold_test; |
|
|
|
return CheckNorm(cpuRes, gpuRes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// resize
|
|
|
|
// resize
|
|
|
|
class CV_GpuNppImageResizeTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
CV_GpuNppImageResizeTest() : CV_GpuImageProcTest( "GPU-NppImageResize", "resize" ) {} |
|
|
|
CV_GpuNppImageResizeTest(); |
|
|
|
int test(const Mat& img) |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageResizeTest::CV_GpuNppImageResizeTest(): CV_GpuImageProcTest( "GPU-NppImageResize", "resize" ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageResizeTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int interpolations[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4}; |
|
|
|
int interpolations[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_LANCZOS4}; |
|
|
|
const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LANCZOS4"}; |
|
|
|
const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LANCZOS4"}; |
|
|
|
int interpolations_num = sizeof(interpolations) / sizeof(int); |
|
|
|
int interpolations_num = sizeof(interpolations) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
int test_res = CvTS::OK; |
|
|
|
int test_res = CvTS::OK; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < interpolations_num; ++i) |
|
|
|
for (int i = 0; i < interpolations_num; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nInterpolation type: %s\n", interpolations_str[i]); |
|
|
|
ts->printf(CvTS::LOG, "\nInterpolation type: %s\n", interpolations_str[i]); |
|
|
|
|
|
|
|
|
|
|
|
Mat cpu_res; |
|
|
|
|
|
|
|
cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img), gpu_res; |
|
|
|
Mat cpu_res; |
|
|
|
cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]); |
|
|
|
cv::resize(img, cpu_res, Size(), 0.5, 0.5, interpolations[i]); |
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpu_res, gpu_res) != CvTS::OK) |
|
|
|
GpuMat gpu1(img), gpu_res; |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return test_res; |
|
|
|
if (CheckNorm(cpu_res, gpu_res) != CvTS::OK) |
|
|
|
} |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//CV_GpuNppImageResizeTest CV_GpuNppImageResize_test;
|
|
|
|
return test_res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// copyMakeBorder
|
|
|
|
// copyMakeBorder
|
|
|
|
class CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
CV_GpuNppImageCopyMakeBorderTest() : CV_GpuImageProcTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" ) {} |
|
|
|
CV_GpuNppImageCopyMakeBorderTest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageCopyMakeBorderTest::CV_GpuNppImageCopyMakeBorderTest(): CV_GpuImageProcTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" ) |
|
|
|
int test(const Mat& img) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageCopyMakeBorderTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
cv::RNG rng(*ts->get_rng()); |
|
|
|
} |
|
|
|
int top = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int botton = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int left = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int right = rng.uniform(1, 10); |
|
|
|
|
|
|
|
cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat cpudst; |
|
|
|
cv::RNG rng(*ts->get_rng()); |
|
|
|
cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val); |
|
|
|
int top = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int botton = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int left = rng.uniform(1, 10); |
|
|
|
|
|
|
|
int right = rng.uniform(1, 10); |
|
|
|
|
|
|
|
cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)); |
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
Mat cpudst; |
|
|
|
GpuMat gpudst;
|
|
|
|
cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val); |
|
|
|
cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CheckNorm(cpudst, gpudst); |
|
|
|
GpuMat gpu1(img); |
|
|
|
} |
|
|
|
GpuMat gpudst;
|
|
|
|
|
|
|
|
cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val); |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test; |
|
|
|
return CheckNorm(cpudst, gpudst); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// warpAffine
|
|
|
|
// warpAffine
|
|
|
|
class CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
CV_GpuNppImageWarpAffineTest() : CV_GpuImageProcTest( "GPU-NppImageWarpAffine", "warpAffine" ) {} |
|
|
|
CV_GpuNppImageWarpAffineTest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
int test(const Mat& img) |
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageWarpAffineTest::CV_GpuNppImageWarpAffineTest(): CV_GpuImageProcTest( "GPU-NppImageWarpAffine", "warpAffine" ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageWarpAffineTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() == CV_32SC1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() == CV_32SC1) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
static const double coeffs[2][3] =
|
|
|
|
} |
|
|
|
{
|
|
|
|
|
|
|
|
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
|
|
|
|
static const double coeffs[2][3] =
|
|
|
|
{sin(3.14 / 6), cos(3.14 / 6), -100.0} |
|
|
|
{
|
|
|
|
}; |
|
|
|
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
|
|
|
|
Mat M(2, 3, CV_64F, (void*)coeffs); |
|
|
|
{sin(3.14 / 6), cos(3.14 / 6), -100.0} |
|
|
|
|
|
|
|
}; |
|
|
|
int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP}; |
|
|
|
Mat M(2, 3, CV_64F, (void*)coeffs); |
|
|
|
const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"}; |
|
|
|
|
|
|
|
int flags_num = sizeof(flags) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int test_res = CvTS::OK; |
|
|
|
int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP}; |
|
|
|
|
|
|
|
const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"}; |
|
|
|
|
|
|
|
int flags_num = sizeof(flags) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < flags_num; ++i) |
|
|
|
int test_res = CvTS::OK; |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat cpudst; |
|
|
|
for (int i = 0; i < flags_num; ++i) |
|
|
|
cv::warpAffine(img, cpudst, M, img.size(), flags[i]); |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]); |
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
Mat cpudst; |
|
|
|
GpuMat gpudst; |
|
|
|
cv::warpAffine(img, cpudst, M, img.size(), flags[i]); |
|
|
|
cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return test_res; |
|
|
|
GpuMat gpu1(img); |
|
|
|
} |
|
|
|
GpuMat gpudst; |
|
|
|
|
|
|
|
cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;
|
|
|
|
return test_res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// warpPerspective
|
|
|
|
// warpPerspective
|
|
|
|
class CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
CV_GpuNppImageWarpPerspectiveTest() : CV_GpuImageProcTest( "GPU-NppImageWarpPerspective", "warpPerspective" ) {} |
|
|
|
CV_GpuNppImageWarpPerspectiveTest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageWarpPerspectiveTest::CV_GpuNppImageWarpPerspectiveTest(): CV_GpuImageProcTest( "GPU-NppImageWarpPerspective", "warpPerspective" ) |
|
|
|
int test(const Mat& img) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageWarpPerspectiveTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() == CV_32SC1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() == CV_32SC1) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
static const double coeffs[3][3] =
|
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
|
|
|
|
static const double coeffs[3][3] =
|
|
|
|
{sin(3.14 / 6), cos(3.14 / 6), -100.0},
|
|
|
|
{ |
|
|
|
{0.0, 0.0, 1.0} |
|
|
|
{cos(3.14 / 6), -sin(3.14 / 6), 100.0},
|
|
|
|
}; |
|
|
|
{sin(3.14 / 6), cos(3.14 / 6), -100.0},
|
|
|
|
Mat M(3, 3, CV_64F, (void*)coeffs); |
|
|
|
{0.0, 0.0, 1.0} |
|
|
|
|
|
|
|
}; |
|
|
|
int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP}; |
|
|
|
Mat M(3, 3, CV_64F, (void*)coeffs); |
|
|
|
const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"}; |
|
|
|
|
|
|
|
int flags_num = sizeof(flags) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int test_res = CvTS::OK; |
|
|
|
int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP}; |
|
|
|
|
|
|
|
const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"}; |
|
|
|
|
|
|
|
int flags_num = sizeof(flags) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < flags_num; ++i) |
|
|
|
int test_res = CvTS::OK; |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat cpudst; |
|
|
|
for (int i = 0; i < flags_num; ++i) |
|
|
|
cv::warpPerspective(img, cpudst, M, img.size(), flags[i]); |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]); |
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
Mat cpudst; |
|
|
|
GpuMat gpudst; |
|
|
|
cv::warpPerspective(img, cpudst, M, img.size(), flags[i]); |
|
|
|
cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
GpuMat gpu1(img); |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
GpuMat gpudst; |
|
|
|
} |
|
|
|
cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]); |
|
|
|
|
|
|
|
|
|
|
|
return test_res; |
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
} |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;
|
|
|
|
return test_res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// integral
|
|
|
|
// integral
|
|
|
|
class CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
CV_GpuNppImageIntegralTest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageIntegralTest::CV_GpuNppImageIntegralTest(): CV_GpuImageProcTest( "GPU-NppImageIntegral", "integral" ) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
CV_GpuNppImageIntegralTest() : CV_GpuImageProcTest( "GPU-NppImageIntegral", "integral" ) {} |
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageIntegralTest::test(const Mat& img) |
|
|
|
int CV_GpuNppImageIntegralTest::test(const Mat& img) |
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() != CV_8UC1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() != CV_8UC1) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
Mat cpusum, cpusqsum; |
|
|
|
} |
|
|
|
cv::integral(img, cpusum, cpusqsum, CV_32S); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
Mat cpusum, cpusqsum; |
|
|
|
GpuMat gpusum, gpusqsum; |
|
|
|
cv::integral(img, cpusum, cpusqsum, CV_32S); |
|
|
|
cv::gpu::integral(gpu1, gpusum, gpusqsum); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpusqsum.convertTo(gpusqsum, CV_64F); |
|
|
|
GpuMat gpu1(img); |
|
|
|
|
|
|
|
GpuMat gpusum, gpusqsum; |
|
|
|
|
|
|
|
cv::gpu::integral(gpu1, gpusum, gpusqsum); |
|
|
|
|
|
|
|
|
|
|
|
int test_res = CvTS::OK; |
|
|
|
gpusqsum.convertTo(gpusqsum, CV_64F); |
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpusum, gpusum) != CvTS::OK) |
|
|
|
int test_res = CvTS::OK; |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nSum failed\n"); |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CheckNorm(cpusqsum, gpusqsum) != CvTS::OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nSquared sum failed\n"); |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return test_res; |
|
|
|
if (CheckNorm(cpusum, gpusum) != CvTS::OK) |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nSum failed\n"); |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CheckNorm(cpusqsum, gpusqsum) != CvTS::OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ts->printf(CvTS::LOG, "\nSquared sum failed\n"); |
|
|
|
|
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test; |
|
|
|
return test_res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// blur
|
|
|
|
// blur
|
|
|
|
class CV_GpuNppImageBlurTest : public CV_GpuImageProcTest |
|
|
|
struct CV_GpuNppImageBlurTest : public CV_GpuImageProcTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
CV_GpuNppImageBlurTest() : CV_GpuImageProcTest( "GPU-NppImageBlur", "blur" ) {} |
|
|
|
CV_GpuNppImageBlurTest(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
int test(const Mat& img) |
|
|
|
virtual int test(const Mat& img); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageBlurTest::CV_GpuNppImageBlurTest(): CV_GpuImageProcTest( "GPU-NppImageBlur", "blur" ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuNppImageBlurTest::test(const Mat& img) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
if (img.type() != CV_8UC1 && img.type() != CV_8UC4) |
|
|
|
return CvTS::OK; |
|
|
|
{ |
|
|
|
} |
|
|
|
ts->printf(CvTS::LOG, "\nUnsupported type\n"); |
|
|
|
|
|
|
|
return CvTS::OK; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ksizes[] = {3, 5, 7}; |
|
|
|
int ksizes[] = {3, 5, 7}; |
|
|
|
int ksizes_num = sizeof(ksizes) / sizeof(int); |
|
|
|
int ksizes_num = sizeof(ksizes) / sizeof(int); |
|
|
|
|
|
|
|
|
|
|
|
int test_res = CvTS::OK; |
|
|
|
int test_res = CvTS::OK; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ksizes_num; ++i) |
|
|
|
for (int i = 0; i < ksizes_num; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]); |
|
|
|
ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]); |
|
|
|
|
|
|
|
|
|
|
|
Mat cpudst; |
|
|
|
|
|
|
|
cv::blur(img, cpudst, Size(ksizes[i], ksizes[i])); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GpuMat gpu1(img); |
|
|
|
Mat cpudst; |
|
|
|
GpuMat gpudst; |
|
|
|
cv::blur(img, cpudst, Size(ksizes[i], ksizes[i])); |
|
|
|
cv::gpu::blur(gpu1, gpudst, Size(ksizes[i], ksizes[i])); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat c; |
|
|
|
GpuMat gpu1(img); |
|
|
|
cv::absdiff(cpudst, gpudst, c); |
|
|
|
GpuMat gpudst; |
|
|
|
|
|
|
|
cv::gpu::blur(gpu1, gpudst, Size(ksizes[i], ksizes[i])); |
|
|
|
|
|
|
|
|
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
cv::Mat c; |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
cv::absdiff(cpudst, gpudst, c); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return test_res; |
|
|
|
if (CheckNorm(cpudst, gpudst) != CvTS::OK) |
|
|
|
} |
|
|
|
test_res = CvTS::FAIL_GENERIC; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//CV_GpuNppImageBlurTest CV_GpuNppImageBlur_test;
|
|
|
|
return test_res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cvtColor
|
|
|
|
// cvtColor
|
|
|
|
class CV_GpuCvtColorTest : public CvTest |
|
|
|
class CV_GpuCvtColorTest : public CvTest |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
CV_GpuCvtColorTest(); |
|
|
|
CV_GpuCvtColorTest() : CvTest("GPU-NppCvtColor", "cvtColor") {} |
|
|
|
|
|
|
|
~CV_GpuCvtColorTest() {}; |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
void run(int); |
|
|
|
void run(int); |
|
|
@ -541,9 +468,6 @@ protected: |
|
|
|
int CheckNorm(const Mat& m1, const Mat& m2); |
|
|
|
int CheckNorm(const Mat& m1, const Mat& m2); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuCvtColorTest::CV_GpuCvtColorTest(): CvTest("GPU-NppCvtColor", "cvtColor") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2) |
|
|
|
int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -610,4 +534,19 @@ void CV_GpuCvtColorTest::run( int ) |
|
|
|
ts->set_failed_test_info(testResult); |
|
|
|
ts->set_failed_test_info(testResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CV_GpuCvtColorTest CV_GpuCvtColor_test; |
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////// tests registration /////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If we comment some tests, we may foget/miss to uncomment it after.
|
|
|
|
|
|
|
|
// Placing all test definitions in one place
|
|
|
|
|
|
|
|
// makes us know about what tests are commented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_GpuNppImageThresholdTest CV_GpuNppImageThreshold_test; |
|
|
|
|
|
|
|
CV_GpuNppImageResizeTest CV_GpuNppImageResize_test; |
|
|
|
|
|
|
|
CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test; |
|
|
|
|
|
|
|
CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test; |
|
|
|
|
|
|
|
CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test; |
|
|
|
|
|
|
|
CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test; |
|
|
|
|
|
|
|
CV_GpuNppImageBlurTest CV_GpuNppImageBlur_test; |
|
|
|
|
|
|
|
CV_GpuCvtColorTest CV_GpuCvtColor_test; |