c++ opencv findHomography()函数中的未定义关系

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

我检查了“calib3d.hpp”头文件,它似乎包含 findHomography 函数的类似声明,但我不禁觉得我遗漏了一些东西。我在 Ubuntu 上运行 opencv 3.1.0,我对 c++ 还很陌生,请帮忙。

最佳答案

如果您在 linux 上工作,请将其添加到您的编译字符串 -lopencv_calib3d,如果您在 windows 和 visual studio 上工作,请在附加库中添加 opencv_calib3d

关于c++ opencv findHomography()函数中的未定义关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37823179/

相关文章:

c++ - QToolButton 的位置在调整大小或移动父部件时不会改变

c++ - 为什么神经网络不预测?

c++ - 如何从 C++ Qt 代码在 QML QtLocation map 上添加 PoI

c++ - 如何使用 boost::random_device 生成密码安全的 64 位整数?

c++如何获取指向另一个类中当前对象的指针?

c++ - 使用 Qt 阅读 Central Role 上的 BLE 广告

c++ - C++将随机值放在乘法图表中(嵌套循环)

Qt Main-Gui 和其他线程+事件循环

python - 如何建立值(value)观之间的关系?

python - 切掉一个角的矩形的非精确形状检测