perf_houghcircles.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "perf_precomp.hpp"
  5. namespace opencv_test {
  6. PERF_TEST(PerfHoughCircles, Basic)
  7. {
  8. string filename = getDataPath("cv/imgproc/stuff.jpg");
  9. const double dp = 1.0;
  10. double minDist = 20;
  11. double edgeThreshold = 20;
  12. double accumThreshold = 30;
  13. int minRadius = 20;
  14. int maxRadius = 200;
  15. Mat img = imread(filename, IMREAD_GRAYSCALE);
  16. ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
  17. GaussianBlur(img, img, Size(9, 9), 2, 2);
  18. vector<Vec3f> circles;
  19. declare.in(img);
  20. TEST_CYCLE()
  21. {
  22. HoughCircles(img, circles, cv::HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
  23. }
  24. SANITY_CHECK_NOTHING();
  25. }
  26. PERF_TEST(PerfHoughCircles2, ManySmallCircles)
  27. {
  28. string filename = getDataPath("cv/imgproc/beads.jpg");
  29. const double dp = 1.0;
  30. double minDist = 10;
  31. double edgeThreshold = 90;
  32. double accumThreshold = 11;
  33. int minRadius = 7;
  34. int maxRadius = 18;
  35. Mat img = imread(filename, IMREAD_GRAYSCALE);
  36. ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
  37. vector<Vec3f> circles;
  38. declare.in(img);
  39. TEST_CYCLE()
  40. {
  41. HoughCircles(img, circles, cv::HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
  42. }
  43. SANITY_CHECK_NOTHING();
  44. }
  45. PERF_TEST(PerfHoughCircles4f, Basic)
  46. {
  47. string filename = getDataPath("cv/imgproc/stuff.jpg");
  48. const double dp = 1.0;
  49. double minDist = 20;
  50. double edgeThreshold = 20;
  51. double accumThreshold = 30;
  52. int minRadius = 20;
  53. int maxRadius = 200;
  54. Mat img = imread(filename, IMREAD_GRAYSCALE);
  55. ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
  56. GaussianBlur(img, img, Size(9, 9), 2, 2);
  57. vector<Vec4f> circles;
  58. declare.in(img);
  59. TEST_CYCLE()
  60. {
  61. HoughCircles(img, circles, cv::HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
  62. }
  63. SANITY_CHECK_NOTHING();
  64. }
  65. } // namespace