Help required converting a few lines of Python to Java (Android)

asked 2016-02-27 11:14:40 -0600

Hi, I've been trying to implement the following Python example from the OpenCV docs into Java for OpenCV4Android:

http://docs.opencv.org/3.0-beta/doc/p...

I'm stuck on this particular part for the FLANN based matcher and was wondering if anyone could help me out:

FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)

flann = cv2.FlannBasedMatcher(index_params, search_params)

matches = flann.knnMatch(des1,des2,k=2)

// store all the good matches as per Lowe's ratio test. 
good = []
for m,n in matches:
    if m.distance < 0.7*n.distance:
        good.append(m)

So far I have:

DescriptorMatcher FLANN = DescriptorMatcher.create(1);
FLANN.knnMatch(descriptorsRef, descriptors, matches, 2);

I'm struggling to figure out how to express the index_params and search_params as well as the for loop for storing all the good matches as per Lowe's ratio test.

Any help would be very much appreciated!

edit retag flag offensive close merge delete