Ask Your Question
2

How to enable findEssentialMat in opencv 2.4.9?

asked 2013-03-18 23:29:57 -0600

RaulPL gravatar image

updated 2013-03-19 15:24:21 -0600

Hi, I'm being trying to use the new function findEssentialMat() in OpenCV 2.4.9 but when I try to compile my program it says that findEssentialMat is not defined. I include calib3d and I also link the proper library.

How should I compile OpenCV to enable the function?

This is my program:

#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

Mat getEssential(const vector<KeyPoint>& keypoints1,const vector<KeyPoint>& keypoints2,vector<DMatch>& matches){
vector<Point2f> p1, p2;
for (vector<DMatch>::const_iterator it= matches.begin();it!= matches.end(); ++it) {
    float x=keypoints1[it->queryIdx].pt.x;
    float y=keypoints1[it->queryIdx].pt.y;
    p1.push_back(Point2f(x,y));
    x=keypoints2[it->trainIdx].pt.x;
    y=keypoints2[it->trainIdx].pt.y;
    p2.push_back(Point2f(x,y));
}
Mat output;
Mat essen = findEssentialMat(p1,p2,focal,pp,CV_RANSAC,0.99,1,output);
vector<DMatch> inliers;
for(int i=0;i<output.rows;i++){
    int status=output.at<char>(i,0);
    if(status==1){
        inliers.push_back(matches[i]);
    }
}
matches=inliers;
return essen;
}

int main(){
Ptr<FeatureDetector> fast = new FastFeatureDetector(10,true);
Ptr<FeatureDetector> detector = new PyramidAdaptedFeatureDetector(fast,3);
FREAK freak(true,true,22.0f,0);
BFMatcher matcher(NORM_HAMMING,true);
vector<DMatch> matches;

vector<KeyPoint> kp0,kp1;
Mat d0, d1;

Mat im0 = imread("/home/Chini/im0.png",0);
Mat im1 = imread("/home/Chini/im1.png",0);
detector->detect(im0,kp0,Mat());
detector->detect(im1,kp0,Mat());
freak.compute(im0,kp0,d0);
freak.compute(im1,kp1,d1);
matcher.match(d0,d1,matches);
Mat e = getEssential(kp0,kp1,matches);
}

When I try to compile it I received the following message:

example.cpp: In function ‘cv::Mat getEssential(const std::vector<cv::KeyPoint>&, const    std::vector<cv::KeyPoint>&, std::vector<cv::DMatch>&)’:
example.cpp:18:62: error: ‘findEssentialMat’ is not defined

Thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2013-03-19 04:44:37 -0600

berak gravatar image

it looks like you copied the signature from findHomography().

findEssentialMat(p1,p2,FM_RANSAC, 1, 0.99,output);  // <-- all params from the 3rd on are wrong

so they just could not find the signature you called

CV_EXPORTS Mat findEssentialMat( InputArray points1, InputArray points2, double focal = 1.0, Point2d pp = Point2d(0, 0), 
                                 int method = CV_RANSAC, 
                                 double prob = 0.999, double threshold = 1.0, OutputArray mask = noArray() );
edit flag offensive delete link more

Comments

Thanks, I already correct it

RaulPL gravatar imageRaulPL ( 2013-03-19 15:26:07 -0600 )edit

You also have to use OpenCV >= 3.0.0

aledalgrande gravatar imagealedalgrande ( 2014-05-18 18:15:32 -0600 )edit

Question Tools

Stats

Asked: 2013-03-18 23:29:57 -0600

Seen: 4,738 times

Last updated: Mar 19 '13