opencv findHomography()函数中的c ++ undefined rererence

时间:2016-06-14 22:29:19

标签: c++ qt opencv image-processing computer-vision

我尝试在以下opencv / c ++示例中运行代码段http://docs.opencv.org/3.1.0/d7/dff/tutorial_feature_homography.html#gsc.tab=0

部分代码如下:

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

我检查了&#34; calib3d.hpp&#34;头文件,它似乎包含findHomography函数的类似声明,但我不能帮助,但我想我错过了什么。我在Ubuntu上运行opencv 3.1.0,而且我对c ++很新,请帮助。

1 个答案:

答案 0 :(得分:2)

如果您正在使用linux,请将此添加到您的编译字符串-lopencv_calib3d中,如果您正在使用Windows和Visual Studio,请在附加库中添加opencv_calib3d