Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 510
Jacob Waite Avatar asked Aug 10 '15 20:08

Jacob Waite


2 Answers

It turns out the header file for findHomography was missing:

#include "opencv2/calib3d/calib3d.hpp"
like image 99
beaker Avatar answered Oct 04 '22 01:10

beaker


Latest OpenCV version, CV_RANSAC is renamed to RANSAC.

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

This should work.

like image 45
Manish S Avatar answered Oct 04 '22 01:10

Manish S