findHomography 在 OpenCV 3.0 中不起作用
findHomography not working in OpenCV 3.0
我一直在使用 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::"。我不确定是什么问题。对这些错误的任何建议将不胜感激。谢谢!
原来 findHomography
的头文件丢失了:
#include "opencv2/calib3d/calib3d.hpp"
最新的OpenCV版本,CV_RANSAC重命名为RANSAC。
只需使用H = findHomography(ref, tst, RANSAC)
这应该有效。
Q1。 CV_RANSAC
未申报。
解决方案:CV_RANSAC
=> RANSAC
Q2。 findHomography
未声明。
解决方案:#include <opencv2/opencv.hpp>
对于大多数情况就足够了。
对于这个具体问题,您也可以使用 #include <opencv2/calib3d/calib3d.hpp>
我一直在使用 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::"。我不确定是什么问题。对这些错误的任何建议将不胜感激。谢谢!
原来 findHomography
的头文件丢失了:
#include "opencv2/calib3d/calib3d.hpp"
最新的OpenCV版本,CV_RANSAC重命名为RANSAC。
只需使用H = findHomography(ref, tst, RANSAC)
这应该有效。
Q1。 CV_RANSAC
未申报。
解决方案:CV_RANSAC
=> RANSAC
Q2。 findHomography
未声明。
解决方案:#include <opencv2/opencv.hpp>
对于大多数情况就足够了。
对于这个具体问题,您也可以使用 #include <opencv2/calib3d/calib3d.hpp>