Ask Your Question
0

Features2D + Homography Tutorial

asked 2016-07-28 21:54:55 -0600

Zou gravatar image

Hi,

I'm beginner in OpenCV domain and currently I try to implement the "Features2D + Homography tutorial" in Java with OpenCV3.1 and the supplied Java bindings.

In this code:

//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );
double max_dist = 0; double min_dist = 100; 
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_object.rows; i++ )
{ double dist = matches[i].distance;
    if( dist < min_dist ) min_dist = dist;
    if( dist > max_dist ) max_dist = dist;
}

Why in the for loop they use descriptors_object.rows ? Why not using the matches vector's length ?

And my second question is what exactly contains a descriptors_object/descriptors_scene Mat ? Is it a 2 dimension Mat ? With the same width and height than the image used to create this descriptor ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-29 01:30:49 -0600

berak gravatar image

updated 2016-07-29 03:40:25 -0600

"Why in the for loop they use descriptors_object.rows ? Why not using the matches vector's length ?"

that's the same. (though the size of descriptors_object and descriptors_scene will differ, the matching goes from object -> scene, so there will be as many matches than object descriptors)

"what exactly contains a descriptors_object/descriptors_scene Mat ?"

a 2d Mat. numRows == number of keypoints, numCols == length of descriptor (e.g. 32 bytes for ORB, 128 floats for SIFT) . each descriptor is on a single row.

" I try to implement the "Features2D + Homography tutorial" in Java with OpenCV3.1"

since you cannot use SIFT or SURF from java, you'll probably have to use ORB or AKAZE instead, and a BFMAtcher instead of the flann-based matcher. have a look here and here

also , please use http://docs.opencv.org/master and http://docs.opencv.org/java/3.1.0 for 3.1 !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-28 21:54:55 -0600

Seen: 764 times

Last updated: Jul 29 '16