我正在使用SURF / FLANN探测器,我正在寻找将图像,点,描述符保存到文件中,这样我就可以比较这个图像,然后将它指向第二个图像,然后指出我得到了以下内容我尝试写的错误:
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
这是我用来写的代码:
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne", keypoints_1, tempDescriptors_1);
fs.release();
我不确定在哪里可以指定额外的参数(tempDescriptors_1
),因为它可以在删除此arg时正常工作。
代码立即高于写代码:
//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 );
答案 0 :(得分:6)
你必须一次写一个:
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "keypoints_1", keypoints_1);
write(fs, "descriptors_1", tempDescriptors_1);
...
fs.release();
答案 1 :(得分:-1)
我们必须逐一编写关键点和描述符
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne_Keypoint", keypoints_1);
write(fs, "templateImageOne_descriptor", tempDescriptors_1);
fs.release();