perf_houghcircles.cpp 2.2 KB

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