Opencv 使用解算PNP估计姿势前不失真图像

Opencv 使用解算PNP估计姿势前不失真图像,opencv,remap,pose-estimation,Opencv,Remap,Pose Estimation,我必须使用已知的标记来估计相机的姿势。 摄像机已经校准,我有所有的校准系数 当前版本的算法从帧中提取4个共面点,并使用solvePnP函数使用它们来估计姿势 算法似乎很好,但我有一个疑问。由于solvePnP也将校准系数作为输入,我是否需要在查看4个点之前取消图像失真 在下面的代码中,是否需要initUnderSortyMap/remap函数 while(1) { frame = camera->getFrame(); imshow("frame", frame);

我必须使用已知的标记来估计相机的姿势。 摄像机已经校准,我有所有的校准系数

当前版本的算法从帧中提取4个共面点,并使用solvePnP函数使用它们来估计姿势

算法似乎很好,但我有一个疑问。由于solvePnP也将校准系数作为输入,我是否需要在查看4个点之前取消图像失真

在下面的代码中,是否需要initUnderSortyMap/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);

如果你给solvePnP未失真的像素信息,我会用0表示距离系数。但这并不能保证;)更新:根据米卡提供的注释,我注释掉了remap函数,并将校准系数用作solvePnP函数的附加输入。有人能确认我这个过程是否正确吗?@Alek是的,这是正确的方法。如果你给solvePnP提供未失真的像素信息,我会用零表示距离系数。但这并不能保证;)更新:根据米卡提供的注释,我注释掉了remap函数,并将校准系数用作solvePnP函数的附加输入。有人能确认我这个程序是否正确吗?@Alek是的,这是正确的方法。