2016-06-14 272 views
0

我試圖運行的代碼片段在下面的OpenCV/C++示例http://docs.opencv.org/3.1.0/d7/dff/tutorial_feature_homography.html#gsc.tab=0C++中的OpenCV findHomography()函數

部分代碼下面給出未定義rererence:

std::vector<Point2f> obj; 
std::vector<Point2f> scene; 
for(size_t i = 0; i < good_matches.size(); i++) 
{ 
    //-- Get the keypoints from the good matches 
    obj.push_back(keypoints_object[ good_matches[i].queryIdx ].pt); 
    scene.push_back(keypoints_scene[ good_matches[i].trainIdx ].pt); 
} 
Mat H = findHomography(obj, scene, RANSAC); 

我得到以下編譯就行錯誤

/home/yudori/Documents/qt_projects/featureTest/main.cpp:57: error: undefined reference to `cv::findHomography(cv::_InputArray const&, cv::_InputArray const&, int, double, cv::_OutputArray const&, int, double)' 

Mat H = findHomography(obj, scene, RANSAC); 

我檢查了「calib3d.hpp」頭文件,它似乎包含findHomography函數的類似聲明,但我忍不住想我錯過了一些東西。我在Ubuntu上運行opencv 3.1.0,我對C++很陌生,請幫忙。

回答

2

如果你在Linux上工作添加到您的編譯字符串-lopencv_calib3d,如果你是在Windows和Visual Studio的工作,在其他庫添加opencv_calib3d

+0

感謝...我不知道怎麼說跳過過去我 :) – yudori