Commit 72e4f72a authored by Chechli's avatar Chechli

Update hough_circles.cpp

parent 3542da71
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#include <algorithm>
using namespace cv; using namespace cv;
using namespace cv::cuda; using namespace cv::cuda;
...@@ -139,6 +140,8 @@ namespace ...@@ -139,6 +140,8 @@ namespace
Ptr<cuda::Filter> filterDy_; Ptr<cuda::Filter> filterDy_;
Ptr<cuda::CannyEdgeDetector> canny_; Ptr<cuda::CannyEdgeDetector> canny_;
}; };
bool centersCompare(Vec3f a, Vec3f b) {return (a[2] > b[2]);}
HoughCirclesDetectorImpl::HoughCirclesDetectorImpl(float dp, float minDist, int cannyThreshold, int votesThreshold, HoughCirclesDetectorImpl::HoughCirclesDetectorImpl(float dp, float minDist, int cannyThreshold, int votesThreshold,
int minRadius, int maxRadius, int maxCircles) : int minRadius, int maxRadius, int maxCircles) :
...@@ -219,9 +222,21 @@ namespace ...@@ -219,9 +222,21 @@ namespace
const float minDist2 = minDist_ * minDist_; const float minDist2 = minDist_ * minDist_;
vector<Vec3f> sortBuf;
for(int i=0; i<centersCount; i++){
Vec3f temp;
temp[0] = oldBuf[i].x;
temp[1] = oldBuf[i].y;
temp[2] = tt.at<int>(temp[1]+1, temp[0]+1);
sortBuf.push_back(temp);
}
std::sort(sortBuf.begin(), sortBuf.end(), centersCompare);
for (int i = 0; i < centersCount; ++i) 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; bool good = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment