1

テンプレート画像の SURF キーポイントをビデオ フィードに表示されているものと一致させようとしていますが、 を呼び出そうとすると次のエラーが発生しますFlannBasedMatcher

captureFromCam.cpp: In function ‘void matchAndDrawKeypoints(cv::Mat, IplImage*)’:
captureFromCam.cpp:110:55: error: no matching function for call to ‘cv::FlannBasedMatcher::match(cv::FileNode&, cv::Mat&, std::vector<cv::DMatch>&)’
captureFromCam.cpp:110:55: note: candidates are:
In file included from /usr/local/include/opencv/cv.h:68:0,
                 from captureFromCam.cpp:2:
/usr/local/include/opencv2/features2d/features2d.hpp:1110:18: note: void cv::DescriptorMatcher::match(const cv::Mat&, const cv::Mat&, std::vector<cv::DMatch>&, const cv::Mat&) const
/usr/local/include/opencv2/features2d/features2d.hpp:1110:18: note:   no known conversion for argument 1 from ‘cv::FileNode’ to ‘const cv::Mat&’
/usr/local/include/opencv2/features2d/features2d.hpp:1128:18: note: void cv::DescriptorMatcher::match(const cv::Mat&, std::vector<cv::DMatch>&, const std::vector<cv::Mat>&)
/usr/local/include/opencv2/features2d/features2d.hpp:1128:18: note:   no known conversion for argument 1 from ‘cv::FileNode’ to ‘const cv::Mat&’

yml画像を読み込み、キーポイントと記述子を計算し、次のような形式で保存することで、これを実行しようとしています。

// code to detect features/descriptors
...
  cv::FileStorage fs(fileNamePostCut + ".yml", cv::FileStorage::WRITE);
  write(fs, fileNamePostCut + "Keypoints_1", keypoints_1);
  write(fs, fileNamePostCut + "Descriptors_1", img_descriptors_1);
  fs.release();

別の関数で、キーポイントと記述子を読み込んで、ビデオ ストリーム用に計算された値と比較しようとしています。

matchAndDrawKeypoints (cv::Mat img_1, IplImage* frames)
      std::vector<cv::KeyPoint> templateKeypoints;
      std::vector<cv::KeyPoint> templateDescriptor;
      cv::FileStorage fs2("VWlogo.yml", cv::FileStorage::READ);
      cv::FileNode kptFileNode = fs2["VWlogoKeypoints_1"];
      read(kptFileNode, templateKeypoints);
      cv::FileNode desFileNode = fs2["VWlogoDescriptors_1"];
      read(desFileNode, templateDescriptor);
      fs2.release();
      cv::FlannBasedMatcher matcher;
      std::vector<cv::DMatch> matches;
      matcher.match(desFileNode, img_descriptors_1, matches);

yml問題は、記述子がファイルから正しく読み込まれていないか、ビデオ フィードの記述子が正しく渡されていないことだと思います。

以下は、情報の流れに関する追加情報です。

main()コールコール コールmakeitgrey(frame)コールdetectKeypoints(grey_frame)リターンmakeitgrey()コールmain()コールmatchAndDrawKeypoints (img_1, frames)

編集: キーポイントが計算されるコードと宣言。

cv::Mat img_keypoints_1;
cv::Mat img_1;
cv::Mat img_descriptors_1;
std::vector<cv::KeyPoint> keypoints_1;
std::vector<cv::KeyPoint> descriptors_1;

main()ビデオをmakeitgrey()渡す先:

IplImage* detectKeypointsImage (IplImage* img_1) {
  int minHessian = 400;
  cv::SurfFeatureDetector detector(minHessian);
  detector.detect(img_1, keypoints_1);
  drawKeypoints(img_1, keypoints_1, img_keypoints_1);
  cv::SurfDescriptorExtractor extractor;
  extractor.compute(img_1, keypoints_1, img_descriptors_1);
  return img_1;
}

テンプレート画像はコマンドライン引数として渡さdetectTemplateKeypoints(img_1, argv[1]);れ、元の投稿に示されているように渡されます。

4

1 に答える 1

2

コードには 2 つの問題があります。

  1. std::vector<cv::KeyPoint> templateDescriptor;記述子の正しいタイプではありません。記述子の計算用。http://docs.opencv.org/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.htmlのサンプル コードでは、一連のキーポイントの記述子は通常 type であることがわかりますcv::Mat。したがって、それを次のように変更しcv::Mat templateDescriptor;ますcv::Mat descriptors_1;

  2. matcher.match(desFileNode, img_descriptors_1, matches);matcher.match(templateDescriptor, img_descriptors_1, matches);ファイルストレージノードではなく記述子を一致させる必要があるためです。

于 2015-01-14T13:02:54.637 に答える