标签:读取 获取 center main thml nts data- water dos
https://blog.csdn.net/u013498583/article/details/71404323
摄像机的成像过程主要是主要涉及到几个坐标系的变换(具体过程可以参考相机模型):

从摄像机成像畸变的产生于是其“天生”的,不可避免的,这主要是由于透镜成像原理导致的。其畸变的原理可以参考相机模型)。
相机内参 像素的物理尺寸和焦距

相机的畸变矫正
(uOv坐标系) 下的无畸变坐标 (U, V),经过 径向畸变 和 切向畸变 后落在了uOv坐标系 的 (Ud, Vd) 上。imgR(U, V) = imgD(Ud, Vd)
最终公式

其中,[x′,y′]为畸变后的位置,[x,y]为畸变前的位置,[ki,pi]为畸变系数。当然,其实畸变系数远远不止这么四个,但通常情况下可以仅考虑这四个。
2-1 opencv自带的源码
2-2 使用matlab

最终获取标定文件
XML/YAML file
Camera_Matrix type_id="opencv-matrix"> <rows>3</rows> <cols>3</cols> <dt>d</dt> <data> 6.5746697944293521e+002 0. 3.1950000000000000e+002 0. 6.5746697944293521e+002 2.3950000000000000e+002 0. 0. 1.</data></Camera_Matrix> <Distortion_Coefficients type_id="opencv-matrix"> <rows>5</rows> <cols>1</cols> <dt>d</dt> <data> -4.1802327176423804e-001 5.0715244063187526e-001 0. 0. -5.7843597214487474e-001</data></Distortion_Coefficients>
畸变矫正 Distortion_Coefficients 5个失真参数

内参矩阵 Camera_Matrix 新的变换矩阵
联合 
#include <opencv2/opencv.hpp>
#include <opencv2/calib3d/calib3d.hpp>
using namespace std;
using namespace cv;
/**
* @主函数
*/
int main( int argc, char** argv )
{
/// 读取一副图片,不改变图片本身的颜色类型(该读取方式为DOS运行模式)
Mat src = imread( argv[1], 1 );
Mat distortion = src.clone();
Mat camera_matrix = Mat(3, 3, CV_32FC1);
Mat distortion_coefficients;
//导入相机内参和畸变系数矩阵
FileStorage file_storage("out_camera_data.xml", FileStorage::READ);
file_storage["Camera_Matrix"] >> camera_matrix;
file_storage["Distortion_Coefficients"] >> distortion_coefficients;
file_storage.release();
//矫正
undistort(src, distortion, camera_matrix, distortion_coefficients);
imshow("img", src);
imshow("undistort", distortion);
imwrite("undistort.jpg", distortion);
waitKey(0);
return 0;
}
标签:读取 获取 center main thml nts data- water dos
原文地址:https://www.cnblogs.com/kekeoutlook/p/13270069.html