|
| 1 | +// This file is part of OpenCV project. |
| 2 | +// It is subject to the license terms in the LICENSE file found in the top-level |
| 3 | +// directory of this distribution and at http://opencv.org/license.html. |
| 4 | + |
| 5 | +#include "perf_precomp.hpp" |
| 6 | + |
| 7 | +namespace opencv_test |
| 8 | +{ |
| 9 | +namespace |
| 10 | +{ |
| 11 | + |
| 12 | +/* 1. Define parameter type and test fixture */ |
| 13 | +typedef tuple<int, int> EDTestParam; |
| 14 | +typedef TestBaseWithParam<EDTestParam> EdgeDrawing_Detect_Edges; |
| 15 | +typedef TestBaseWithParam<EDTestParam> EdgeDrawing_Detect_Lines; |
| 16 | +typedef TestBaseWithParam<EDTestParam> EdgeDrawing_Detect_Ellipses; |
| 17 | + |
| 18 | +/* 2. Declare the testsuite */ |
| 19 | +PERF_TEST_P(EdgeDrawing_Detect_Edges, perf, |
| 20 | + Combine(Values(0, 1, 2, 3), Values(10, 20, 30, 50, 80, 100, 120, 150))) |
| 21 | +{ |
| 22 | + /* 3. Get actual test parameters */ |
| 23 | + EDTestParam params = GetParam(); |
| 24 | + int EdgeDetectionOperator = get<0>(params); |
| 25 | + int GradientThresholdValue = get<1>(params); |
| 26 | + |
| 27 | + /* 4. Allocate and initialize arguments for tested function */ |
| 28 | + std::string filename = getDataPath("perf/1680x1050.png"); |
| 29 | + Mat src = imread(filename, 0); |
| 30 | + |
| 31 | + /* 5. Manifest your expectations about this test */ |
| 32 | + declare.in(src); |
| 33 | + |
| 34 | + /* 6. Collect the samples! */ |
| 35 | + PERF_SAMPLE_BEGIN(); |
| 36 | + Ptr<ximgproc::EdgeDrawing> ed = ximgproc::createEdgeDrawing(); |
| 37 | + ed->params.EdgeDetectionOperator = EdgeDetectionOperator; |
| 38 | + ed->params.GradientThresholdValue = GradientThresholdValue; |
| 39 | + ed->detectEdges(src); |
| 40 | + PERF_SAMPLE_END(); |
| 41 | + |
| 42 | + /* 7. Do not check anything */ |
| 43 | + SANITY_CHECK_NOTHING(); |
| 44 | +} |
| 45 | + |
| 46 | +/* 2. Declare the testsuite */ |
| 47 | +PERF_TEST_P(EdgeDrawing_Detect_Lines, perf, |
| 48 | + Combine(Values(0, 1, 2, 3), Values(10, 20, 30, 50, 80, 100, 120, 150))) |
| 49 | +{ |
| 50 | + /* 3. Get actual test parameters */ |
| 51 | + EDTestParam params = GetParam(); |
| 52 | + int EdgeDetectionOperator = get<0>(params); |
| 53 | + int GradientThresholdValue = get<1>(params); |
| 54 | + |
| 55 | + /* 4. Allocate and initialize arguments for tested function */ |
| 56 | + std::string filename = getDataPath("perf/1680x1050.png"); |
| 57 | + Mat src = imread(filename, 0); |
| 58 | + |
| 59 | + /* 5. Manifest your expectations about this test */ |
| 60 | + declare.in(src); |
| 61 | + |
| 62 | + /* 6. Collect the samples! */ |
| 63 | + PERF_SAMPLE_BEGIN(); |
| 64 | + Ptr<ximgproc::EdgeDrawing> ed = ximgproc::createEdgeDrawing(); |
| 65 | + ed->params.EdgeDetectionOperator = EdgeDetectionOperator; |
| 66 | + ed->params.GradientThresholdValue = GradientThresholdValue; |
| 67 | + ed->detectEdges(src); |
| 68 | + std::vector<Vec4f> lines; |
| 69 | + ed->detectLines(lines); |
| 70 | + PERF_SAMPLE_END(); |
| 71 | + |
| 72 | + /* 7. Do not check anything */ |
| 73 | + SANITY_CHECK_NOTHING(); |
| 74 | +} |
| 75 | + |
| 76 | +/* 2. Declare the testsuite */ |
| 77 | +PERF_TEST_P(EdgeDrawing_Detect_Ellipses, perf, |
| 78 | + Combine(Values(0, 1, 2, 3), Values(10, 20, 30, 50, 80, 100, 120, 150))) |
| 79 | +{ |
| 80 | + /* 3. Get actual test parameters */ |
| 81 | + EDTestParam params = GetParam(); |
| 82 | + int EdgeDetectionOperator = get<0>(params); |
| 83 | + int GradientThresholdValue = get<1>(params); |
| 84 | + |
| 85 | + /* 4. Allocate and initialize arguments for tested function */ |
| 86 | + std::string filename = getDataPath("perf/1680x1050.png"); |
| 87 | + Mat src = imread(filename, 0); |
| 88 | + |
| 89 | + /* 5. Manifest your expectations about this test */ |
| 90 | + declare.in(src); |
| 91 | + |
| 92 | + /* 6. Collect the samples! */ |
| 93 | + PERF_SAMPLE_BEGIN(); |
| 94 | + Ptr<ximgproc::EdgeDrawing> ed = ximgproc::createEdgeDrawing(); |
| 95 | + ed->params.EdgeDetectionOperator = EdgeDetectionOperator; |
| 96 | + ed->params.GradientThresholdValue = GradientThresholdValue; |
| 97 | + ed->detectEdges(src); |
| 98 | + vector<Vec6d> ellipses; |
| 99 | + ed->detectEllipses(ellipses); |
| 100 | + PERF_SAMPLE_END(); |
| 101 | + |
| 102 | + /* 7. Do not check anything */ |
| 103 | + SANITY_CHECK_NOTHING(); |
| 104 | +} |
| 105 | +} // namespace |
| 106 | +} // namespace opencv_test |
0 commit comments