[][src]Function cv_pinhole::pose_reprojection_error

pub fn pose_reprojection_error(
    pose: RelativeCameraPose,
    m: FeatureMatch<NormalizedKeyPoint>,
    triangulator: impl TriangulatorRelative
) -> Option<[Vector2<f64>; 2]>

Find the reprojection error in focal lengths of a feature match and a relative pose using the given triangulator.

If the feature match destructures as FeatureMatch(a, b), then A is the camera of a, and B is the camera of b. The pose must transform the space of camera A into camera B. The triangulator will triangulate the 3d point from the perspective of camera A, and the pose will be used to transform the point into the perspective of camera B.

You can use [cv_core::geom::make_one_pose_dlt_triangulator] to create the triangulator.

// 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 errors = cv_pinhole::pose_reprojection_error(pose, FeatureMatch(nkpa, nkpb), triangulator).unwrap();
let average_error = errors.iter().map(|v| v.norm()).sum::<f64>() * 0.5;
assert!(average_error < 1e-6);