minor refactoring of GPU module and GPU tests
added gpu compare version for CMP_NE operation
This commit is contained in:
@@ -60,21 +60,23 @@ CV_GpuMeanShiftTest::CV_GpuMeanShiftTest(): CvTest( "GPU-MeanShift", "MeanShift"
|
||||
|
||||
void CV_GpuMeanShiftTest::run(int)
|
||||
{
|
||||
int spatialRad = 30;
|
||||
int colorRad = 30;
|
||||
int spatialRad = 30;
|
||||
int colorRad = 30;
|
||||
|
||||
cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");
|
||||
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");
|
||||
cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");
|
||||
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");
|
||||
|
||||
if (img.empty() || img_template.empty())
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
if (img.empty() || img_template.empty())
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
cv::Mat rgba;
|
||||
cvtColor(img, rgba, CV_BGR2BGRA);
|
||||
cv::Mat rgba;
|
||||
cvtColor(img, rgba, CV_BGR2BGRA);
|
||||
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat res;
|
||||
cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );
|
||||
if (res.type() != CV_8UC4)
|
||||
@@ -98,15 +100,27 @@ void CV_GpuMeanShiftTest::run(int)
|
||||
{
|
||||
const uchar& ch1 = res_line[result.channels()*i + k];
|
||||
const uchar& ch2 = ref_line[img_template.channels()*i + k];
|
||||
uchar diff = abs(ch1 - ch2);
|
||||
uchar diff = static_cast<uchar>(abs(ch1 - ch2));
|
||||
if (maxDiff < diff)
|
||||
maxDiff = diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxDiff > 0)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nMeanShift maxDiff = %d\n", maxDiff);
|
||||
ts->set_failed_test_info((maxDiff == 0) ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
}
|
||||
|
||||
CV_GpuMeanShiftTest CV_GpuMeanShift_test;
|
||||
CV_GpuMeanShiftTest CV_GpuMeanShift_test;
|
||||
|
@@ -81,7 +81,7 @@ protected:
|
||||
if (res < std::numeric_limits<double>::epsilon())
|
||||
return CvTS::OK;
|
||||
|
||||
ts->printf(CvTS::LOG, "\nNorm: %f\n", res);
|
||||
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", res);
|
||||
return CvTS::FAIL_GENERIC;
|
||||
}
|
||||
};
|
||||
@@ -116,7 +116,8 @@ void CV_GpuNppMorphogyTest::run( int )
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
@@ -174,7 +175,6 @@ protected:
|
||||
|
||||
CV_GpuDilateTest CV_GpuDilate_test;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Dilate
|
||||
class CV_GpuMorphExTest : public CV_GpuNppMorphogyTest
|
||||
|
@@ -132,7 +132,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(const Mat& m1, const Mat& m2)
|
||||
}
|
||||
else
|
||||
{
|
||||
ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);
|
||||
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
|
||||
return CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ int CV_GpuNppImageArithmTest::CheckNorm(double d1, double d2)
|
||||
}
|
||||
else
|
||||
{
|
||||
ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);
|
||||
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
|
||||
return CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
@@ -165,8 +165,14 @@ void CV_GpuNppImageArithmTest::run( int )
|
||||
//cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png");
|
||||
//cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png");
|
||||
|
||||
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
|
||||
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
|
||||
//cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
|
||||
//cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
|
||||
|
||||
cv::RNG rng(*ts->get_rng());
|
||||
cv::Size sz(200, 200);
|
||||
cv::Mat img_l(sz, CV_8UC3), img_r(sz, CV_8UC3);
|
||||
rng.fill(img_l, cv::RNG::UNIFORM, cv::Scalar::all(10), cv::Scalar::all(100));
|
||||
rng.fill(img_r, cv::RNG::UNIFORM, cv::Scalar::all(10), cv::Scalar::all(100));
|
||||
|
||||
if (img_l.empty() || img_r.empty())
|
||||
{
|
||||
@@ -174,32 +180,41 @@ void CV_GpuNppImageArithmTest::run( int )
|
||||
return;
|
||||
}
|
||||
|
||||
//run tests
|
||||
int testResult = test8UC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
try
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
//run tests
|
||||
int testResult = test8UC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
|
||||
testResult = test8UC4(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
testResult = test8UC4(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
|
||||
testResult = test32SC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
testResult = test32SC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
|
||||
testResult = test32FC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
testResult = test32FC1(img_l, img_r);
|
||||
if (testResult != CvTS::OK)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
ts->set_failed_test_info(testResult);
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -423,15 +438,15 @@ int CV_GpuNppImageThresholdTest::test( const Mat& cpu1, const Mat& )
|
||||
if (cpu1.type() != CV_32FC1)
|
||||
return CvTS::OK;
|
||||
|
||||
const double thresh = 0.5;
|
||||
const double maxval = 0.0;
|
||||
cv::RNG rng(*ts->get_rng());
|
||||
const double thresh = rng;
|
||||
|
||||
cv::Mat cpuRes;
|
||||
cv::threshold(cpu1, cpuRes, thresh, maxval, THRESH_TRUNC);
|
||||
cv::threshold(cpu1, cpuRes, thresh, 0.0, THRESH_TRUNC);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpuRes;
|
||||
cv::gpu::threshold(gpu1, gpuRes, thresh, maxval, THRESH_TRUNC);
|
||||
cv::gpu::threshold(gpu1, gpuRes, thresh);
|
||||
|
||||
return CheckNorm(cpuRes, gpuRes);
|
||||
}
|
||||
@@ -458,15 +473,30 @@ int CV_GpuNppImageCompareTest::test( const Mat& cpu1, const Mat& cpu2 )
|
||||
if (cpu1.type() != CV_32FC1)
|
||||
return CvTS::OK;
|
||||
|
||||
cv::Mat cpuRes;
|
||||
cv::compare(cpu1, cpu2, cpuRes, CMP_GT);
|
||||
int cmp_codes[] = {CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE};
|
||||
const char* cmp_str[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};
|
||||
int cmp_num = sizeof(cmp_codes) / sizeof(int);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpu2(cpu2);
|
||||
GpuMat gpuRes;
|
||||
cv::gpu::compare(gpu1, gpu2, gpuRes, CMP_GT);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
return CheckNorm(cpuRes, gpuRes);
|
||||
for (int i = 0; i < cmp_num; ++i)
|
||||
{
|
||||
cv::Mat cpuRes;
|
||||
cv::compare(cpu1, cpu2, cpuRes, cmp_codes[i]);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpu2(cpu2);
|
||||
GpuMat gpuRes;
|
||||
cv::gpu::compare(gpu1, gpu2, gpuRes, cmp_codes[i]);
|
||||
|
||||
if (CheckNorm(cpuRes, gpuRes) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nCompare operation: %s\n", cmp_str[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageCompareTest CV_GpuNppImageCompare_test;
|
||||
@@ -525,19 +555,28 @@ int CV_GpuNppImageNormTest::test( const Mat& cpu1, const Mat& cpu2 )
|
||||
if (cpu1.type() != CV_8UC1)
|
||||
return CvTS::OK;
|
||||
|
||||
double cpu_norm_inf = cv::norm(cpu1, cpu2, NORM_INF);
|
||||
double cpu_norm_L1 = cv::norm(cpu1, cpu2, NORM_L1);
|
||||
double cpu_norm_L2 = cv::norm(cpu1, cpu2, NORM_L2);
|
||||
int norms[] = {NORM_INF, NORM_L1, NORM_L2};
|
||||
const char* norms_str[] = {"NORM_INF", "NORM_L1", "NORM_L2"};
|
||||
int norms_num = sizeof(norms) / sizeof(int);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpu2(cpu2);
|
||||
double gpu_norm_inf = cv::gpu::norm(gpu1, gpu2, NORM_INF);
|
||||
double gpu_norm_L1 = cv::gpu::norm(gpu1, gpu2, NORM_L1);
|
||||
double gpu_norm_L2 = cv::gpu::norm(gpu1, gpu2, NORM_L2);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
return (CheckNorm(cpu_norm_inf, gpu_norm_inf) == CvTS::OK
|
||||
&& CheckNorm(cpu_norm_L1, gpu_norm_L1) == CvTS::OK
|
||||
&& CheckNorm(cpu_norm_L2, gpu_norm_L2) == CvTS::OK) ? CvTS::OK : CvTS::FAIL_GENERIC;
|
||||
for (int i = 0; i < norms_num; ++i)
|
||||
{
|
||||
double cpu_norm = cv::norm(cpu1, cpu2, norms[i]);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpu2(cpu2);
|
||||
double gpu_norm = cv::gpu::norm(gpu1, gpu2, norms[i]);
|
||||
|
||||
if (CheckNorm(cpu_norm, gpu_norm) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nNorm type: %s\n", norms_str[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageNormTest CV_GpuNppImageNorm_test;
|
||||
@@ -562,20 +601,29 @@ int CV_GpuNppImageFlipTest::test( const Mat& cpu1, const Mat& )
|
||||
if (cpu1.type() != CV_8UC1 && cpu1.type() != CV_8UC4)
|
||||
return CvTS::OK;
|
||||
|
||||
Mat cpux, cpuy, cpub;
|
||||
cv::flip(cpu1, cpux, 0);
|
||||
cv::flip(cpu1, cpuy, 1);
|
||||
cv::flip(cpu1, cpub, -1);
|
||||
int flip_codes[] = {0, 1, -1};
|
||||
const char* flip_axis[] = {"X", "Y", "Both"};
|
||||
int flip_codes_num = sizeof(flip_codes) / sizeof(int);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpux, gpuy, gpub;
|
||||
cv::gpu::flip(gpu1, gpux, 0);
|
||||
cv::gpu::flip(gpu1, gpuy, 1);
|
||||
cv::gpu::flip(gpu1, gpub, -1);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
return (CheckNorm(cpux, gpux) == CvTS::OK &&
|
||||
CheckNorm(cpuy, gpuy) == CvTS::OK &&
|
||||
CheckNorm(cpub, gpub) == CvTS::OK) ? CvTS::OK : CvTS::FAIL_GENERIC;
|
||||
for (int i = 0; i < flip_codes_num; ++i)
|
||||
{
|
||||
Mat cpu_res;
|
||||
cv::flip(cpu1, cpu_res, flip_codes[i]);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpu_res;
|
||||
cv::gpu::flip(gpu1, gpu_res, flip_codes[i]);
|
||||
|
||||
if (CheckNorm(cpu_res, gpu_res) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nFlip Axis: %s\n", flip_axis[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageFlipTest CV_GpuNppImageFlip_test;
|
||||
@@ -600,25 +648,28 @@ int CV_GpuNppImageResizeTest::test( const Mat& cpu1, const Mat& )
|
||||
if (cpu1.type() != CV_8UC1 && cpu1.type() != CV_8UC4)
|
||||
return CvTS::OK;
|
||||
|
||||
Mat cpunn, cpulin, cpucub, cpulanc;
|
||||
cv::resize(cpu1, cpunn, Size(), 0.5, 0.5, INTER_NEAREST);
|
||||
cv::resize(cpu1, cpulin, Size(), 0.5, 0.5, INTER_LINEAR);
|
||||
cv::resize(cpu1, cpucub, Size(), 0.5, 0.5, INTER_CUBIC);
|
||||
cv::resize(cpu1, cpulanc, Size(), 0.5, 0.5, INTER_LANCZOS4);
|
||||
int interpolations[] = {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);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpunn, gpulin, gpucub, gpulanc;
|
||||
cv::gpu::resize(gpu1, gpunn, Size(), 0.5, 0.5, INTER_NEAREST);
|
||||
cv::gpu::resize(gpu1, gpulin, Size(), 0.5, 0.5, INTER_LINEAR);
|
||||
cv::gpu::resize(gpu1, gpucub, Size(), 0.5, 0.5, INTER_CUBIC);
|
||||
cv::gpu::resize(gpu1, gpulanc, Size(), 0.5, 0.5, INTER_LANCZOS4);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
int nnres =CheckNorm(cpunn, gpunn);
|
||||
int linres = CheckNorm(cpulin, gpulin);
|
||||
int cubres = CheckNorm(cpucub, gpucub);
|
||||
int lancres = CheckNorm(cpulanc, gpulanc);
|
||||
for (int i = 0; i < interpolations_num; ++i)
|
||||
{
|
||||
Mat cpu_res;
|
||||
cv::resize(cpu1, cpu_res, Size(), 0.5, 0.5, interpolations[i]);
|
||||
|
||||
return (nnres == CvTS::OK && linres == CvTS::OK && cubres == CvTS::OK && lancres == CvTS::OK) ? CvTS::OK : CvTS::FAIL_GENERIC;
|
||||
GpuMat gpu1(cpu1), gpu_res;
|
||||
cv::gpu::resize(gpu1, gpu_res, Size(), 0.5, 0.5, interpolations[i]);
|
||||
|
||||
if (CheckNorm(cpu_res, gpu_res) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nInterpolation type: %s\n", interpolations_str[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageResizeTest CV_GpuNppImageResize_test;
|
||||
@@ -744,14 +795,29 @@ int CV_GpuNppImageWarpAffineTest::test( const Mat& cpu1, const Mat& )
|
||||
if (cpu1.type() == CV_32SC1)
|
||||
return CvTS::OK;
|
||||
|
||||
Mat cpudst;
|
||||
cv::warpAffine(cpu1, cpudst, M, cpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
|
||||
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);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpudst;
|
||||
cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
return CheckNorm(cpudst, gpudst);
|
||||
for (int i = 0; i < flags_num; ++i)
|
||||
{
|
||||
Mat cpudst;
|
||||
cv::warpAffine(cpu1, cpudst, M, cpu1.size(), flags[i]);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpudst;
|
||||
cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);
|
||||
|
||||
if (CheckNorm(cpudst, gpudst) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nFlags: %s\n", flags_str[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;
|
||||
@@ -784,14 +850,29 @@ int CV_GpuNppImageWarpPerspectiveTest::test( const Mat& cpu1, const Mat& )
|
||||
if (cpu1.type() == CV_32SC1)
|
||||
return CvTS::OK;
|
||||
|
||||
Mat cpudst;
|
||||
cv::warpPerspective(cpu1, cpudst, M, cpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
|
||||
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);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpudst;
|
||||
cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), INTER_CUBIC | WARP_INVERSE_MAP);
|
||||
int test_res = CvTS::OK;
|
||||
|
||||
return CheckNorm(cpudst, gpudst);
|
||||
for (int i = 0; i < flags_num; ++i)
|
||||
{
|
||||
Mat cpudst;
|
||||
cv::warpPerspective(cpu1, cpudst, M, cpu1.size(), flags[i]);
|
||||
|
||||
GpuMat gpu1(cpu1);
|
||||
GpuMat gpudst;
|
||||
cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);
|
||||
|
||||
if (CheckNorm(cpudst, gpudst) != CvTS::OK)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nFlags: %s\n", flags_str[i]);
|
||||
test_res = CvTS::FAIL_GENERIC;
|
||||
}
|
||||
}
|
||||
|
||||
return test_res;
|
||||
}
|
||||
|
||||
CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;
|
||||
CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;
|
||||
|
@@ -143,7 +143,16 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
|
||||
Mat cpumat(rows, cols, CV_8U);
|
||||
cpumat.setTo(Scalar::all(127));
|
||||
|
||||
is_test_good &= compare_matrix(cpumat);
|
||||
try
|
||||
{
|
||||
is_test_good &= compare_matrix(cpumat);
|
||||
}
|
||||
catch(cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_test_good == true)
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
@@ -151,4 +160,4 @@ void CV_GpuMatAsyncCallTest::run( int /* start_from */)
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
}
|
||||
|
||||
CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
|
||||
//CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
|
||||
|
@@ -115,10 +115,12 @@ void CV_GpuMatOpConvertToTest::run(int /* start_from */)
|
||||
}
|
||||
catch(cv::Exception& e)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nERROR: %s\n", e.what());
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
}
|
||||
|
||||
CV_GpuMatOpConvertToTest CV_GpuMatOpConvertToTest_test;
|
||||
|
||||
|
@@ -136,14 +136,23 @@ void CV_GpuMatOpCopyToTest::run( int /* start_from */)
|
||||
{
|
||||
bool is_test_good = true;
|
||||
|
||||
for (int i = 0 ; i < 7; i++)
|
||||
try
|
||||
{
|
||||
Mat cpumat(rows, cols, i);
|
||||
cpumat.setTo(Scalar::all(127));
|
||||
for (int i = 0 ; i < 7; i++)
|
||||
{
|
||||
Mat cpumat(rows, cols, i);
|
||||
cpumat.setTo(Scalar::all(127));
|
||||
|
||||
GpuMat gpumat(cpumat);
|
||||
GpuMat gpumat(cpumat);
|
||||
|
||||
is_test_good &= compare_matrix(cpumat, gpumat);
|
||||
is_test_good &= compare_matrix(cpumat, gpumat);
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_test_good == true)
|
||||
|
@@ -132,11 +132,20 @@ void CV_GpuMatOpSetToTest::run( int /* start_from */)
|
||||
{
|
||||
bool is_test_good = true;
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
try
|
||||
{
|
||||
Mat cpumat(rows, cols, i, Scalar::all(0));
|
||||
GpuMat gpumat(cpumat);
|
||||
is_test_good &= compare_matrix(cpumat, gpumat);
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
Mat cpumat(rows, cols, i, Scalar::all(0));
|
||||
GpuMat gpumat(cpumat);
|
||||
is_test_good &= compare_matrix(cpumat, gpumat);
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_test_good == true)
|
||||
|
@@ -70,18 +70,30 @@ void CV_GpuStereoBMTest::run(int )
|
||||
return;
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBM_GPU bm(0, 128, 19);
|
||||
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBM_GPU bm(0, 128, 19);
|
||||
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
|
||||
|
||||
disp.convertTo(disp, img_reference.type());
|
||||
double norm = cv::norm(disp, img_reference, cv::NORM_INF);
|
||||
disp.convertTo(disp, img_reference.type());
|
||||
double norm = cv::norm(disp, img_reference, cv::NORM_INF);
|
||||
|
||||
if (norm >= 100)
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
|
||||
ts->set_failed_test_info((norm < 100) ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
if (norm >= 100)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
}
|
||||
|
||||
|
||||
CV_GpuStereoBMTest CV_GpuStereoBM_test;
|
||||
|
||||
|
@@ -74,24 +74,37 @@ void CV_GpuMatAsyncCallStereoBMTest::run( int /* start_from */)
|
||||
return;
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBM_GPU bm(0, 128, 19);
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBM_GPU bm(0, 128, 19);
|
||||
|
||||
cv::gpu::Stream stream;
|
||||
cv::gpu::Stream stream;
|
||||
|
||||
for (size_t i = 0; i < 50; i++)
|
||||
{
|
||||
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp, stream);
|
||||
}
|
||||
for (size_t i = 0; i < 50; i++)
|
||||
{
|
||||
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp, stream);
|
||||
}
|
||||
|
||||
stream.waitForCompletion();
|
||||
disp.convertTo(disp, img_reference.type());
|
||||
double norm = cv::norm(disp, img_reference, cv::NORM_INF);
|
||||
stream.waitForCompletion();
|
||||
disp.convertTo(disp, img_reference.type());
|
||||
double norm = cv::norm(disp, img_reference, cv::NORM_INF);
|
||||
|
||||
if (norm >= 100)
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
|
||||
ts->set_failed_test_info((norm < 100) ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
if (norm >= 100)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
}
|
||||
|
||||
CV_GpuMatAsyncCallStereoBMTest CV_GpuMatAsyncCallStereoBMTest_test;
|
||||
|
@@ -69,20 +69,33 @@ void CV_GpuStereoBPTest::run(int )
|
||||
return;
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
|
||||
|
||||
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
|
||||
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
|
||||
|
||||
//cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);
|
||||
//cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);
|
||||
|
||||
disp.convertTo(disp, img_template.type());
|
||||
disp.convertTo(disp, img_template.type());
|
||||
|
||||
double norm = cv::norm(disp, img_template, cv::NORM_INF);
|
||||
if (norm >= 0.5)
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBP norm = %f\n", norm);
|
||||
ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
double norm = cv::norm(disp, img_template, cv::NORM_INF);
|
||||
if (norm >= 0.5)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nStereoBP norm = %f\n", norm);
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
}
|
||||
|
||||
|
||||
CV_GpuStereoBPTest CV_GpuStereoBP_test;
|
||||
CV_GpuStereoBPTest CV_GpuStereoBP_test;
|
||||
|
@@ -59,16 +59,18 @@ CV_GpuStereoCSBPTest::CV_GpuStereoCSBPTest(): CvTest( "GPU-StereoCSBP", "Constan
|
||||
|
||||
void CV_GpuStereoCSBPTest::run(int )
|
||||
{
|
||||
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-L.png");
|
||||
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-R.png");
|
||||
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", 0);
|
||||
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-L.png");
|
||||
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-R.png");
|
||||
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", 0);
|
||||
|
||||
if (img_l.empty() || img_r.empty() || img_template.empty())
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
if (img_l.empty() || img_r.empty() || img_template.empty())
|
||||
{
|
||||
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cv::gpu::GpuMat disp;
|
||||
cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
|
||||
|
||||
@@ -79,9 +81,21 @@ void CV_GpuStereoCSBPTest::run(int )
|
||||
disp.convertTo(disp, img_template.type());
|
||||
|
||||
double norm = cv::norm(disp, img_template, cv::NORM_INF);
|
||||
if (norm >= 0.5)
|
||||
if (norm >= 0.5)
|
||||
{
|
||||
ts->printf(CvTS::CONSOLE, "\nConstantSpaceStereoBP norm = %f\n", norm);
|
||||
ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(const cv::Exception& e)
|
||||
{
|
||||
if (!check_and_treat_gpu_exception(e, ts))
|
||||
throw;
|
||||
return;
|
||||
}
|
||||
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
}
|
||||
|
||||
CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;
|
||||
CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;
|
||||
|
Reference in New Issue
Block a user