From ada8f92cc7dc5c6461af01aa5fb6e40445f5f572 Mon Sep 17 00:00:00 2001 From: yao Date: Thu, 9 May 2013 17:57:13 +0800 Subject: [PATCH] fix warnings, unify test names --- modules/ocl/test/test_arithm.cpp | 33 ++++------------- modules/ocl/test/test_blend.cpp | 2 +- modules/ocl/test/test_columnsum.cpp | 2 +- modules/ocl/test/test_filters.cpp | 4 +-- modules/ocl/test/test_hog.cpp | 2 +- modules/ocl/test/test_match_template.cpp | 8 ++--- modules/ocl/test/test_matrix_operation.cpp | 42 ++++------------------ modules/ocl/test/test_moments.cpp | 10 +++--- modules/ocl/test/test_pyrdown.cpp | 8 ++--- modules/ocl/test/test_pyrup.cpp | 7 ++-- modules/ocl/test/test_split_merge.cpp | 26 +++----------- 11 files changed, 34 insertions(+), 110 deletions(-) diff --git a/modules/ocl/test/test_arithm.cpp b/modules/ocl/test/test_arithm.cpp index 9b9cec9381..d12cef0b22 100644 --- a/modules/ocl/test/test_arithm.cpp +++ b/modules/ocl/test/test_arithm.cpp @@ -174,16 +174,12 @@ PARAM_TEST_CASE(ArithmTestBase, MatType, bool) void Near(double threshold = 0.) { - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - EXPECT_MAT_NEAR(dst, cpu_dst, threshold); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), threshold); } void Near1(double threshold = 0.) - { - cv::Mat cpu_dst1; - gdst1_whole.download(cpu_dst1); - EXPECT_MAT_NEAR(dst1, cpu_dst1, threshold); + { + EXPECT_MAT_NEAR(dst1, Mat(gdst1_whole), threshold); } }; @@ -1169,33 +1165,18 @@ TEST_P(MagnitudeSqr, Mat) { for(int j = 0; j < LOOP_TIMES; j++) { - // random_roi(); - // int64 start, end; - // start = cv::getTickCount(); + random_roi(); for(int i = 0; i < mat1.rows; ++i) for(int j = 0; j < mat1.cols; ++j) { float val1 = mat1.at(i, j); float val2 = mat2.at(i, j); - ((float *)(dst.data))[i * dst.step / 4 + j] = val1 * val1 + val2 * val2; - - // float val1 =((float *)( mat1.data))[(i*mat1.step/8 +j)*2]; - // - // float val2 =((float *)( mat1.data))[(i*mat1.step/8 +j)*2+ 1 ]; - - // ((float *)(dst.data))[i*dst.step/4 +j]= val1 * val1 +val2 * val2; } - // end = cv::getTickCount(); - - cv::ocl::oclMat clmat1(mat1), clmat2(mat2), cldst; - cv::ocl::magnitudeSqr(clmat1, clmat2, cldst); - - cv::Mat cpu_dst; - cldst.download(cpu_dst); - - EXPECT_MAT_NEAR(dst, cpu_dst, 1); + cv::ocl::oclMat clmat1(mat1), clmat2(mat2); + cv::ocl::magnitudeSqr(clmat1, clmat2, gdst); + Near(1); } } diff --git a/modules/ocl/test/test_blend.cpp b/modules/ocl/test/test_blend.cpp index 292353be60..fa1aea1727 100644 --- a/modules/ocl/test/test_blend.cpp +++ b/modules/ocl/test/test_blend.cpp @@ -112,7 +112,7 @@ TEST_P(Blend, Accuracy) EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.f : 1e-5f); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, Combine( +INSTANTIATE_TEST_CASE_P(OCL_ImgProc, Blend, Combine( DIFFERENT_SIZES, testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)) )); diff --git a/modules/ocl/test/test_columnsum.cpp b/modules/ocl/test/test_columnsum.cpp index bf389d1b84..231f0657b0 100644 --- a/modules/ocl/test/test_columnsum.cpp +++ b/modules/ocl/test/test_columnsum.cpp @@ -88,7 +88,7 @@ TEST_P(ColumnSum, Accuracy) } } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ColumnSum, DIFFERENT_SIZES); +INSTANTIATE_TEST_CASE_P(OCL_ImgProc, ColumnSum, DIFFERENT_SIZES); #endif diff --git a/modules/ocl/test/test_filters.cpp b/modules/ocl/test/test_filters.cpp index 316076cc35..cfd57413e1 100644 --- a/modules/ocl/test/test_filters.cpp +++ b/modules/ocl/test/test_filters.cpp @@ -125,9 +125,7 @@ PARAM_TEST_CASE(FilterTestBase, void Near(double threshold) { - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - EXPECT_MAT_NEAR(dst, cpu_dst, threshold); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), threshold); } }; diff --git a/modules/ocl/test/test_hog.cpp b/modules/ocl/test/test_hog.cpp index c95c25fe95..cfc4e3963f 100644 --- a/modules/ocl/test/test_hog.cpp +++ b/modules/ocl/test/test_hog.cpp @@ -244,7 +244,7 @@ TEST_P(HOG, Detect) } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HOG, testing::Combine( +INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine( testing::Values(cv::Size(64, 128), cv::Size(48, 96)), testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); diff --git a/modules/ocl/test/test_match_template.cpp b/modules/ocl/test/test_match_template.cpp index e6f1f7080d..a393abdeb3 100644 --- a/modules/ocl/test/test_match_template.cpp +++ b/modules/ocl/test/test_match_template.cpp @@ -89,12 +89,10 @@ TEST_P(MatchTemplate8U, Accuracy) cv::Mat dst_gold; cv::matchTemplate(image, templ, dst_gold, method); - char sss [100] = ""; - cv::Mat mat_dst; dst.download(mat_dst); - EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss); + EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1); } PARAM_TEST_CASE(MatchTemplate32F, cv::Size, TemplateSize, Channels, TemplateMethod) @@ -125,12 +123,10 @@ TEST_P(MatchTemplate32F, Accuracy) cv::Mat dst_gold; cv::matchTemplate(image, templ, dst_gold, method); - char sss [100] = ""; - cv::Mat mat_dst; dst.download(mat_dst); - EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1, sss); + EXPECT_MAT_NEAR(dst_gold, mat_dst, templ_size.area() * 1e-1); } INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MatchTemplate8U, diff --git a/modules/ocl/test/test_matrix_operation.cpp b/modules/ocl/test/test_matrix_operation.cpp index 654e1a61f3..92d810818b 100644 --- a/modules/ocl/test/test_matrix_operation.cpp +++ b/modules/ocl/test/test_matrix_operation.cpp @@ -135,12 +135,7 @@ TEST_P(ConvertTo, Accuracy) mat_roi.convertTo(dst_roi, dst_type); gmat.convertTo(gdst, dst_type); - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d", roicols, roirows, srcx , srcy, dstx, dsty); - - EXPECT_MAT_NEAR(dst, cpu_dst, 0.0, sss); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0); } } @@ -242,12 +237,7 @@ TEST_P(CopyTo, Without_mask) mat_roi.copyTo(dst_roi); gmat.copyTo(gdst); - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d", roicols, roirows, srcx , srcy, dstx, dsty, maskx, masky); - - EXPECT_MAT_NEAR(dst, cpu_dst, 0.0, sss); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0); } } @@ -260,12 +250,7 @@ TEST_P(CopyTo, With_mask) mat_roi.copyTo(dst_roi, mask_roi); gmat.copyTo(gdst, gmask); - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d", roicols, roirows, srcx , srcy, dstx, dsty, maskx, masky); - - EXPECT_MAT_NEAR(dst, cpu_dst, 0.0, sss); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0); } } @@ -357,12 +342,7 @@ TEST_P(SetTo, Without_mask) mat_roi.setTo(val); gmat.setTo(val); - cv::Mat cpu_dst; - gmat_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,srcx =%d,srcy=%d,maskx=%d,masky=%d", roicols, roirows, srcx , srcy, maskx, masky); - - EXPECT_MAT_NEAR(mat, cpu_dst, 1., sss); + EXPECT_MAT_NEAR(mat, Mat(gmat_whole), 1.); } } @@ -375,12 +355,7 @@ TEST_P(SetTo, With_mask) mat_roi.setTo(val, mask_roi); gmat.setTo(val, gmask); - cv::Mat cpu_dst; - gmat_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,srcx =%d,srcy=%d,maskx=%d,masky=%d", roicols, roirows, srcx , srcy, maskx, masky); - - EXPECT_MAT_NEAR(mat, cpu_dst, 1., sss); + EXPECT_MAT_NEAR(mat, Mat(gmat_whole), 1.); } } @@ -464,11 +439,8 @@ TEST_P(convertC3C4, Accuracy) mat1 = randomMat(rng, size, type, 0, 40, false); gmat1 = mat1; - cv::Mat cpu_dst; - gmat1.download(cpu_dst); - char sss[1024]; - sprintf(sss, "cols=%d,rows=%d", mat1.cols, mat1.rows); - EXPECT_MAT_NEAR(mat1, cpu_dst, 0.0, sss); + + EXPECT_MAT_NEAR(mat1, Mat(gmat1), 0.0); } } diff --git a/modules/ocl/test/test_moments.cpp b/modules/ocl/test/test_moments.cpp index 715ad8963a..98c66def31 100644 --- a/modules/ocl/test/test_moments.cpp +++ b/modules/ocl/test/test_moments.cpp @@ -10,7 +10,7 @@ using namespace cvtest; using namespace testing; using namespace std; extern string workdir; -PARAM_TEST_CASE(MomentsTestBase, MatType, bool) +PARAM_TEST_CASE(MomentsTest, MatType, bool) { int type; cv::Mat mat1; @@ -30,13 +30,13 @@ PARAM_TEST_CASE(MomentsTestBase, MatType, bool) Mat gpu_dst, cpu_dst; HuMoments(cpu, cpu_dst); HuMoments(gpu, gpu_dst); - EXPECT_MAT_NEAR(gpu_dst,cpu_dst, .5, ""); + EXPECT_MAT_NEAR(gpu_dst,cpu_dst, .5); } }; -struct ocl_Moments : MomentsTestBase {}; -TEST_P(ocl_Moments, Mat) + +TEST_P(MomentsTest, Mat) { bool binaryImage = 0; SetUp(); @@ -67,6 +67,6 @@ TEST_P(ocl_Moments, Mat) } } -INSTANTIATE_TEST_CASE_P(Moments, ocl_Moments, Combine( +INSTANTIATE_TEST_CASE_P(OCL_ImgProc, MomentsTest, Combine( Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_64FC1), Values(true,false))); #endif // HAVE_OPENCL diff --git a/modules/ocl/test/test_pyrdown.cpp b/modules/ocl/test/test_pyrdown.cpp index a67e0b0ac6..6d00fb5e45 100644 --- a/modules/ocl/test/test_pyrdown.cpp +++ b/modules/ocl/test/test_pyrdown.cpp @@ -83,15 +83,11 @@ TEST_P(PyrDown, Mat) cv::pyrDown(src, dst_cpu); cv::ocl::pyrDown(gsrc, gdst); - cv::Mat dst; - gdst.download(dst); - char s[1024] = {0}; - - EXPECT_MAT_NEAR(dst, dst_cpu, dst.depth() == CV_32F ? 1e-4f : 1.0f, s); + EXPECT_MAT_NEAR(dst_cpu, Mat(gdst), type == CV_32F ? 1e-4f : 1.0f); } } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrDown, Combine( +INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrDown, Combine( Values(CV_8U, CV_32F), Values(1, 3, 4))); diff --git a/modules/ocl/test/test_pyrup.cpp b/modules/ocl/test/test_pyrup.cpp index b2d45ef4fd..afd3e8b1b8 100644 --- a/modules/ocl/test/test_pyrup.cpp +++ b/modules/ocl/test/test_pyrup.cpp @@ -77,17 +77,14 @@ TEST_P(PyrUp, Accuracy) ocl::oclMat dst; ocl::oclMat srcMat(src); ocl::pyrUp(srcMat, dst); - Mat cpu_dst; - dst.download(cpu_dst); - char s[100] = {0}; - EXPECT_MAT_NEAR(dst_gold, cpu_dst, (src.depth() == CV_32F ? 1e-4f : 1.0), s); + EXPECT_MAT_NEAR(dst_gold, Mat(dst), (type == CV_32F ? 1e-4f : 1.0)); } } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrUp, testing::Combine( +INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrUp, testing::Combine( Values(CV_8U, CV_32F), Values(1, 3, 4))); diff --git a/modules/ocl/test/test_split_merge.cpp b/modules/ocl/test/test_split_merge.cpp index 2d60b2830b..854ce309c2 100644 --- a/modules/ocl/test/test_split_merge.cpp +++ b/modules/ocl/test/test_split_merge.cpp @@ -202,12 +202,7 @@ TEST_P(Merge, Accuracy) cv::merge(dev_src, dst_roi); cv::ocl::merge(dev_gsrc, gdst); - cv::Mat cpu_dst; - gdst_whole.download(cpu_dst); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,src1x =%d,src1y=%d,src2x =%d,src2y=%d,src3x =%d,src3y=%d,src4x =%d,src4y=%d,dstx=%d,dsty=%d", roicols, roirows, src1x, src1y, src2x , src2y, src3x , src3y, src4x , src4y, dstx, dsty); - - EXPECT_MAT_NEAR(dst, cpu_dst, 0.0, sss); + EXPECT_MAT_NEAR(dst, Mat(gdst_whole), 0.0); } } @@ -349,28 +344,17 @@ TEST_P(Split, Accuracy) cv::split(mat_roi, dev_dst); cv::ocl::split(gmat, dev_gdst); - cv::Mat cpu_dst1; - cv::Mat cpu_dst2; - cv::Mat cpu_dst3; - cv::Mat cpu_dst4; - gdst1_whole.download(cpu_dst1); - gdst2_whole.download(cpu_dst2); - gdst3_whole.download(cpu_dst3); - gdst4_whole.download(cpu_dst4); - char sss[1024]; - sprintf(sss, "roicols=%d,roirows=%d,dst1x =%d,dsty=%d,dst2x =%d,dst2y=%d,dst3x =%d,dst3y=%d,dst4x =%d,dst4y=%d,srcx=%d,srcy=%d", roicols, roirows, dst1x , dst1y, dst2x , dst2y, dst3x , dst3y, dst4x , dst4y, srcx, srcy); - if(channels >= 1) - EXPECT_MAT_NEAR(dst1, cpu_dst1, 0.0, sss); + EXPECT_MAT_NEAR(dst1, Mat(gdst1_whole), 0.0); if(channels >= 2) - EXPECT_MAT_NEAR(dst2, cpu_dst2, 0.0, sss); + EXPECT_MAT_NEAR(dst2, Mat(gdst2_whole), 0.0); if(channels >= 3) - EXPECT_MAT_NEAR(dst3, cpu_dst3, 0.0, sss); + EXPECT_MAT_NEAR(dst3, Mat(gdst3_whole), 0.0); if(channels >= 4) - EXPECT_MAT_NEAR(dst4, cpu_dst4, 0.0, sss); + EXPECT_MAT_NEAR(dst4, Mat(gdst4_whole), 0.0); } }