Saving Matcher/Descriptors
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