我必须使用已知标记来估计相机的姿势。 相机已校准,我有所有校准系数。
当前版本的算法从帧中提取4个共面点,并使用它们使用solvePnP函数估计姿势。
算法似乎工作正常,但我有一个疑问。由于solvePnP也将校准系数作为输入,在查看4个点之前是否需要对图像进行无失真处理?
在下面的代码中,是否需要initUndistortRectifyMap / remap函数?
while(1) {
frame = camera->getFrame();
imshow("frame", frame);
// Estimation of Map1 and Map2 for image rectification (to be done only on the first iteration)
if (initRectifyMap_flag)
{
// Rectify the image
// The initialization of the Rectification Parameters will be carried out only at the first frame.
initUndistortRectifyMap(cameraMatrix, distCoeffs, Mat(), getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, frame.size(), 1, frame.size(), 0), frame.size(), CV_16SC2, map1, map2);
initRectifyMap_flag = false;
}
// Remapping of the current frame
remap(frame, src, map1, map2, INTER_LINEAR, BORDER_TRANSPARENT, Scalar::all(255));
// Here is the code for the extraction of the 4 points based on the content of the variable src
...
...
// Pose estimation
solvePnP(Mat(refMarkerPoint), Mat(markerPoints), cameraMatrix, distCoeffs, rvec, tvec,false);