added undistort point
This commit is contained in:
		@@ -36,6 +36,16 @@ cv::Point2f distortPoint(
 | 
				
			|||||||
    const cv::Vec4d& intrinsics,
 | 
					    const cv::Vec4d& intrinsics,
 | 
				
			||||||
    const std::string& distortion_model,
 | 
					    const std::string& distortion_model,
 | 
				
			||||||
    const cv::Vec4d& distortion_coeffs);
 | 
					    const cv::Vec4d& distortion_coeffs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void undistortPoint(
 | 
				
			||||||
 | 
					    const cv::Point2f& pt_in,
 | 
				
			||||||
 | 
					    const cv::Vec4d& intrinsics,
 | 
				
			||||||
 | 
					    const std::string& distortion_model,
 | 
				
			||||||
 | 
					    const cv::Vec4d& distortion_coeffs,
 | 
				
			||||||
 | 
					    cv::Point2f& pt_out,
 | 
				
			||||||
 | 
					    const cv::Matx33d &rectification_matrix = cv::Matx33d::eye(),
 | 
				
			||||||
 | 
					    const cv::Vec4d &new_intrinsics = cv::Vec4d(1,1,0,0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,47 @@ namespace msckf_vio {
 | 
				
			|||||||
namespace image_handler {
 | 
					namespace image_handler {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void undistortPoint(
 | 
				
			||||||
 | 
					    const cv::Point2f& pt_in,
 | 
				
			||||||
 | 
					    const cv::Vec4d& intrinsics,
 | 
				
			||||||
 | 
					    const std::string& distortion_model,
 | 
				
			||||||
 | 
					    const cv::Vec4d& distortion_coeffs,
 | 
				
			||||||
 | 
					    cv::Point2f& pt_out,
 | 
				
			||||||
 | 
					    const cv::Matx33d &rectification_matrix,
 | 
				
			||||||
 | 
					    const cv::Vec4d &new_intrinsics) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  std::vector<cv::Point2f> pts_in;
 | 
				
			||||||
 | 
					  std::vector<cv::Point2f> pts_out;
 | 
				
			||||||
 | 
					  pts_in.push_back(pt_in);
 | 
				
			||||||
 | 
					  if (pts_in.size() == 0) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const cv::Matx33d K(
 | 
				
			||||||
 | 
					      intrinsics[0], 0.0, intrinsics[2],
 | 
				
			||||||
 | 
					      0.0, intrinsics[1], intrinsics[3],
 | 
				
			||||||
 | 
					      0.0, 0.0, 1.0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const cv::Matx33d K_new(
 | 
				
			||||||
 | 
					      new_intrinsics[0], 0.0, new_intrinsics[2],
 | 
				
			||||||
 | 
					      0.0, new_intrinsics[1], new_intrinsics[3],
 | 
				
			||||||
 | 
					      0.0, 0.0, 1.0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (distortion_model == "radtan") {
 | 
				
			||||||
 | 
					    cv::undistortPoints(pts_in, pts_out, K, distortion_coeffs,
 | 
				
			||||||
 | 
					                        rectification_matrix, K_new);
 | 
				
			||||||
 | 
					  } else if (distortion_model == "equidistant") {
 | 
				
			||||||
 | 
					    cv::fisheye::undistortPoints(pts_in, pts_out, K, distortion_coeffs,
 | 
				
			||||||
 | 
					                                 rectification_matrix, K_new);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    ROS_WARN_ONCE("The model %s is unrecognized, use radtan instead...",
 | 
				
			||||||
 | 
					                  distortion_model.c_str());
 | 
				
			||||||
 | 
					    cv::undistortPoints(pts_in, pts_out, K, distortion_coeffs,
 | 
				
			||||||
 | 
					                        rectification_matrix, K_new);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  pt_out = pts_out[0];
 | 
				
			||||||
 | 
					  return;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void undistortPoints(
 | 
					void undistortPoints(
 | 
				
			||||||
    const std::vector<cv::Point2f>& pts_in,
 | 
					    const std::vector<cv::Point2f>& pts_in,
 | 
				
			||||||
    const cv::Vec4d& intrinsics,
 | 
					    const cv::Vec4d& intrinsics,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user