Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Save flann matcher data for use later

I'm currently using this code to generate a Flann based matcher:

flann_params = dict(algorithm = 1, trees = 4)
matcher = cv2.FlannBasedMatcher(flann_params, {})

# Train FLANN matcher with descriptors of all images
for f in os.listdir("images/"):
    image = get_image("./images/%s" % (f,))
    keypoints, descriptors = get_image_features(image)
    matcher.add([descriptors])
    files.append(f)
    matcher.train()

What I want to do is to save the Flann index generated and use it later on by simply loading it, from a file on the disk. How to do that? I've searched extensively for this in the reference manual but found nothing in OpenCV's Python docs.

Save flann matcher data for use later

I'm currently using this code to generate a Flann based matcher:matcher in Python using OpenCV's cv2 module:

flann_params = dict(algorithm = 1, trees = 4)
matcher = cv2.FlannBasedMatcher(flann_params, {})

# Train FLANN matcher with descriptors of all images
for f in os.listdir("images/"):
    image = get_image("./images/%s" % (f,))
    keypoints, descriptors = get_image_features(image)
    matcher.add([descriptors])
    files.append(f)
    matcher.train()

What I want to do is to save the Flann index generated and use it later on by simply loading it, from a file on the disk. How to do that? I've searched extensively for this in the reference manual but found nothing in OpenCV's Python docs.

click to hide/show revision 3
retagged

updated 2014-05-30 10:04:46 -0500

berak gravatar image

Save flann matcher data for use later

I'm currently using this code to generate a Flann based matcher in Python using OpenCV's cv2 module:

flann_params = dict(algorithm = 1, trees = 4)
matcher = cv2.FlannBasedMatcher(flann_params, {})

# Train FLANN matcher with descriptors of all images
for f in os.listdir("images/"):
    image = get_image("./images/%s" % (f,))
    keypoints, descriptors = get_image_features(image)
    matcher.add([descriptors])
    files.append(f)
    matcher.train()

What I want to do is to save the Flann index generated and use it later on by simply loading it, from a file on the disk. How to do that? I've searched extensively for this in the reference manual but found nothing in OpenCV's Python docs.