JavaCV assertion failed <p>I am trying to use K-means JavaCV implementation, but I have the following error:</p> <pre><code>OpenCV Error: Assertion failed (!centers.empty()) in cvKMeans2, file src\matrix.cpp, line 4233 </code></pre> <p>My source code is:</p> <pre><code>IplImage src = cvLoadImage(fileName, CV_LOAD_IMAGE_COLOR); int cluster_count = 3; int attempts = 10; CvTermCriteria termCriteria = new CvTermCriteria(TermCriteria.EPS + TermCriteria.MAX_ITER, 10, 1.0); cvReshape(src, src.asCvMat(), 1, src.height() * src.width()); IplImage samples = cvCreateImage(cvGetSize(src), src.depth(), 1); cvConvertImage(src, samples, CV_32F); IplImage labels = cvCreateImage(new CvSize(samples.height()), 1, CV_8U); IplImage centers = cvCreateImage(new CvSize(cluster_count), 1, CV_32F); cvKMeans2(samples, cluster_count, labels, termCriteria, 1, new long[attempts], KMEANS_RANDOM_CENTERS, centers, new double[attempts]); </code></pre> <p>I'm beginner on JavaCV and would to know what I doing wrong in this code?</p>