Saving Matcher/Descriptors

asked 2013-01-05 15:44:09 -0500

Mr.Mountain gravatar image

updated 2013-01-05 15:44:50 -0500

Hello, I'm currently working on a small application which should index some images and store this index. I'm reading the image and getting the keypoints. For writing down the data I would use yaml.

vector<cv::KeyPoint> keypoints;
cv::Mat source = cv::imread("test.jpg");
Ptr<FeatureDetector> detector = new SurfFeatureDetector(400);
detector->detect(source , keypoints);

Now I have the keypoints. This is the first possible move to save the keypoints, If I do so, I can complete reconstruct any keypoint found. So no problem.

But what I want is to store the descriptor. So lets go a little bit further:

cv::Mat sourceMatch; Ptr<DescriptorExtractor> descriptorExtractor = new SurfDescriptorExtractor();
descriptorExtractor->compute(source , keypoints, sourceMatch);
Ptr<DescriptorMatcher> matcher = new BFMatcher(NORM_L2);

At this Point I'm not sure if I could save down the descriptor to the yaml-file. Any idea? I could try to save down the matcher. But this won't work:

vector<Mat> descriptors;
FileStorage* fileStorage = newFileStorage("index.yml",FileStorage::WRITE, "UTF-8");

This statement only saves me a yaml file with the header. And as I would guess even if I could write down the matcher I wouldn't write down the consisting descriptors. Has anyone an idea how to save the descriptors?


edit retag flag offensive close merge delete


did you try googling "opencv save descriptors to file"?

I see this 4 upvotes to the answer says it was useful for them.

bad_keypoints gravatar imagebad_keypoints ( 2014-11-25 07:30:13 -0500 )edit