c++
1#include <opencv2/highgui/highgui.hpp> 2#include <opencv2/imgproc/imgproc.hpp> 3#include <opencv2/features2d/features2d.hpp> 4#include <opencv2/calib3d/calib3d.hpp> 5 6using namespace cv; 7using namespace std; 8 9int main(int argc,char *argv[]) 10{ 11 //画像読み込み 12 Mat src_image1 = imread("left.jpg"); 13 Mat src_image2 = imread("right.jpg"); 14 //キーポイントの検出 15 vector<KeyPoint> keypoints1,keypoints2;// 特徴点情報を格納するための変数 16 FeatureDetector detector1,detector2 ; 17 //Ptr<FeatureDetector> detector = cv::FeatureDetector::create( "SURF" ); //検出器を指定(SIFT, SURF, ORBなど) 18 detector1.detect(src_image1,keypoints1);// 特徴点の取得 19 detector2.detect(src_image2,keypoints2);// 特徴点の取得 20 //記述子を抽出する 21 DescriptorExtractor extractor; 22 Mat descriptors1,descriptors2; 23 extractor.compute(src_image1,keypoints1,descriptors1); 24 extractor.compute(src_image2,keypoints2,descriptors2); 25 //マッチングを取る 26 vector<DMatch> matches; 27 BFMatcher matche(NORM_HAMMING); 28 matche.match(descriptors1,descriptors2,matches); 29 //良好なマッチングのみを選ぶ 30 vector<DMatch> good_matches; 31 vector<KeyPoint> good_keypoints1,good_keypoints2; 32 for(unsigned int i = 0; i < matches.size();i++) 33 { 34 if(matches[i].distance < 30) 35 { 36 good_matches.push_back(matches[i]); 37 good_keypoints1.push_back(keypoints1[matches[i].queryIdx]); 38 good_keypoints2.push_back(keypoints2[matches[i].queryIdx]); 39 } 40 } 41 Mat match_image; 42 drawMatches(src_image1,keypoints1,src_image2,keypoints2,good_matches,match_image); 43 imshow("マッチング結果",match_image); 44 45 waitKey(); 46 return 0; 47 48} 49
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.3) /tmp/opencv-20181001-41572-id0soo/opencv-3.4.3/modules/features2d/src/feature2d.cpp:154: error: (-213:The function/feature is not implemented) in function 'detectAndCompute'
Abort trap: 6
とゆうエラーが出ます。
同じファイル内にright, left.jpgのファイルはあります。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/05 07:39