Ask Your Question
3

Saving Matcher/Descriptors

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

Mr.Mountain gravatar image

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

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;
descriptors.push_back(sourceMatch);
matcher->train();
FileStorage* fileStorage = newFileStorage("index.yml",FileStorage::WRITE, "UTF-8");
matcher->write(*fileStorage);

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?

thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-11-25 07:30:13 -0600

bad_keypoints gravatar image

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

I see this http://stackoverflow.com/questions/76... 4 upvotes to the answer says it was useful for them.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-05 15:44:09 -0600

Seen: 2,711 times

Last updated: Jan 05 '13