Making FLANN matcher editable and savable to disk?

asked 2014-09-11 02:25:45 -0600

bad_keypoints gravatar image

updated 2014-09-11 02:49:40 -0600

berak gravatar image

I have my FLANN matcher here:

flann_params = dict(algorithm = 1, trees = 4)

matcher = cv2.FlannBasedMatcher(flann_params, {})

And then I add descriptors of training images to it in a loop:

matcher.add([descriptors])

And then I train it:

matcher.train()

Few more related methods:

matcher.clear()

Clears the train descriptor collection

matcher.empty()

Does the same thing ( right?)

But what I really want is,

A) to store the descriptors to disk and simply load them into the matcher and then train it

OR

Save the matcher data to disk so that I don't have to train images everytime I run the program.

B) Make the matcher editable: if I delete an image off the disk, it shouldn't be found by the matcher. Maybe something like matcher.clear(index_of_image_deleted)

edit retag flag offensive close merge delete

Comments

matcher.empty() only checks if it is empty.

A) since your descriptors are just numpy arrays: numpy.save

B) afaik, it's not possible to remove items from a flann index, you will have to retrain it.

berak gravatar imageberak ( 2014-09-11 02:44:18 -0600 )edit

@berak, that's what I already have in mind (your point B). I just wanted to know if anyone has ever done anything (maybe using a third party library) to save the matcher data to disk. Thanks for your input though.

bad_keypoints gravatar imagebad_keypoints ( 2014-09-11 05:14:43 -0600 )edit

the long story is: in c++ you can serialize a descriptormatcher using the FileStorage. that part is just not available from python

berak gravatar imageberak ( 2014-09-11 05:29:40 -0600 )edit