即使我的回答对您来说为时已晚,也许其他人会觉得这很有用。我有来自 Homography 的 openCV Pose 代码。我在这个非常有用的网站euclideanspace上找到了该方法。
void cameraPoseFromHomography(const Mat& H, Mat& pose)
{
pose = Mat::eye(3, 4, CV_64FC1); //3x4 matrix
float norm1 = (float)norm(H.col(0));
float norm2 = (float)norm(H.col(1));
float tnorm = (norm1 + norm2) / 2.0f;
Mat v1 = H.col(0);
Mat v2 = pose.col(0);
cv::normalize(v1, v2); // Normalize the rotation
v1 = H.col(1);
v2 = pose.col(1);
cv::normalize(v1, v2);
v1 = pose.col(0);
v2 = pose.col(1);
Mat v3 = v1.cross(v2); //Computes the cross-product of v1 and v2
Mat c2 = pose.col(2);
v3.copyTo(c2);
pose.col(3) = H.col(2) / tnorm; //vector t [R|t]
}
////