简体   繁体   中英

findHomography not working in OpenCV 3.0

I have been working on an image stitching project using OpenCV 3.0. I use the findHomography function like so:

findHomography(imageOnePoints, imageTwoPoints, CV_RANSAC);

but when I try to compile my code, I am returned the following error messages:

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

I have already declared that I am using "namespace cv" so I do not need the preceeding "cv::". I am not sure what the problem is. Any advice on these errors would be greatly appreciated. Thank you!

结果发现findHomography的头文件丢失了:

#include "opencv2/calib3d/calib3d.hpp"

Latest OpenCV version, CV_RANSAC is renamed to RANSAC.

just use H = findHomography(ref, tst, RANSAC)

This should work.

Q1. CV_RANSAC was not declared.

Solution: CV_RANSAC => RANSAC

Q2. findHomography was not declared.

Solution: #include <opencv2/opencv.hpp> would be enough for most cases.

For this specific question you can also use #include <opencv2/calib3d/calib3d.hpp>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM