Commit 7c13d327 authored by Nghia Ho's avatar Nghia Ho Committed by Alexander Smorkalov

Fixed a valgrind 'Conditional jump or move depends on uninitialised value(s)' on…

Fixed a valgrind 'Conditional jump or move depends on uninitialised value(s)' on cv::kmeans(...). The original code used points(sampleCount, 1, CV_32FC2), which confused generateCentersPP into thinking it is a 1 dimensional center, instead of 2. As a result it would set only the x variable and leave y unitialised.
(cherry picked from commit 601b7d1d)
parent 345b3b0b
...@@ -33,7 +33,7 @@ int main( int /*argc*/, char** /*argv*/ ) ...@@ -33,7 +33,7 @@ int main( int /*argc*/, char** /*argv*/ )
{ {
int k, clusterCount = rng.uniform(2, MAX_CLUSTERS+1); int k, clusterCount = rng.uniform(2, MAX_CLUSTERS+1);
int i, sampleCount = rng.uniform(1, 1001); int i, sampleCount = rng.uniform(1, 1001);
Mat points(sampleCount, 1, CV_32FC2), labels; Mat points(sampleCount, 2, CV_32F), labels;
clusterCount = MIN(clusterCount, sampleCount); clusterCount = MIN(clusterCount, sampleCount);
Mat centers(clusterCount, 1, points.type()); Mat centers(clusterCount, 1, points.type());
......
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