mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
Merge pull request #11101 from lamantine:fix_11100
* fixed bug #11100 Integer overflow in kmeans * fixed integer overflow in other divUp-s in kmeans code fixed warning about size_t to double conversion
This commit is contained in:
parent
2dac35a97d
commit
22ecdd16ef
@ -128,7 +128,7 @@ static void generateCentersPP(const Mat& data, Mat& _out_centers,
|
||||
|
||||
parallel_for_(Range(0, N),
|
||||
KMeansPPDistanceComputer(tdist2, data, dist, ci),
|
||||
divUp(dims * N, CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
(double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
double s = 0;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
@ -429,14 +429,14 @@ double cv::kmeans( InputArray _data, int K,
|
||||
if (isLastIter)
|
||||
{
|
||||
// don't re-assign labels to avoid creation of empty clusters
|
||||
parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists, labels, data, centers), divUp(dims * N, CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists, labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
compactness = sum(Mat(Size(N, 1), CV_64F, &dists[0]))[0];
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// assign labels
|
||||
parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists, labels, data, centers), divUp(dims * N * K, CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists, labels, data, centers), (double)divUp((size_t)(dims * N * K), CV_KMEANS_PARALLEL_GRANULARITY));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user