使用 cv::不扭曲不失真和居中图像
Undistort and center image using cv::undistort
我有一个失真的图像,它的主点不在中心。我想使用 opencv 函数cv::undistort
来摆脱失真。此外,我想将图像的主体移动到图像中心[size_x/2,size_y/2]的中心。
我目前所做的是:
//Creating the camera matrix with the parameters of the calibration algorithm (they are correct)
cv::Mat cv_camera_matrix = cv::Mat::zeros(3, 3, CV_64F);
cv_camera_matrix.at<double>(0,0) = projection_parameters[0]; //* incoming_image_ptr_mono8->image.cols;
cv_camera_matrix.at<double>(1,1) = projection_parameters[1]; //* incoming_image_ptr_mono8->image.rows;
cv_camera_matrix.at<double>(0,2) = projection_parameters[2]; //* incoming_image_ptr_mono8->image.cols;
cv_camera_matrix.at<double>(1,2) = projection_parameters[3]; //* incoming_image_ptr_mono8->image.rows;
cv_camera_matrix.at<double>(2,2) = 1;
//filling up of an array with the generated distortion parameters of the calibration algorithm (they are correct)
cv::Mat distortion_coefficients = cv::Mat::zeros(1, 4, CV_64F);
distortion_coefficients.at<double>(0,0) = undistortion_parameters[0];
distortion_coefficients.at<double>(0,1) = undistortion_parameters[1];
distortion_coefficients.at<double>(0,2) = undistortion_parameters[2];
distortion_coefficients.at<double>(0,3) = undistortion_parameters[3];
cv::undistort(input_image, output_image,cv_camera_matrix, cv::getDefaultNewCameraMatrix(cv_camera_matrix,input_image.size(),true),distortion_coefficients);
不失真已经消除了失真,但我不确定图像的主体点是否移动到中心。我选择函数cv::getDefaultNewCameraMatrix
以转移主要点。现在的问题是,中心是否在它应该在的地方。
Undistort 使用函数:cv::initUndistortRectifyMap()
当我插入我的值时,它在文档中的数学描述不会产生结果。
现在的问题是:我可以使用GetDefaultNewCameraMatrix
来转移主要点吗?还有别的办法吗?我应该使用哪个功能?
另外,我如何检查我的主点是否移动到中心?
感谢您的帮助!
我如何检查我的主要点是否移动到中心?
您可以在已知位置(例如,在主点上具有中心交点的网格(使用已知图案创建自己的图像。然后,通过undistort
函数发送此模拟图像,以查看已知模式是否移动到正确的位置。
如果你想更进一步,你可以用你期望的失真投影你自己的模拟图像projectPoints
,然后undistort
它。然后,您可以控制整个过程,并且可以准确看到失真系数和原则点如何影响图像。
我可以使用 GetDefaultNewCameraMatrix 来移动主要点吗?还有别的办法吗?我应该使用哪个功能?
我认为GetDefaultNewCameraMatrix
在这里使用的功能是错误的。它将覆盖图像中心的原则点(例如,对于大小为 [400,400] 的图像,则为 [200,200](。
如果矩阵projection_parameters
已经包含原则点(例如,来自calibrateCamera
函数(,则按原样将其发送到undistort
。
喜欢这个:
cv::undistort(input_image, output_image,cv_camera_matrix, cv_camera_matrix, distortion_coefficients);
undistort
函数应正确处理原则点并相应地翻译图像。这就是构建函数的目的。
- 将"打开的CV图像"中的"颜色"转换为整数格式
- C++:从GPU内存(cudaMemcpy2D)获取BGR图像(cv::Mat)
- 使用 cv::不扭曲不失真和居中图像
- 如何在OpenCV 3.4.7中计算CV_32FC1 cv::GpuMat图像的(范围)直方图
- 如何在 dlib 的 array2d 图像上从 dlib::rectangle 创建 cv::Mat<rgb_pixel> ?
- 如何从C 中的CV :: MAT图像中有效提取某些像素
- C++/openCV - 为什么显示图像会产生 Linux 分割错误?(打开CV错误?
- 循环浏览捕获的图像 vector<cv::Mat>
- 将打开的CV的重映射功能与类型CV_8SC1的源图像一起使用
- 表示RGB图像的浮点数组的初始CV::MAT
- 将 cv::Mat 转换为穿山甲::图像
- 无法使用cv :: imwrite保存垫子图像在JNI本机代码OPENCV中
- 使用Open CV和Java单击Android时,获取图像尺寸
- 为什么CV :: MAT的向量总是返回第一个图像
- 图像打开时出错(使用打开的 CV C++代码)
- 使用16位签名格式打开CV不起作用..裁剪图像并重新调整图像大小
- 使用 cv::P oint 作为参数访问图像
- 将拜耳RGGB转换为CV图像(RGB)
- 如何在打开的cv c ++中单击鼠标右键时从视频中捕获图像
- 将opencv图像cv::Mat格式转换为c# BitmapImage