|
|
@ -166,11 +166,13 @@ KDTree(const cv::Mat &img, const int _leafNumber, const int _zeroThresh) |
|
|
|
int dimIdx = getMaxSpreadN(_left, _right); |
|
|
|
int dimIdx = getMaxSpreadN(_left, _right); |
|
|
|
KDTreeComparator comp( this, dimIdx ); |
|
|
|
KDTreeComparator comp( this, dimIdx ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int> _idx(idx.begin(), idx.end()); |
|
|
|
std::nth_element(/**/ |
|
|
|
std::nth_element(/**/ |
|
|
|
idx.begin() + _left, |
|
|
|
_idx.begin() + _left, |
|
|
|
idx.begin() + nth, |
|
|
|
_idx.begin() + nth, |
|
|
|
idx.begin() + _right, comp |
|
|
|
_idx.begin() + _right, comp |
|
|
|
/**/); |
|
|
|
/**/); |
|
|
|
|
|
|
|
idx = _idx; |
|
|
|
|
|
|
|
|
|
|
|
left.push(_left); right.push(nth + 1); |
|
|
|
left.push(_left); right.push(nth + 1); |
|
|
|
left.push(nth + 1); right.push(_right); |
|
|
|
left.push(nth + 1); right.push(_right); |
|
|
@ -280,11 +282,12 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Point2i> &tr |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::partial_sort( amount.begin(), amount.begin() + nTransform, |
|
|
|
int num = std::min((int)amount.size(), (int)nTransform); |
|
|
|
|
|
|
|
std::partial_sort( amount.begin(), amount.begin() + num, |
|
|
|
amount.end(), std::greater< std::pair<double, int> >() ); |
|
|
|
amount.end(), std::greater< std::pair<double, int> >() ); |
|
|
|
|
|
|
|
|
|
|
|
transforms.resize(nTransform); |
|
|
|
transforms.resize(num); |
|
|
|
for (int i = 0; i < nTransform; ++i) |
|
|
|
for (int i = 0; i < num; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = amount[i].second; |
|
|
|
int idx = amount[i].second; |
|
|
|
transforms[i] = cv::Point2i( shiftM[idx].x, shiftM[idx].y ); |
|
|
|
transforms[i] = cv::Point2i( shiftM[idx].x, shiftM[idx].y ); |
|
|
|