import numpy as np ''' #T_cam_imu body_T_cam0: !!opencv-matrix rows: 4 cols: 4 dt: d data: [0.003489987080434578, -0.9999876012230461, 0.003552096614378108, 0.012750626916321976, -0.999991882276288, -0.0034971112689532436, -0.002001398086459798, -0.023424853764869122, 0.0020137953486698786, -0.003545082925974641, -0.9999916884731308, -0.017826923591925007, 0, 0, 0, 1] #T_cam_imu body_T_cam1: !!opencv-matrix rows: 4 cols: 4 dt: d data: [0.00446047102202006, -0.9999665817340186, -0.006851249042621769, -0.10819639255862219, -0.9999868688575744, -0.0044430650273882405, -0.002553680791861416, -0.024732250583609703, 0.002523154907262282, 0.0068625496970663846, -0.9999732691932166, -0.017439737925768566, 0, 0, 0, 1] ''' T1=[] T1.append([0.003489987080434578, -0.9999876012230461, 0.003552096614378108, 0.012750626916321976]) T1.append([-0.999991882276288, -0.0034971112689532436, -0.002001398086459798, -0.023424853764869122]) T1.append([0.0020137953486698786, -0.003545082925974641, -0.9999916884731308, -0.017826923591925007]) T1.append([0, 0, 0, 1]) T2=[] T2.append([0.00446047102202006, -0.9999665817340186, -0.006851249042621769, -0.10819639255862219]) T2.append([-0.9999868688575744, -0.0044430650273882405, -0.002553680791861416, -0.024732250583609703]) T2.append([0.002523154907262282, 0.0068625496970663846, -0.9999732691932166, -0.017439737925768566]) T2.append([0, 0, 0, 1]) # 矩阵对象可以通过 .I 更方便的求逆 T1_N = np.matrix(T1) T2_N = np.matrix(T2) print(T1_N.I) print(T2_N.I)
//=========================对原始图像畸变矫正========================== double fx= 355.0974745605948; double fy= 355.47832693317105; double cx= 357.7074039567714; double cy= 351.0244037313849; double k1= -0.023790306606729556; double k2= -0.0007571494794293715; double p1= 0.00016452517056601848; double p2= -0.0005743824914513448; cv::Mat cameraMatrix = (cv::Mat_<double>(3, 3) << fx, 0, cx, 0, fy, cy, 0, 0, 1); cv::Mat distCoeffs = (cv::Mat_<float>(4, 1) << k1, k2, p1, p2); cv::Mat dst_Left; // 普通图像畸变矫正 //undistort(imLeft, dst_Left, cameraMatrix, distCoeffs); cv::Size corrected_size(imLeft.cols,imLeft.rows); cv::Mat mapx, mapy; // 鱼眼图像畸变矫正 cv::fisheye::initUndistortRectifyMap(cameraMatrix, distCoeffs, cv::Matx33d::eye(), cameraMatrix, corrected_size, CV_16SC2, mapx, mapy); remap(imLeft, dst_Left, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_TRANSPARENT); // cv::imshow("leftImage", imLeft); // cv::imshow("dst_Left", dst_Left); // cv::waitKey(2); imLeft=dst_Left; //=========================对原始图像畸变矫正==========================