1 /*#include "perf_precomp.hpp" 2 #include "distransform.cpp" 3 4 using namespace std; 5 using namespace cv; 6 using namespace perf; 7 8 typedef perf::TestBaseWithParam<Size> Size_DistanceTransform; 9 10 PERF_TEST_P(Size_DistanceTransform, icvTrueDistTrans, testing::Values(TYPICAL_MAT_SIZES)) 11 { 12 Size size = GetParam(); 13 Mat src(size, CV_8UC1); 14 Mat dst(size, CV_32FC1); 15 CvMat srcStub = src; 16 CvMat dstStub = dst; 17 18 declare.in(src, WARMUP_RNG).out(dst); 19 20 TEST_CYCLE() icvTrueDistTrans(&srcStub, &dstStub); 21 22 SANITY_CHECK(dst, 1); 23 }*/ 24 25 #include "perf_precomp.hpp" 26 27 using namespace std; 28 using namespace cv; 29 using namespace perf; 30 using std::tr1::make_tuple; 31 using std::tr1::get; 32 33 CV_ENUM(DistanceType, DIST_L1, DIST_L2 , DIST_C) 34 CV_ENUM(MaskSize, DIST_MASK_3, DIST_MASK_5, DIST_MASK_PRECISE) 35 CV_ENUM(DstType, CV_8U, CV_32F) 36 CV_ENUM(LabelType, DIST_LABEL_CCOMP, DIST_LABEL_PIXEL) 37 38 typedef std::tr1::tuple<Size, DistanceType, MaskSize, DstType> SrcSize_DistType_MaskSize_DstType; 39 typedef std::tr1::tuple<Size, DistanceType, MaskSize, LabelType> SrcSize_DistType_MaskSize_LabelType; 40 typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_DstType> DistanceTransform_Test; 41 typedef perf::TestBaseWithParam<SrcSize_DistType_MaskSize_LabelType> DistanceTransform_NeedLabels_Test; 42 43 PERF_TEST_P(DistanceTransform_Test, distanceTransform, 44 testing::Combine( 45 testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)), 46 DistanceType::all(), 47 MaskSize::all(), 48 DstType::all() 49 ) 50 ) 51 { 52 Size srcSize = get<0>(GetParam()); 53 int distanceType = get<1>(GetParam()); 54 int maskSize = get<2>(GetParam()); 55 int dstType = get<3>(GetParam()); 56 57 Mat src(srcSize, CV_8U); 58 Mat dst(srcSize, dstType); 59 60 declare 61 .in(src, WARMUP_RNG) 62 .out(dst, WARMUP_RNG) 63 .time(30); 64 65 TEST_CYCLE() distanceTransform( src, dst, distanceType, maskSize, dstType); 66 67 double eps = 2e-4; 68 69 SANITY_CHECK(dst, eps); 70 } 71 72 PERF_TEST_P(DistanceTransform_NeedLabels_Test, distanceTransform_NeedLabels, 73 testing::Combine( 74 testing::Values(cv::Size(640, 480), cv::Size(800, 600), cv::Size(1024, 768), cv::Size(1280, 1024)), 75 DistanceType::all(), 76 MaskSize::all(), 77 LabelType::all() 78 ) 79 ) 80 { 81 Size srcSize = get<0>(GetParam()); 82 int distanceType = get<1>(GetParam()); 83 int maskSize = get<2>(GetParam()); 84 int labelType = get<3>(GetParam()); 85 86 Mat src(srcSize, CV_8U); 87 Mat label(srcSize, CV_32S); 88 Mat dst(srcSize, CV_32F); 89 90 declare 91 .in(src, WARMUP_RNG) 92 .out(label, WARMUP_RNG) 93 .out(dst, WARMUP_RNG) 94 .time(30); 95 96 TEST_CYCLE() distanceTransform( src, dst, label, distanceType, maskSize, labelType); 97 98 double eps = 2e-4; 99 100 SANITY_CHECK(label, eps); 101 SANITY_CHECK(dst, eps); 102 } 103