opencv/modules/imgproc/perf/perf_houghcircles.cpp

86 lines
2.2 KiB
C++
Raw Normal View History

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
Merge pull request #10232 from TomBecker-BD:hough-many-circles Hough many circles (#10232) * Add Hui's optimization. Merge with latest changes in OpenCV. * Use conditional compilation instead of a runtime flag. * Whitespace. * Create the sequence for the nonzero edge pixels only if using that approach. * Improve performance for finding very large numbers of circles * Return the circles with the larger accumulator values first, as per API documentation. Use a separate step to check distance between circles. Allows circles to be sorted by strength first. Avoids locking in EstimateRadius which was slowing it down. Return centers only if maxRadius == 0 as per API documentation. * Sort the circles so results are deterministic. Otherwise the order of circles with the same strength depends on parallel processing completion order. * Add test for HoughCircles. * Add beads test. * Wrap the non-zero points structure in a common interface so the code can use either a vector or a matrix. * Remove the special case for skipping the radius search if maxRadius==0. * Add performance tests. * Use NULL instead of nullptr. OpenCV should compile with C++98 compiler. * Put test suite name first. Use different test suite names for each test to avoid an error from the test runner. * Address build bot errors and warnings. * Skip radius search if maxRadius < 0. * Dynamically switch to NZPointList when it will be faster than NZPointSet. * Fix compile error: missing 'typename' prior to dependent type name. * Fix compile error: missing 'typename' prior to dependent type name. This time fix it the non C++ 11 way. * Fix compile error: no type named 'const_reference' in 'class cv::NZPointList' * Disable ManySmallCircles tests. Failing on Mac. * Change beads image to JPEG for smaller file size. Try enabling the ManySmallCircles tests again. * Remove ManySmallCircles tests. They are failing on the Mac build. * Fix expectations to check all circles. * Changing case on a case-insensitive file system Step 1: remove the old file names * Changing case on a case-insensitive file system Step 2: add them back with the new names * Fix cmpAccum function to be strictly weak ordered. * Add tests for many small circles. * imgproc(perf): fix HoughCircles tests * imgproc(houghCircles): refactor code - simplify NZPointList - drop broken (de-synchronization of 'current'/'mi' fields) NZPointSet iterator - NZPointSet iterator is replaced to direct area scan - use SIMD intrinsics - avoid std exceptions (build for embedded systems)
2017-12-28 22:23:11 +08:00
#include "perf_precomp.hpp"
#include "opencv2/imgproc/types_c.h"
namespace opencv_test {
Merge pull request #10232 from TomBecker-BD:hough-many-circles Hough many circles (#10232) * Add Hui's optimization. Merge with latest changes in OpenCV. * Use conditional compilation instead of a runtime flag. * Whitespace. * Create the sequence for the nonzero edge pixels only if using that approach. * Improve performance for finding very large numbers of circles * Return the circles with the larger accumulator values first, as per API documentation. Use a separate step to check distance between circles. Allows circles to be sorted by strength first. Avoids locking in EstimateRadius which was slowing it down. Return centers only if maxRadius == 0 as per API documentation. * Sort the circles so results are deterministic. Otherwise the order of circles with the same strength depends on parallel processing completion order. * Add test for HoughCircles. * Add beads test. * Wrap the non-zero points structure in a common interface so the code can use either a vector or a matrix. * Remove the special case for skipping the radius search if maxRadius==0. * Add performance tests. * Use NULL instead of nullptr. OpenCV should compile with C++98 compiler. * Put test suite name first. Use different test suite names for each test to avoid an error from the test runner. * Address build bot errors and warnings. * Skip radius search if maxRadius < 0. * Dynamically switch to NZPointList when it will be faster than NZPointSet. * Fix compile error: missing 'typename' prior to dependent type name. * Fix compile error: missing 'typename' prior to dependent type name. This time fix it the non C++ 11 way. * Fix compile error: no type named 'const_reference' in 'class cv::NZPointList' * Disable ManySmallCircles tests. Failing on Mac. * Change beads image to JPEG for smaller file size. Try enabling the ManySmallCircles tests again. * Remove ManySmallCircles tests. They are failing on the Mac build. * Fix expectations to check all circles. * Changing case on a case-insensitive file system Step 1: remove the old file names * Changing case on a case-insensitive file system Step 2: add them back with the new names * Fix cmpAccum function to be strictly weak ordered. * Add tests for many small circles. * imgproc(perf): fix HoughCircles tests * imgproc(houghCircles): refactor code - simplify NZPointList - drop broken (de-synchronization of 'current'/'mi' fields) NZPointSet iterator - NZPointSet iterator is replaced to direct area scan - use SIMD intrinsics - avoid std exceptions (build for embedded systems)
2017-12-28 22:23:11 +08:00
PERF_TEST(PerfHoughCircles, Basic)
{
string filename = getDataPath("cv/imgproc/stuff.jpg");
const double dp = 1.0;
double minDist = 20;
double edgeThreshold = 20;
double accumThreshold = 30;
int minRadius = 20;
int maxRadius = 200;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
GaussianBlur(img, img, Size(9, 9), 2, 2);
vector<Vec3f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST(PerfHoughCircles2, ManySmallCircles)
{
string filename = getDataPath("cv/imgproc/beads.jpg");
const double dp = 1.0;
double minDist = 10;
double edgeThreshold = 90;
double accumThreshold = 11;
int minRadius = 7;
int maxRadius = 18;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
vector<Vec3f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST(PerfHoughCircles4f, Basic)
{
string filename = getDataPath("cv/imgproc/stuff.jpg");
const double dp = 1.0;
double minDist = 20;
double edgeThreshold = 20;
double accumThreshold = 30;
int minRadius = 20;
int maxRadius = 200;
Mat img = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()) << "Unable to load source image " << filename;
GaussianBlur(img, img, Size(9, 9), 2, 2);
vector<Vec4f> circles;
declare.in(img);
TEST_CYCLE()
{
HoughCircles(img, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius);
}
SANITY_CHECK_NOTHING();
}
} // namespace