kmeans crashes with unknown exception

asked 2018-07-17 11:58:18 -0500

mikegwf1 gravatar image

updated 2018-07-17 18:11:25 -0500

Hi, I am using opencv 3.41 and the Java interface. I am using the kmeans clustering method, which has been working for me in the past but crashed today with an "unknown exception". The crash dump looks as follows:

java.lang.Exception: unknown exception at org.opencv.core.Core.kmeans_0(Native Method) at org.opencv.core.Core.kmeans(Core.java:468) at bll.CVClusterSentenceVectors.clusterSentenceVectors(CVClusterSentenceVectors.java:103) at bll.CVClusterSentenceVectors.clusterSentenceVectorsTop(CVClusterSentenceVectors.java:44) at mains.CVClusterSentenceVectorsMain.main(CVClusterSentenceVectorsMain.java:14)

My code is the following:

    Core.kmeans(t1, par.clusterCount, labels, criteria, 1, Core.KMEANS_PP_CENTERS, centers);

where: t1 - matrix of 3152034 vectors of dimension 300 par.clusterCount = 10000 labels - new Mat(); criteria - new TermCriteria(TermCriteria.EPS + TermCriteria.MAX_ITER, par.maxIterationCount, par.variationValue); where par.maxIterationCount=10 and par.variationValue=.001 centers - new Mat();

Almost exactly this code has worked for me in the past. The only difference is that I am now using TermCriteria.EPS + TermCriteria.MAX_ITER and in the past I've only used these criteria separately. Is there a problem with this usage?

I've now tried the code with criteria - new TermCriteria(TermCriteria.EPS, par.maxIterationCount, par.variationValue); which is exactly what worked before, but I still get the unknown exception. I also wrote a small program to dump my data to a text file and that worked, so the data should be valid.

Also, what would be regarded as a reasonable EPS value for kmeans. Is .001 too tight?

How do I go about diagnosing the issue since I am not getting back specific information about the exception?

Thanks, Mike

edit retag flag offensive close merge delete