Commit 9ba659af authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #12660 from alalek:flann_drop_useless_mutex

parents be989b3b 52f52f67
......@@ -276,7 +276,7 @@ public:
public:
KMeansDistanceComputer(Distance _distance, const Matrix<ElementType>& _dataset,
const int _branching, const int* _indices, const Matrix<double>& _dcenters, const size_t _veclen,
int* _count, int* _belongs_to, std::vector<DistanceType>& _radiuses, bool& _converged, cv::Mutex& _mtx)
int* _count, int* _belongs_to, std::vector<DistanceType>& _radiuses, bool& _converged)
: distance(_distance)
, dataset(_dataset)
, branching(_branching)
......@@ -287,7 +287,6 @@ public:
, belongs_to(_belongs_to)
, radiuses(_radiuses)
, converged(_converged)
, mtx(_mtx)
{
}
......@@ -311,12 +310,10 @@ public:
radiuses[new_centroid] = sq_dist;
}
if (new_centroid != belongs_to[i]) {
count[belongs_to[i]]--;
count[new_centroid]++;
CV_XADD(&count[belongs_to[i]], -1);
CV_XADD(&count[new_centroid], 1);
belongs_to[i] = new_centroid;
mtx.lock();
converged = false;
mtx.unlock();
}
}
}
......@@ -332,7 +329,6 @@ public:
int* belongs_to;
std::vector<DistanceType>& radiuses;
bool& converged;
cv::Mutex& mtx;
KMeansDistanceComputer& operator=( const KMeansDistanceComputer & ) { return *this; }
};
......@@ -801,8 +797,7 @@ private:
}
// reassign points to clusters
cv::Mutex mtx;
KMeansDistanceComputer invoker(distance_, dataset_, branching, indices, dcenters, veclen_, count, belongs_to, radiuses, converged, mtx);
KMeansDistanceComputer invoker(distance_, dataset_, branching, indices, dcenters, veclen_, count, belongs_to, radiuses, converged);
parallel_for_(cv::Range(0, (int)indices_length), invoker);
for (int i=0; i<branching; ++i) {
......
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