Descriptor Extractor causes errors
i wrote the below code to do features matching for list of Mat objects, the problem is at run time i receive the below posted errors, as far as i understood it, i checked the extenstion and the size of the used image and they are .jpg and 538 * 522 except one image is 538 * 520
is the image with different size might cause such error? please help me to fix this issue.
Code:
public static void main(String[] args) {
loadOpenCVLib();
/*Step_1: Feature Detection*/
initFeatureDetector();
/*Step_2: Descriptor Extractor*/
initDescriptorExtractor();
}
private static void initDescriptorExtractor() {
// TODO Auto-generated method stub
descriptorsList = new ArrayList<Mat>();
descriptorsList.add(new Mat());
descriptorsList.add(new Mat());
descriptorsList.add(new Mat());
DescriptorExtractor descripExtractor =
DescriptorExtractor.create(DescriptorExtractor.SIFT);
descripExtractor.compute(matList, keyPointsList, descriptorsList);
//descripExtractor.write(fileName) test this method
//descripExtractor.read(fileName)
}
private static void initFeatureDetector() {
// TODO Auto-generated method stub
matList = new ArrayList<Mat>();
keyPointsList = new ArrayList<MatOfKeyPoint>();
matList.add(path2Mat(path_jf00));
matList.add(path2Mat(path_jf01));
matList.add(path2Mat(path_jf02));
keyPointsList.add(newMatKeyPoints());
keyPointsList.add(newMatKeyPoints());
keyPointsList.add(newMatKeyPoints());
FeatureDetector featsDetect =
FeatureDetector.create(FeatureDetector.SURF);
featsDetect.detect(matList, keyPointsList);
}
private static void loadOpenCVLib() {
// TODO Auto-generated method stub
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
private static Mat path2Mat(String path2File) {
// TODO Auto-generated method stub
return Highgui.imread(path2File);
}
private static MatOfKeyPoint newMatKeyPoints() {
return new MatOfKeyPoint();
}
}
Error:
OpenCV Error: Assertion failed (imageCollection.size() ==
pointCollection.size()) in cv::DescriptorExtractor::compute, file
..\..\..\..\opencv\modules\features2d\src\descriptors.cpp, line 74
Exception in thread "main" CvException [org.opencv.core.CvException:
cv::Exception: ..\..\..\..\opencv\modules\features2d
\src\descriptors.cpp:74: error: (-215) imageCollection.size() ==
pointCollection.size() in function cv::DescriptorExtractor::compute
]
at org.opencv.features2d.DescriptorExtractor.compute_1(Native Method)
at
org.opencv.features2d.DescriptorExtractor.compute(DescriptorExtractor.java:140)
at test.FeatsMatch.initDescriptorExtractor(FeatsMatch.java:40)
at test.FeatsMatch.main(FeatsMatch.java:28)