Ask Your Question

Artur's profile - activity

2013-10-16 15:09:33 -0600 asked a question solvepnpransac gives bad results

hi. i have a problem with solvepnpransac. it just gives bad results. i have no idea whats wrong... here is a little program which shows the problem. there are 5 perfect point-correspondences. These should perfectly fit to a camera at point (1,0,0), showing into the x-direction, with a focallength of 1. solvePnP on the other hand gives very good results.

#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"

#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv ){
    Mat imagePoint(0,2,CV_32F);
    Mat iPoint = (Mat_<float>(1,2) << 0,0);
    iPoint = (Mat_<float>(1,2) << 0,1);
    iPoint = (Mat_<float>(1,2) << 1,0);
    iPoint = (Mat_<float>(1,2) << 0,2);
    iPoint = (Mat_<float>(1,2) << 2,0);

    Mat worldPoint(0,3,CV_32F);
    Mat wPoint = (Mat_<float>(1,3) << 10,0,0);
    wPoint = (Mat_<float>(1,3) << 4,3,0);
    wPoint = (Mat_<float>(1,3) << 4,0,3);
    wPoint = (Mat_<float>(1,3) << 3,4,0);
    wPoint = (Mat_<float>(1,3) << 3,0,4);
    Mat cameraMatrix = (Mat_<float>(3,3) << 1,0,0,0,1,0,0,0,1);
    Mat distCoeffs = (Mat_<float>(4,1) << 0,0,0,0);
    Mat rvec(3,1,CV_32F);
    Mat tvec(3,1,CV_32F);
    solvePnPRansac(worldPoint, imagePoint, cameraMatrix, distCoeffs, rvec, tvec);
    //solvePnP(worldPoint, imagePoint, cameraMatrix, distCoeffs, rvec, tvec);
    Mat rotate(3,3,CV_32F);
    Rodrigues(rvec, rotate);
    Mat estimatePosition = -((Mat)rotate.t()) * tvec;
    cout << estimatePosition << endl;
2013-10-16 05:46:30 -0600 asked a question does solvepnpransac require tbb?

hi i try to estimate the pose of a camera by 3d-2d correspondences. at the moment i want to program a testcase with quit reliable data. solvepnp gives very good results, but solvepnpransac not... my program compiles and runs without problems. the documentation says, that solvepnprasac uses tbb to speed up the calculation. so my question is, if solvepnprasac requires tbb to return good results?