- 对于 3D 点
std::vector<cv::Point3d> transform_3d_points(std::vector<cv::Point3d> points3d, cv::Mat transformation_matrix){
std::vector<cv::Point3d> transformed_points3d;
cv::perspectiveTransform(points3d, transformed_points3d, transformation_matrix);
return transformed_points3d;
}
- 对于二维点
std::vector<cv::Point2d> transform_2d_points(std::vector<cv::Point2d> points2d, cv::Mat transformation_matrix){
std::vector<cv::Point2d> transformed_points2d;
cv::perspectiveTransform(points2d, transformed_points2d, transformation_matrix);
return transformed_points2d;
}
对于 3d 点,变换矩阵应该是 4*4 齐次的。
例如
cv::Mat transformation_matrix = (cv::Mat_<double>(4, 4) << 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
std::vector<cv::Points3d> points3d = { cv::Points3d(0,0,0), cv::Points3d(1,1,1) }
对于 2d 点,变换矩阵应该是 3*3 齐次的。
例如
cv::Mat transformation_matrix = (cv::Mat_<double>(3, 3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);
std::vector<cv::Points2d> points2d = { cv::Points2d(0,0), cv::Points3d(1,1) }