If you have Homography, you also have a twist. When you have homography, it's easy to get a rotation and translation matrix.
For example, if you use OpenCV C ++:
param[in] H
param[out] pose
void cameraPoseFromHomography(const Mat& H, Mat& pose)
{
pose = Mat::eye(3, 4, CV_32FC1);
float norm1 = (float)norm(H.col(0));
float norm2 = (float)norm(H.col(1));
float tnorm = (norm1 + norm2) / 2.0f;
Mat p1 = H.col(0);
Mat p2 = pose.col(0);
cv::normalize(p1, p2);
p1 = H.col(1);
p2 = pose.col(1);
cv::normalize(p1, p2);
p1 = pose.col(0);
p2 = pose.col(1);
Mat p3 = p1.cross(p2);
Mat c2 = pose.col(2);
p3.copyTo(c2);
pose.col(3) = H.col(2) / tnorm;
}
This function calculates the position of the camera from the homography that contains the rotation. For further theoretical information, follow this thread .
source
share