Ask Your Question

Revision history [back]

Use of Kmean C++

Hello everybody,

I'm confronted to a problem in my attempt to use Kmean form OpenCV. I'am using C++11 with the IDE qtcreator on ubuntu 14.04.

Concerning my problem, I have a collection of samples caracterized by a constant amount of complex features.

My first Idea was to send a vecor of vector of complex to kmean but as you may no it didn't work. So i decided to use a cv::Mat filled with my samples. So I have a cv::Mat in which: rows = samples cols = features (a complex coefficient is seen as two float so the real number of features in my cv::Mat is twice the original number of features).

With such an input, I have no error when running the code BUT, the outpur of : cv::kmeans(bdd, nbClusters, labels,cv::TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 10, 1.0), attempts, cv::KMEANS_RANDOM_CENTERS, centers );

cerr << centers.size() << endl;

cerr << centers<< endl;

cerr << labels.size() << endl;

is:

[0 x 0]

[]

[1 x 800]

So the kmean function did not work.

Does someone has an idea of how to fix that promblem?

Thanks a lot

click to hide/show revision 2
No.2 Revision

updated 2015-01-17 04:51:31 -0600

berak gravatar image

Use of Kmean C++

Hello everybody,

I'm confronted to a problem in my attempt to use Kmean Kmeans form OpenCV. I'am using C++11 with the IDE qtcreator on ubuntu 14.04.

Concerning my problem, I have a collection of samples caracterized by a constant amount of complex features.

My first Idea was to send a vecor of vector of vector of complex to kmean kmeans but as you may no it didn't work. So i decided to use a cv::Mat filled with my samples. So I have a cv::Mat in which: which:

rows = samples samples

cols = features (a complex coefficient is seen as two float so the real number of features in my cv::Mat is twice the original number of features).

With such an input, I have no error when running the code BUT, the outpur of : output of :

cv::kmeans(bdd, nbClusters, labels,cv::TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 10, 1.0), attempts, cv::KMEANS_RANDOM_CENTERS, centers );

); cerr << centers.size() << endl;

endl;

    cerr << centers<< endl;

 cerr << labels.size() << endl;

is:

[0 x 0]

[]

0] [] [1 x 800]

800]

So the kmean function did not work.

Does someone has an idea of how to fix that promblem?

Thanks a lot