c++中镜头的畸变校正
cameraMatrix为内参矩阵;
distCoeffs为畸变参数
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/calib3d.hpp"
#include <opencv2/highgui.hpp>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
using namespace cv;
int main()
{
Mat test_image2 = imread("3.png");
imshow("as", test_image2);
waitKey(20000);
Mat cameraMatrix = (Mat_<float>(3, 3) << 517, 0, 318, 0, 516, 255, 0, 0, 1);
Mat distCoeffs = (Mat_<float>(5, 1) << -0.95, 1.16, -0.005, 0.002, 0.26);
// 导入要矫正的图片
cout << cameraMatrix << endl << distCoeffs << endl;
Mat show_image;
undistort(test_image2, show_image, cameraMatrix, distCoeffs);
//cout << show_image << endl;
//cvSaveImage("5.jpg",&show_image);
imshow("asdasd", show_image);
waitKey(20000);
return 0;
}