halcon相机标定参数转为opencv参数形式

由于条件限制拿到了halcon标定相机的参数,但由于自己畸变矫正采用opencv形式,但halcon官网给出5畸变系数到opencv不可转换。实际转换公式为:

void calibParaL (Mat &cameraMatrix, Mat &distCoeffs)
{
    double F = 6.2254672188473579e-03;
    double sx = 4.7992918037134185e-06;
    double sy = 4.7999999999999998e-06;
    double k1h = 5.7491650585212965e+03;      //k1k2k3p1p2
    double k2h = - 2.7796396962651394e+07;
    double k3h = - 1.4920594731728228e+12;
    double p1h = 5.6153778906380375e-02;
    double p2h = - 9.1599064524437290e-03;   //p2

    cameraMatrix = Mat::eye(3, 3, CV_64F);
    cameraMatrix.at(0, 0) = F / sx;
    cameraMatrix.at(0, 1) = 0.0;
    cameraMatrix.at(0, 2) = 6.402223194383531e+02;
    cameraMatrix.at(1, 1) = F  / sy;
    cameraMatrix.at(1, 2) = 5.076691017558288e+02;

    distCoeffs = Mat::zeros(5, 1, CV_64F);
    distCoeffs.at(0, 0) = -k1h*F*F ;
    distCoeffs.at(1, 0) = k2h*F*F*F*F;
    distCoeffs.at(2, 0) = p2h*F;
    distCoeffs.at(3, 0) = p1h*F;
    distCoeffs.at(4, 0) = k3h*F*F*F*F*F*F;
}

本公式参考

https://stackoverflow.com/questions/58606394/halcon-to-opencv-distortion-coefficients-convertion

你可能感兴趣的:(opencv,opencv)