mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Merge pull request #17724 from pemmanuelviel:pev--fix-mix-of-types
This commit is contained in:
commit
deaf1dd458
@ -725,15 +725,6 @@ private:
|
||||
}
|
||||
|
||||
|
||||
cv::AutoBuffer<double> dcenters_buf(branching*veclen_);
|
||||
Matrix<double> dcenters(dcenters_buf.data(), branching, veclen_);
|
||||
for (int i=0; i<centers_length; ++i) {
|
||||
ElementType* vec = dataset_[centers_idx[i]];
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
dcenters[i][k] = double(vec[k]);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DistanceType> radiuses(branching);
|
||||
cv::AutoBuffer<int> count_buf(branching);
|
||||
int* count = count_buf.data();
|
||||
@ -747,10 +738,10 @@ private:
|
||||
int* belongs_to = belongs_to_buf.data();
|
||||
for (int i=0; i<indices_length; ++i) {
|
||||
|
||||
DistanceType sq_dist = distance_(dataset_[indices[i]], dcenters[0], veclen_);
|
||||
DistanceType sq_dist = distance_(dataset_[indices[i]], dataset_[centers_idx[0]], veclen_);
|
||||
belongs_to[i] = 0;
|
||||
for (int j=1; j<branching; ++j) {
|
||||
DistanceType new_sq_dist = distance_(dataset_[indices[i]], dcenters[j], veclen_);
|
||||
DistanceType new_sq_dist = distance_(dataset_[indices[i]], dataset_[centers_idx[j]], veclen_);
|
||||
if (sq_dist>new_sq_dist) {
|
||||
belongs_to[i] = j;
|
||||
sq_dist = new_sq_dist;
|
||||
@ -762,6 +753,15 @@ private:
|
||||
count[belongs_to[i]]++;
|
||||
}
|
||||
|
||||
cv::AutoBuffer<double> dcenters_buf(branching*veclen_);
|
||||
Matrix<double> dcenters(dcenters_buf.data(), branching, veclen_);
|
||||
for (int i=0; i<centers_length; ++i) {
|
||||
ElementType* vec = dataset_[centers_idx[i]];
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
dcenters[i][k] = double(vec[k]);
|
||||
}
|
||||
}
|
||||
|
||||
bool converged = false;
|
||||
int iteration = 0;
|
||||
while (!converged && iteration<iterations_) {
|
||||
|
Loading…
Reference in New Issue
Block a user