Hi,
I am trying to do pose estimation. But I am clearly doing something wrong. Let's say I have an pattern consisting of 4 Markers (A,B,C,D). Each of these markers has an image coordinate and a pattern coordinate. The origin of the pattern is the center of the polygon.
The image coordinates (x/y) are the following. (In a 1280x960 image)
- Origin(616/814)
A(561/664)
B(702/838)
C(637/982)
D(520/755)
Pattern coordinates (x/y/z)
Origin(0/0/0)
A(-12/32/0)
B(18/-5/0)
C(12/-36/0)
D(21/13/0)
Now it rotates by 90 degrees, but my coordinate system does not rotate with the pattern. I am wondering what is wrong? Is it because the Z coordinate is always 0?
- (x/y)
- Origin(632/784)
A(718/812)
B(567/938)
C(441/909)
D(632/784)
Pattern coordinates (x/y/z)
Origin(0/0/0)
A(32/12/0)
B(-4/18/0)
C(-35/11/0)
D(11/19/0)
I am using solvePnP like this
cv::solvePnP(patternPoints, imgPoints, cameraMatrix, distCoeffs, rvec, tvec);
Drawing the axis
//Method Call
pattern.drawAxis(image, camMatrix, distCoeffs, rvec, tvec,10);
//Implementation (taken from aruco.cpp)
void drawAxis(InputOutputArray _image, InputArray _cameraMatrix, InputArray _distCoeffs,
InputArray _rvec, InputArray _tvec, float length) {
CV_Assert(_image.getMat().total() != 0 &&
(_image.getMat().channels() == 1 || _image.getMat().channels() == 3));
CV_Assert(length > 0);
// project axis points
vector< Point3f > axisPoints;
axisPoints.push_back(Point3f(0, 0, 0));
axisPoints.push_back(Point3f(length, 0, 0));
axisPoints.push_back(Point3f(0, length, 0));
axisPoints.push_back(Point3f(0, 0, length));
vector< Point2f > imagePoints;
projectPoints(axisPoints, _rvec, _tvec, _cameraMatrix, _distCoeffs, imagePoints);
// draw axis lines
line(_image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), 3);
line(_image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), 3);
line(_image, imagePoints[0], imagePoints[3], Scalar(255, 0, 0), 3);
}