OpenCV3.1.0鱼眼相机标定及畸变校正
来源:互联网 发布:24小时淘宝店铺套花呗 编辑:程序博客网 时间:2024/05/17 00:59
常用的相机模型为针孔模型,此模型在视场较小的情况下是适用的,随着视场的增加,模型误差越来越大。
普通镜头和鱼眼镜头成像原理的差异是造成此现象的根本原因。具体原理可以参见:
[1] http://docs.opencv.org/master/db/d58/group__calib3d__fisheye.html#gsc.tab=0
[2] Juho Kannalaand Sami S. Brandt. A generic camera model and calibration method for conventional,wide-angle and fish-eye lenses. IEEE Transactions on Pattern Analysis andMachine Intelligence, vol. 28, no. 8, August 2006.
[3] Juho Kannala,Janne Heikkila and Sami S. Brandt. Geometric camera calibration. WileyEncyclopedia of Computer Science and Engineering, 2008.
我的源程序:
vector<Point2f> img_ptsTemp;
vector<vector<Point2f>> img_ptsVector;
vector<Point3f> obj_ptsTemp;
vector<vector<Point3f>> obj_ptsVector;
// 鱼眼镜头参数
Mat intrinsic_mat; //Matx33d intrinsic_mat亦可; Mat intrinsic_mat(3, 3, CV_64FC1, Scalar(0))亦可,注意数据类型;
Mat distortion_coeffs; //Vec4d distortion_coeffs亦可
int flag = 0;
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
flag |= cv::fisheye::CALIB_CHECK_COND;
flag |= cv::fisheye::CALIB_FIX_SKEW; /*非常重要*/
cv::fisheye::calibrate(
obj_ptsVector,
img_ptsVector,
board_img_size,
intrinsic_mat,
distortion_coeffs,
cv::noArray(),
cv::noArray(),
flag,
cv::TermCriteria(3, 20, 1e-6)
);
//畸变校正
void FishEyeImgUndistort()
{
Mat DistortImg = cv::imread("fore_1.jpg");
Mat UndistortImg;
Mat new_intrinsic_mat; //Mat new_intrinsic_mat(3, 3, CV_64FC1, Scalar(0))亦可,注意数据类型;
//fx,fy变大(小),视场变小(大),裁剪较多(少),但细节清晰(模糊);很关键,new_intrinsic_mat决定输出的畸变校正图像的范围
intrinsic_mat.copyTo(new_intrinsic_mat);
//调整输出校正图的视场
new_intrinsic_mat.at<double>(0, 0) *= 0.5; //注意数据类型,非常重要
new_intrinsic_mat.at<double>(1, 1) *= 0.4;
//调整输出校正图的中心
new_intrinsic_mat.at<double>(0, 2) += 0.0;
new_intrinsic_mat.at<double>(1, 2) += 0.0;
cv::fisheye::undistortImage(
DistortImg,
UndistortImg,
intrinsic_mat,
distortion_coeffs,
new_intrinsic_mat //
); //最后一个camera_matrix必须写上 Ref:http://answers.opencv.org/question/64614/fisheyeundistortimage-doesnt-work-what-wrong-with-my-code/
cv::imshow("DistortImg", DistortImg);
cv::imshow("UndistortImg", UndistortImg);
cv::imwrite("feModelUndistortFore.jpg", UndistortImg);
cv::waitKey(0);
}
- OpenCV3.1.0鱼眼相机标定及畸变校正
- 【opencv3.0】鱼眼图像畸变校正——标定校正
- 【opencv3.0】鱼眼图像畸变校正——标定校正
- 【opencv】普通相机标定畸变校正
- 手机广角相机标定和畸变校正
- opencv3 鱼眼相机标定
- 鱼眼镜头畸变校正-OpenCV3.1.0和Matalb2012a
- 相机畸变校正
- 【OpenCV】摄像机标定+畸变校正
- OpenCV 标定和畸变校正
- 【OpenCV】摄像机标定+畸变校正
- 相机的标定+畸变矫正
- 鱼眼相机与针孔相机的标定与校正基于MATLAB和Opencv
- 摄像机标定和图像径向畸变校正
- 摄像机标定和图像径向畸变校正
- OpenCV 标定和畸变校正(2)
- 【opencv】鱼眼图像畸变校正
- 鱼眼图像畸变校正_V
- PHP+Mysql+jQuery实现文件下载次数统计
- .NET软件工程师48个面试题目
- 微软2016年4月实习生笔试第三题-Demo Day题解
- iOS各种最全的画图实现 (折线图.走势图.柱状图.动态曲线图.形状图.划线图)
- 线程与进程
- OpenCV3.1.0鱼眼相机标定及畸变校正
- 一篇不错的讲解Java异常的文章
- 注释转换(C---->C++)
- 基于linux 3.10.49内核 从dts文件里注册platform_device流程分析
- Android中四中声音设置
- 屏蔽Xcode编译警告
- 以form表单上传文件,接口不响应,后台显示"file" does not contain '/'
- Android SwipeRefreshLayout 官方下拉刷新控件介绍
- Mysql初始化root密码和允许远程访问