Skip to content

Update annf.hpp #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions modules/xphoto/src/annf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ KDTree(const cv::Mat &img, const int _leafNumber, const int _zeroThresh)
int dimIdx = getMaxSpreadN(_left, _right);
KDTreeComparator comp( this, dimIdx );

std::vector<int> _idx(idx.begin(), idx.end());
std::nth_element(/**/
idx.begin() + _left,
idx.begin() + nth,
idx.begin() + _right, comp
_idx.begin() + _left,
_idx.begin() + nth,
_idx.begin() + _right, comp
/**/);
idx = _idx;

left.push(_left); right.push(nth + 1);
left.push(nth + 1); right.push(_right);
Expand Down Expand Up @@ -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> >() );

transforms.resize(nTransform);
for (int i = 0; i < nTransform; ++i)
transforms.resize(num);
for (int i = 0; i < num; ++i)
{
int idx = amount[i].second;
transforms[i] = cv::Point2i( shiftM[idx].x, shiftM[idx].y );
Expand Down