テンプレート画像の 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]);
れ、元の投稿に示されているように渡されます。