perf_canny.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. typedef tuple<string, int, bool, tuple<double, double> > Img_Aperture_L2_thresholds_t;
  7. typedef perf::TestBaseWithParam<Img_Aperture_L2_thresholds_t> Img_Aperture_L2_thresholds;
  8. PERF_TEST_P(Img_Aperture_L2_thresholds, canny,
  9. testing::Combine(
  10. testing::Values( "cv/shared/lena.png", "stitching/b1.png", "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png" ),
  11. testing::Values( 3, 5 ),
  12. testing::Bool(),
  13. testing::Values( make_tuple(50.0, 100.0), make_tuple(0.0, 50.0), make_tuple(100.0, 120.0) )
  14. )
  15. )
  16. {
  17. string filename = getDataPath(get<0>(GetParam()));
  18. int aperture = get<1>(GetParam());
  19. bool useL2 = get<2>(GetParam());
  20. double thresh_low = get<0>(get<3>(GetParam()));
  21. double thresh_high = get<1>(get<3>(GetParam()));
  22. Mat img = imread(filename, IMREAD_GRAYSCALE);
  23. if (img.empty())
  24. FAIL() << "Unable to load source image " << filename;
  25. Mat edges(img.size(), img.type());
  26. declare.in(img).out(edges);
  27. PERF_SAMPLE_BEGIN();
  28. Canny(img, edges, thresh_low, thresh_high, aperture, useL2);
  29. PERF_SAMPLE_END();
  30. SANITY_CHECK(edges);
  31. }
  32. } // namespace