Commit 55a714c8 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fix cv::kmeans function

reshape input matrix, since the function works with data
as with [N x dims] matrix
parent 09674623
......@@ -2701,6 +2701,8 @@ double cv::kmeans( InputArray _data, int K,
CV_Assert( data.dims <= 2 && type == CV_32F && K > 0 );
CV_Assert( N >= K );
data = data.reshape(1, N);
_bestLabels.create(N, 1, CV_32S, -1, true);
Mat _labels, best_labels = _bestLabels.getMat();
......
......@@ -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, 2, CV_32F), labels;
Mat points(sampleCount, 1, CV_32FC2), labels;
clusterCount = MIN(clusterCount, sampleCount);
Mat centers;
......
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