[−][src]Function cv_pinhole::average_pose_reprojection_error
pub fn average_pose_reprojection_error(
pose: CameraToCamera,
m: FeatureMatch<NormalizedKeyPoint>,
triangulator: impl TriangulatorRelative
) -> Option<f64>
This is a convenience function that simply finds the average reprojection error rather than all components.
use cv_core::{CameraToCamera, CameraPoint, FeatureMatch, Pose}; use cv_core::nalgebra::{Point3, IsometryMatrix3, Vector3, Rotation3}; use cv_pinhole::NormalizedKeyPoint; // Create an arbitrary point in the space of camera A. let point_a = CameraPoint(Point3::new(0.4, -0.25, 5.0).to_homogeneous()); // Create an arbitrary relative pose between two cameras A and B. let pose = CameraToCamera::from_parts(Vector3::new(0.1, 0.2, -0.5), Rotation3::identity()); // Transform the point in camera A to camera B. let point_b = pose.transform(point_a); // Convert the camera points to normalized image coordinates. let nkpa = NormalizedKeyPoint::from_camera_point(point_a).unwrap(); let nkpb = NormalizedKeyPoint::from_camera_point(point_b).unwrap(); // Create a triangulator. let triangulator = cv_geom::MinSquaresTriangulator::new(); // Since the normalized keypoints were computed exactly, there should be no reprojection error. let average_error = cv_pinhole::average_pose_reprojection_error(pose, FeatureMatch(nkpa, nkpb), triangulator).unwrap(); assert!(average_error < 1e-6);