2018-12-12 07:21:20 -0500 received badge ● Nice Answer (source) 2017-07-12 15:44:14 -0500 received badge ● Popular Question (source) 2016-11-01 09:43:58 -0500 received badge ● Teacher (source) 2013-07-09 02:27:57 -0500 answered a question How to use Mat.at(i,j)? You can use Mat_. You have to specify the Mat_ type when you declare it, and then you can acces to the pixels easily. Check this documentation: http://docs.opencv.org/modules/core/doc/basic_structures.html#id7 2013-01-25 07:51:01 -0500 asked a question solvePnP returns wrong result Hi everyone, I'm using the function solvePnP to estimate the pose of my robot by visual markers. Some times I get wrong results in two consecutives frames. In the file problem.cpp you can see one of these results. The points sets correspond to the same marker in two consecutives frames. The variation between them is very small, and the result of the solvePnP is very different, but only in the rotation vector. Translation vector is ok. This happens approximely one time each 30 frames. I have tested CV_ITERATIVE and CV_P3P method with the same data, and they return the same result. This is a example of the issue: #include #include #include using namespace std; using namespace cv; int main(){ vector points1, points2; //First point's set points1.push_back(Point2f(384.3331f, 162.23618f)); points1.push_back(Point2f(385.27521f, 135.21503f)); points1.push_back(Point2f(409.36746f, 139.30315f)); points1.push_back(Point2f(407.43854f, 165.64435f)); //Second point's set points2.push_back(Point2f(427.64938f, 158.77661f)); points2.push_back(Point2f(428.79471f, 131.60953f)); points2.push_back(Point2f(454.04532f, 134.97353f)); points2.push_back(Point2f(452.23096f, 162.13156f)); //Real object point's set vector object; object.push_back(Point3f(-88.0f,88.0f,0)); object.push_back(Point3f(-88.0f,-88.0f,0)); object.push_back(Point3f(88.0f,-88.0f,0)); object.push_back(Point3f(88.0f,88.0f,0)); //Camera matrix Mat cam_matrix = Mat(3,3,CV_32FC1,Scalar::all(0)); cam_matrix.at(0,0) = 519.0f; cam_matrix.at(0,2) = 320.0f; cam_matrix.at(1,1) = 522.0f; cam_matrix.at(1,2) = 240.0f; cam_matrix.at(2,2) = 1.0f; //PnP Mat rvec1i,rvec2i,tvec1i,tvec2i; Mat rvec1p,rvec2p,tvec1p,tvec2p; solvePnP(Mat(object),Mat(points1),cam_matrix,Mat(),rvec1i,tvec1i,false,CV_ITERATIVE); solvePnP(Mat(object),Mat(points2),cam_matrix,Mat(),rvec2i,tvec2i,false,CV_ITERATIVE); solvePnP(Mat(object),Mat(points1),cam_matrix,Mat(),rvec1p,tvec1p,false,CV_P3P); solvePnP(Mat(object),Mat(points2),cam_matrix,Mat(),rvec2p,tvec2p,false,CV_P3P); //Print result cout<<"Iterative: "<