前提
这里不讨论怎么获取矫正参数,假定已经获取矫正参数
使用undistort#include
using namespace cv;
void correct_photo(const char * jpg)
{
Mat src = imread(jpg);
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);
}
undistort函数对于单幅
2、使用remap 2.1 说明void cvRemap( const CvArr* src, CvArr* dst,const CvArr* mapx, const CvArr* mapy,int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,CvScalar fillval=cvScalarAll(0) );
参数说明: src——输入图像. dst——输出图像. mapx——x坐标的映射 (32fC1 image). mapy——y坐标的映射 (32fC1 image). flags——插值方法和以下开关选项的组合: CV_WARP_FILL_OUTLIERS——填充边界外的像素. 如果输出图像的部分象素落在变换后的边界外,那么它们的值设定为 fillval。 fillval——用来填充边界外面的值.
2.2 show me the code#include
#include
using namespace std;
using namespace cv;
int main()
{
const cv::Mat K = (cv::Mat_(3, 3)
关注
打赏