简体   繁体   English

OpenCV将图像,关键点和描述符保存到文件中

[英]OpenCV saving image, keypoints and descriptors to file

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: 我正在使用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

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. 我不确定在哪里可以指定额外的参数( tempDescriptors_1 ),因为它可以正常删除这个arg。

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 );

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();

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除OpenCV中的匹配项(关键点和描述符) - Delete matches in OpenCV (Keypoints and descriptors) 如何在C ++中的OpenCV 3.0.0,Visual Studio 2013中检测关键点,计算描述符并匹配这些描述符? - How to detect keypoints, compute descriptors and match those descriptors in OpenCV 3.0.0, Visual Studio 2013, in C++? OpenCV:如何在文件中存储描述符? - OpenCV: How to store descriptors in a file? OpenCV C ++创建可重用的关键点和描述符集,以缝合多个图像 - OpenCV C++ create reusable set of keypoints and descriptors for stitching multiple images 从SURF描述符转换为关键点 - converting from SURF descriptors to keypoints OpenCV代码,用于将列表中存储的描述符与新的图像描述符进行比较 - OpenCV Code to compare descriptors stored in a list with new image descriptors 处理opencv后将图像保存到文件 - saving an image to file after processing opencv OpenCV FAST 算法仅在图像的一部分上创建倾斜的关键点 - OpenCV FAST Algorithm creating skewed keypoints on only part of an image 如何在opencv中找到单个图像关键点之间的欧氏距离 - How to find euclidean distance between keypoints of a single image in opencv 将关键点转换为mat或将它们保存到文本文件opencv - convert keypoints to mat or save them to text file opencv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM