Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

DescriptorExtractor.compute() is not removing keypoints

According to this documentation: http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_extractors.html#descriptorextractor-compute "Keypoints for which a descriptor cannot be computed are removed." but in this code:

Mat c1 = Highgui.imread("kf1.png");
Mat c2 = Highgui.imread("kf2.png");

Mat f1 = new Mat();
Mat f2 = new Mat();

Imgproc.cvtColor(c1, f1, Imgproc.COLOR_BGR2GRAY);
Imgproc.cvtColor(c2, f2, Imgproc.COLOR_BGR2GRAY);

FeatureDetector detector = FeatureDetector.create(FeatureDetector.PYRAMID_FAST);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);

MatOfKeyPoint mkpf1 = new MatOfKeyPoint();
MatOfKeyPoint mkpf2 = new MatOfKeyPoint();
Mat df1 = new Mat();
Mat df2 = new Mat();

detector.detect(f1, mkpf1);
detector.detect(f2, mkpf2);

System.out.println("Keypoints detected for f2: " + mkpf2.total());
System.out.println("Keypoints detected for f1: " + mkpf1.total());

extractor.compute(f1, mkpf1, df1);
extractor.compute(f2, mkpf2, df2);

System.out.println("Keypoints after extractor for f2: " + mkpf2.rows());
System.out.println("Keypoints after extractor for f1: " + mkpf1.rows());

Keypoints are never removed causing wrong behavior. Can anybody tell me why o how to solve this? Thanks!