[][src]Function cv_pinhole::average_pose_reprojection_error

pub fn average_pose_reprojection_error(
    pose: RelativeCameraPose,
    m: FeatureMatch<NormalizedKeyPoint>,
    triangulator: impl TriangulatorRelative
) -> Option<f64>

See pose_reprojection_error.

This is a convenience function that simply finds the average reprojection error rather than all components.

// Create an arbitrary point in the space of camera A.
let point_a = CameraPoint(Point3::new(0.4, -0.25, 5.0));
// Create an arbitrary relative pose between two cameras A and B.
let pose = RelativeCameraPose(IsometryMatrix3::from_parts(Vector3::new(0.1, 0.2, -0.5).into(), 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(point_a.xy() / point_a.z);
let nkpb = NormalizedKeyPoint(point_b.xy() / point_b.z);

// Create a triangulator.
let triangulator = cv_geom::MinimalSquareReprojectionErrorTriangulator::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);