From: Nghia Ho Date: Mon, 6 Jan 2014 09:19:07 +0000 (+1100) Subject: Fixed a valgrind 'Conditional jump or move depends on uninitialised value(s)' on... X-Git-Tag: accepted/tizen/ivi/20140515.103456~1^2~145^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=601b7d1dd3a3ec9e8af5df461d43632d98ed3a7a;p=profile%2Fivi%2Fopencv.git 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. --- diff --git a/samples/cpp/kmeans.cpp b/samples/cpp/kmeans.cpp index 97de6a0..b742112 100644 --- a/samples/cpp/kmeans.cpp +++ b/samples/cpp/kmeans.cpp @@ -33,7 +33,7 @@ int main( int /*argc*/, char** /*argv*/ ) { int k, clusterCount = rng.uniform(2, MAX_CLUSTERS+1); 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); Mat centers(clusterCount, 1, points.type());