Ask Your Question

DescriptorExtractor.compute() is not removing keypoints

asked 2013-03-23 17:06:53 -0600

rylexr gravatar image

According to this documentation: "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: " +;
System.out.println("Keypoints detected for f1: " +;

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!

edit retag flag offensive close merge delete



Under what circumstances are you expecting that a descriptor can't be computed? compute() only removes a Keypoint if it can't compute a descriptor for it, which is a rather rare occurance.

HD_Mouse gravatar imageHD_Mouse ( 2013-03-23 20:21:20 -0600 )edit

For whatever pair of stereo images you'll see that the number of computed descriptors (df1 and df2) is less than the number of keypoints after extractor.compute() is called. The problem is that you'll not know what descriptors belongs to what keypoints because the relation keypoint i to descriptor i doesn't hold and "uncomputed" keypoints are never removed no matter what. I've tested the exact same code on c++ and it works perfectly. Keypoints are removed just after the extractor.compute() call but unfortunately fails in Java.

rylexr gravatar imagerylexr ( 2013-03-24 19:52:24 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-27 17:23:00 -0600

rylexr gravatar image

updated 2013-03-27 17:23:36 -0600

I submitted the bug report and they fixed it. Thanks!

edit flag offensive delete link more

Question Tools


Asked: 2013-03-23 17:06:53 -0600

Seen: 697 times

Last updated: Mar 27 '13