title: OpenCV's clustering function cvKMeans2() - why doesnt work when i use the centers parameter
body: <p>i use this code. its should print the clusters labels an then the centroids. but the 'center"matrix with the centriod seems to be empty,full of zeros. what is wrong my friends?</p>
  
  <pre><code> #include &lt;iostream&gt;
     #include &lt;stdio.h&gt;
  
  
       #include "cxcore.h"
        #include "highgui.h"
          using namespace cv;
  
  
         int main( int argc, char** argv )
         {
  
          int i,j;
  
  
                CvMat* points = cvCreateMat( 5, 2, CV_32FC1 );
                  CvMat* centers2 = cvCreateMat( 5, 2, CV_32FC1 );
                 CvMat* clusters = cvCreateMat( 5, 1, CV_32SC1 );
  
                 cvSetReal2D( points, 0, 0,1);
                    cvSetReal2D( points, 0, 1,1);
                     cvSetReal2D( points, 1, 0,2);
                      cvSetReal2D( points, 1, 1,2);
                       cvSetReal2D( points, 2, 0,6);
                          cvSetReal2D( points, 2, 1,6);
                        cvSetReal2D( points, 3, 0,5);
                         cvSetReal2D( points, 3, 1,5);
                                cvSetReal2D( points, 4, 0,10);
                               cvSetReal2D( points, 4, 1,10);
   cvKMeans2(points,3,clusters,cvTermCriteria(CV_TERMCRIT_EPS,1000,0 ), 
   1000,0,KMEANS_RANDOM_CENTERS,centers2,0);
  
   for(i=0;i&lt;5;i++)
    printf( " %lf \n", cvGetReal2D(clusters,i, 0));
  
         for(i=0;i&lt;5;i++){
                for(j=0;j&lt;2;j++){
          printf( "center %i %i = %f \n", i, j, cvGetReal2D(centers2,i, j));
      }
    }
  
  
            cvReleaseMat(&amp;points);
                 cvReleaseMat(&amp;centers2);
                    cvReleaseMat(&amp;clusters);
                        }
  </code></pre>