Question

I'm using SURF/FLANN detector and I'm looking to save the image, points, descriptors to a file so I can then compare this image and it's points to a second image and points however I'm getting the following error when I try to write:

In file included from detectFlannPoints.cpp:4:0:
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note: void cv::write(cv::FileStorage&, const string&, const std::vector<cv::KeyPoint>&)
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note:   candidate expects 3 arguments, 4 provided

This is the code I'm using to write:

  FileStorage fs("Keypoints.yml", FileStorage::WRITE);
  write(fs, "templateImageOne", keypoints_1, tempDescriptors_1);
  fs.release();

I'm not sure where I can specify the extra argument (tempDescriptors_1) as it works fine with this arg removed.

Code immediatly above the write code:

  //Detect the keypoints using SURF Detector
  int minHessian = 400;
  SurfFeatureDetector detector( minHessian );
  std::vector<KeyPoint> keypoints_1;
  detector.detect( img_1, keypoints_1 );
  //-- Step 2: Calculate descriptors (feature vectors)
  SurfDescriptorExtractor extractor;
  Mat tempDescriptors_1;
  extractor.compute( img_1, keypoints_1, tempDescriptors_1 );
 //-- Draw keypoints
  Mat img_keypoints_1;
  drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );
Was it helpful?

Solution

you have to write them one at a time:

FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "keypoints_1", keypoints_1);
write(fs, "descriptors_1", tempDescriptors_1);
...
fs.release();

OTHER TIPS

We have to write the keypoints and descriptors one by one

FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne_Keypoint", keypoints_1);
write(fs, "templateImageOne_descriptor", tempDescriptors_1);
fs.release();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top