Ask Your Question
0

How can I get keypoints for given location in MATLAB

asked 2015-03-19 05:06:10 -0500

Kashif gravatar image

I am working in MATLAB, i connected MATLAB with opencv through mexopencv. I want to extract BRIEF descriptors for some keypoints. I am getting keypoints by following code.

detector = cv.FeatureDetector('STAR');
keypoints = detector.detect(im);
extractor = cv.DescriptorExtractor('BRIEF');
descriptors = extractor.compute(im, keypoints);

This code is working fine. But I want dont want to use this command.

keypoints = detector.detect(im);

Instead, I want to get keypoints on my specific location. For example... I want to do this...

keypoint1 = cv.KeyPoint (16,16);

But this is not working...

How can I get keypoints for my specific location? Thank you, Best Regards,

edit retag flag offensive close merge delete

Comments

This is not working because as someone else already answer you (http://answers.opencv.org/question/57737/how-to-extract-brief-descriptor-for-the-keypoint-on-given-location/), keypoints carry other information than just the 2D coordinate.

In C++: http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html#keypoint-keypoint, in Matlab I do not kow.

Eduardo gravatar imageEduardo ( 2015-03-19 05:51:53 -0500 )edit

Yes, I know Keypoints carry other information, but I am not able to call cv2.KeyPoint() method in MATLAB... cv.KeyPoint() is not working/available... is there any alternate?

Kashif gravatar imageKashif ( 2015-03-19 06:06:29 -0500 )edit

Why matlab?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-19 07:40:12 -0500 )edit

@thdrksdfthmn... I have already written a lot of code in MATLAB and used other descriptors such as SURF, BRISK, FREAK etc... and I want to replace BRIEF descriptor only in the code.

Kashif gravatar imageKashif ( 2015-03-19 09:13:48 -0500 )edit

As Eduardo says, maybe you shall try KeyPoint(16, 16, 16) or KeyPoint(16, 16, 16, -1, 0, 0, -1)...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-19 10:02:02 -0500 )edit

I tried, it didn't work. Thank you btw... I resolved the issue by another way (By editing the location of randomly obtained keypoints)..

Kashif gravatar imageKashif ( 2015-03-19 11:50:07 -0500 )edit

What do you mean by "editing the location of randomly obtained keypoints"? You can post the answer...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-20 03:46:26 -0500 )edit

Though Its not a standard way. I used the same code as above.

detector = cv.FeatureDetector('STAR'); keypoints = detector.detect(im);

Then I took first keypoint and changed the location as followed.

keypoint1 = keypoints(1);

keypoint1.pt = [16,16];

And computed the descriptor for my desired point.

extractor = cv.DescriptorExtractor('BRIEF'); descriptors = extractor.compute(im, keypoint1);

(In my case, point location is important, size, angle etc of keypoint does not matter)

Kashif gravatar imageKashif ( 2015-03-20 05:33:54 -0500 )edit

So you are saying that each detector returns features in different locations and you want to "compare" the different extractors based on the same feature location? Why not using Dense and different extractors (and because extractors are of different sizes, just eliminate keypoints on the border of the image)?

Or you are saying that detect finds keypoints in different places even if the image is the same?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-20 07:47:23 -0500 )edit

I wanted to compute BRIEF descriptors on my specified locations. This is part of another task that I am doing.

Kashif gravatar imageKashif ( 2015-03-20 10:24:23 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-04-13 05:26:10 -0500

Carole gravatar image

I know it's an old post, but I just had the same issue. So just in case someone else run into the same problem! You can do something like this :


image = imread('image.jpg');
points2f=[10 20;30 40;50 60]
keypoints=cv.KeyPointsFilter.convertFromPoints(points2f,'Size',2)
extractor = cv.DescriptorExtractor('BRIEF');
descriptors = extractor.compute(image, keypoints);

However the problem is OpenCV won't reestimate your angle or scale you provide. By default an angle of -1 is given (meaning you did not give any angle) If someone else tries to find the same answer but for 'SIFT', I would recommend using vl_feat in matlab with :

Coordinates=[10 20;30 40;50 60]
frames=Coordinates;
frames(3,:)=scale;
[F,D] = vl_covdet(image,'frames',frames,'estimateAffineShape', true,'estimateOrientation', true) ;

This way, the angle is reestimated (but not the scale...)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-03-19 05:06:10 -0500

Seen: 486 times

Last updated: Mar 19 '15