findHomography在OpenCV 3.0中不起作用

时间:2015-08-10 20:56:31

标签: c++ opencv image-stitching

我一直在使用OpenCV 3.0进行图像拼接项目。我像这样使用findHomography函数:

findHomography(imageOnePoints, imageTwoPoints, CV_RANSAC);

但是当我尝试编译我的代码时,我返回了以下错误消息:

stitch.cpp:111:75: error: ‘CV_RANSAC’ was not declared in this scope
 Mat homographyMatrix = findHomography(imageOnePoints, imageTwoPoints, CV_RANSAC);

stitch.cpp:111:84: error: ‘findHomography’ was not declared in this scope
 Mat homographyMatrix = findHomography(imageOnePoints, imageTwoPoints, CV_RANSAC);

我已经声明我正在使用“namespace cv”,所以我不需要前面的“cv ::”。我不确定问题是什么。对这些错误的任何建议将不胜感激。谢谢!

3 个答案:

答案 0 :(得分:4)

事实证明findHomography的头文件丢失了:

#include "opencv2/calib3d/calib3d.hpp"

答案 1 :(得分:0)

最新的OpenCV版本,CV_RANSAC重命名为RANSAC。

只需使用H = findHomography(ref, tst, RANSAC)

这应该有效。

答案 2 :(得分:0)

Q1。 CV_RANSAC未声明。

解决方案:CV_RANSAC => RANSAC

第二季度。 findHomography未声明。

解决方案:#include <opencv2/opencv.hpp>在大多数情况下就足够了。

对于此特定问题,您还可以使用#include <opencv2/calib3d/calib3d.hpp>