Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to enable findEssentialMat in opencv 2.4.9?

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?

Thanks in advance

How to enable findEssentialMat in opencv 2.4.9?

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,FM_RANSAC, 1, 0.99,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

How to enable findEssentialMat in opencv 2.4.9?

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,FM_RANSAC, 1, 0.99,output);
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