I am using opencv 3.2 for Java (build source with contrib modules), and trying to use SURF + BOWKMeansTrainer for detect, but it throws an error when I run it.
我正在为Java使用opencv 3.2(带有后悔模块的构建源代码),并试图使用SURF + BOWKMeansTrainer进行检测,但是当我运行它时它会抛出一个错误。
My code:
我的代码:
//read jpg to variable trainMats
//...
//train
Mat allDesc = new Mat();
int clusterCount = 30;
FeatureDetector detector = FeatureDetector.create(FeatureDetector.SURF);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
BOWTrainer bowTrainer = new BOWKMeansTrainer(clusterCount);
for(int i = 0; i < trainMats.size(); i++) {
Mat trainMat = trainMats.get(i);
MatOfKeyPoint matOfKeyPoint = new MatOfKeyPoint();
Mat desc = new Mat();
detector.detect(trainMat, matOfKeyPoint);
extractor.compute(trainMat, matOfKeyPoint, desc);
allDesc.push_back(desc);
}
Mat dictionary = bowTrainer.cluster(allDesc);
//...
throw error:
把错误:
Exception in thread "main" java.lang.Exception: unknown exception
at org.opencv.features2d.BOWKMeansTrainer.cluster_1(Native Method)
at org.opencv.features2d.BOWKMeansTrainer.cluster(BOWKMeansTrainer.java:62)
1 个解决方案
#1
0
Is by the OpenCV version. Try using 2.4.11
是OpenCV版本。试着用2.4.11
#1
0
Is by the OpenCV version. Try using 2.4.11
是OpenCV版本。试着用2.4.11