|
| 1 | +#include "perf_precomp.hpp" |
| 2 | +#include "opencv2/imgproc.hpp" |
| 3 | +#include "opencv2/imgproc/types_c.h" |
| 4 | + |
| 5 | +using namespace std; |
| 6 | +using namespace cv; |
| 7 | +using namespace perf; |
| 8 | + |
| 9 | +PERF_TEST(PerfHoughCircles, Basic) |
| 10 | +{ |
| 11 | + string filename = getDataPath("cv/imgproc/stuff.jpg"); |
| 12 | + const double dp = 1.0; |
| 13 | + double minDist = 20; |
| 14 | + double edgeThreshold = 20; |
| 15 | + double accumThreshold = 30; |
| 16 | + int minRadius = 20; |
| 17 | + int maxRadius = 200; |
| 18 | + |
| 19 | + Mat img = imread(filename, IMREAD_GRAYSCALE); |
| 20 | + ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename; |
| 21 | + |
| 22 | + GaussianBlur(img, img, Size(9, 9), 2, 2); |
| 23 | + |
| 24 | + vector<Vec3f> circles; |
| 25 | + declare.in(img); |
| 26 | + |
| 27 | + TEST_CYCLE() |
| 28 | + { |
| 29 | + HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius); |
| 30 | + } |
| 31 | + |
| 32 | + SANITY_CHECK_NOTHING(); |
| 33 | +} |
| 34 | + |
| 35 | +PERF_TEST(PerfHoughCircles2, ManySmallCircles) |
| 36 | +{ |
| 37 | + string filename = getDataPath("cv/imgproc/beads.jpg"); |
| 38 | + const double dp = 1.0; |
| 39 | + double minDist = 10; |
| 40 | + double edgeThreshold = 90; |
| 41 | + double accumThreshold = 11; |
| 42 | + int minRadius = 7; |
| 43 | + int maxRadius = 18; |
| 44 | + |
| 45 | + Mat img = imread(filename, IMREAD_GRAYSCALE); |
| 46 | + ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename; |
| 47 | + |
| 48 | + vector<Vec3f> circles; |
| 49 | + declare.in(img); |
| 50 | + |
| 51 | + TEST_CYCLE() |
| 52 | + { |
| 53 | + HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius); |
| 54 | + } |
| 55 | + |
| 56 | + SANITY_CHECK_NOTHING(); |
| 57 | +} |
0 commit comments