# detectAndCompute method not working for useProvidedKeypoints flag

(JAVA) I am using Akaze to detect keypoints. I then prune keypoints according to few criteria. But passing those keypoints to the detectAndCompute method by setting the 'useProvidedKeypoints' flag to true, doesn't compute the descriptor. Instead the keypoint becomes null after calling the method. Please post the necessary fix.

edit retag close merge delete

Sort by » oldest newest most voted

Instead the keypoint becomes null after calling the method.

this means, no descriptors could be computed for your given keypoints (so the invalid ones were removed)

I then prune keypoints according to few criteria

this needs some explanation ? you're pruning unmatched keypoints ? why at all?

hate to say so, but most probably you'll have to change your concept. maybe your pruning is broken ? maybe you can't do this with AKAZE keypoint ? noone knows,without more information

more

Sorry for not being clear, earlier. The below is a snippet of what I'm trying to do. By pruning, I meant I'm taking the top, say 40 keypoints by comparing the response field of the keypoints. I did run akaze with detectAndCompute() method and it worked as expected. Which is why, I thought of separating the methods to pick top keypoints. Please let me know if there's a much easier way to go about this. Thanks

( 2019-04-22 07:08:16 -0500 )edit

descriptors = new Mat(); keypoints = new MatOfKeyPoint();

            // Separate detect and compute
akaze.detect(logoMat, keypoints);
List<KeyPoint> kps= keypoints.toList().stream()
.sorted((KeyPoint k1, KeyPoint k2) -> ((Float)
k2.response).compareTo(((Float) k1.response)))
.collect(Collectors.toList());

kps= kps.subList(0, 40 > kps.size()? kps.size(): 40);
MatOfKeyPoint mkp= new MatOfKeyPoint();
mkp.fromList(kps);

// using from already detected keypoints
akaze.detectAndCompute(logoMat, new Mat(), mkp, descriptors, true);

( 2019-04-22 07:08:40 -0500 )edit

Official site

GitHub

Wiki

Documentation