From 72e4f72a7593bb51cf962d02b2e313c8d32bdd67 Mon Sep 17 00:00:00 2001 From: Chechli Date: Sat, 15 Feb 2014 17:31:14 +0100 Subject: [PATCH] Update hough_circles.cpp --- modules/cudaimgproc/src/hough_circles.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/cudaimgproc/src/hough_circles.cpp b/modules/cudaimgproc/src/hough_circles.cpp index 0cf94a6..c3ca971 100644 --- a/modules/cudaimgproc/src/hough_circles.cpp +++ b/modules/cudaimgproc/src/hough_circles.cpp @@ -41,6 +41,7 @@ //M*/ #include "precomp.hpp" +#include using namespace cv; using namespace cv::cuda; @@ -139,6 +140,8 @@ namespace Ptr filterDy_; Ptr canny_; }; + + bool centersCompare(Vec3f a, Vec3f b) {return (a[2] > b[2]);} HoughCirclesDetectorImpl::HoughCirclesDetectorImpl(float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles) : @@ -219,9 +222,21 @@ namespace const float minDist2 = minDist_ * minDist_; + vector sortBuf; + for(int i=0; i(temp[1]+1, temp[0]+1); + sortBuf.push_back(temp); + } + std::sort(sortBuf.begin(), sortBuf.end(), centersCompare); + for (int i = 0; i < centersCount; ++i) { - ushort2 p = oldBuf[i]; + ushort2 p; + p.x = sortBuf[i][0]; + p.y = sortBuf[i][1]; bool good = true; -- 2.7.4