我有一个图像失真和它的主要点,而不是在中心。我想使用opencv函数cv::undistort来消除失真。此外,我希望将图像的主点移到中心大小x/2,大小_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来转移主点。现在的问题是,中心是否应该在那里。
反扭曲使用函数:当我插入我的值时,cv::initUndistortRectifyMap()及其在文档中的数学描述不会产生结果。
现在的问题是:我可以使用GetDefaultNewCameraMatrix来转移主要点吗?还有别的办法吗?我应该使用哪种功能?
另外,我怎样才能确定我的主要观点是否转移到中心呢?
谢谢你的帮助!
发布于 2018-08-26 09:23:43
我怎样才能确定我的主要观点是否转移到了中心?
您可以使用已知的模式在一个已知的位置创建自己的图像(例如,在主点上有一个中心交点的网格)。然后通过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函数应该正确地处理原点,并相应地对图像进行转换。这就是这个函数的作用所在。
https://stackoverflow.com/questions/51826151
复制相似问题