P3P

RANSAC Problem

VisualGeometryToolkitEstimation.AbsolutePoseProblem — Type
AbsolutePoseProblem(model::CameraModel, pairs; backend=NativeSolver())

Construct an absolute-pose (P3P) problem from 3D-2D correspondences and a camera model. Rays are precomputed via backproject(model, u) at construction time; cs_solve pairs the world points with those rays for the P3P solver. Accepts any sources/targets-protocol container of 3D-source / 2D-target correspondences; a Correspondences:score column is the PROSAC prior.

The residual currency is the RAW pixel of model for every lens: scoring projects through the intrinsics AND the lens (mahalanobis_distances!), and both local optimizations refine the same reprojection — the Student-t M-step and the Welsch lift run on VGC's full-camera constraint_with_jacobians(model, pose, X, u). A Pinhole model keeps the classic calibrated kernels (bit-identical to before). Nothing is undistorted: supply the detections as measured and the camera as calibrated.

The world points are plain numbers (StaticVector{3, <:Real}, or an Uncertain one): a problem is the inner loop, and physical points (lengths) are a MethodError here — find_absolute_pose takes them and strips them in metres once.

source

Fitting Pipeline

VisualGeometryToolkitEstimation.find_absolute_pose — Function
find_absolute_pose(camera_model, correspondences; scoring,
    max_trials, min_trials,
    local_optimization_strategy, config=nothing)

Robust absolute pose estimation via P3P + RANSAC with MSAC scoring. Every default is configs/default.toml's ([ransac], [pipelines.absolute_pose]); a keyword overrides.

Returns a RansacEstimate, the :no_model result (iterations 0) for fewer than 3 correspondences (the P3P minimal sample). iterations(result) is the number of trials (hypotheses drawn); test found_model(result) before reading the model (see RansacEstimate).

Units

The world points are plain numbers or lengths, all one form. Lengths (FlexUnits quantities, e.g. X .* m) are read in metres at entry — exactly, the stored value — the search runs on plain metres, and the pose comes back physical: a unitful CameraExtrinsics, its translation in metres, equal after ustrip(m, ·) to the plain search's on ustrip(m, X) with the same rng. Plain points give a plain pose in their own unit, as before. The residuals, rms and sigma are pixels either way. A unitful extent goes with unitful points (a plain one with plain points).

Arguments

  • correspondences: X => u pairs (world point => raw pixel) — Correspondences, StructArray{<:Pair} or a Pair vector; a Correspondences:score column is the per-match prior (PROSAC; uniform otherwise).
  • scoring: the scorer, its width in PIXELS (the reprojection residual's unit), as find_homography; default [pipelines.absolute_pose] scoring.
  • extent: as find_homography; the pose's _check_extent rejects poses failing cheirality or yielding a non-simple / non-convex image quad.
  • workspace: as find_homography, built with RansacWorkspace([T,] AbsolutePoseProblem, n_data).
  • local_optimization_strategy: default [pipelines.absolute_pose] local_optimization_strategy on the 6-dof pose chart, as find_homography.
  • the other keywords as find_homography.

Examples

result = find_absolute_pose(camera_model, correspondences)
result = find_absolute_pose(camera_model, correspondences; scoring = MsacScoring(AbsolutePoseProblem; threshold = 10.0))
source
VisualGeometryToolkitEstimation.refine_absolute_pose — Function
refine_absolute_pose(pose, camera_model, correspondences; optimization_strategy, scale | width, workspace = nothing)
refine_absolute_pose(pose, bearing_correspondences; optimization_strategy, scale | width, workspace = nothing)
    -> FitResult{M, RefineMetadata}

The camera extrinsics pose (world → camera, x_c = R·X + t) refined against X => u pairs (world point => raw pixel) of the camera camera_model, from pose itself, on find_absolute_pose's AbsolutePoseProblem — the raw-pixel reprojection error through the full camera (codimension 2), on the LeftRigidManifold6 chart; any lens, rays at and past 90° included. Plain least squares over every correspondence is optimization_strategy = nothing. The keywords, the result and the refusals are those of every refine_*, documented on refine_homography (default strategy: [refine.absolute_pose] optimization_strategy). Fewer than 3 correspondences: the guess back unrefined, record (ReturnCode.InitialFailure, NoRule) (retcode_symbol:degenerate).

Bearings: a camera given by its rays (central or generalized)

The second form takes X => f pairs of world points and the camera-frame UNIT bearings observing them (StaticVector{3} both), for a camera the stack holds no CameraModel of — the caller back-projects; optional attribute columns origins (each ray's origin in the camera frame: a non-central camera), M (each bearing's back-projection Jacobian: residuals whitened into pixels, else radians) and weights (fixed per-correspondence weights). Its problem is a BearingPoseProblem: the tangent-plane residual of bearings.md, whose norm is the angle between the rays, on the same LeftRigidManifold6 chart; rays at and past 90° and behind the camera are data like any other. Its default is every refine's ([refine.bearing_pose], Triggs{WelschShape} at the caller's scale or width, in the residual's unit: radians, or pixels with an M column); least squares over every correspondence at the caller's weights is optimization_strategy = nothing. It has no find_*: a generalized camera has no minimal solver here. The guess's ray origins must not coincide with their points (ArgumentError). The keywords are the shared refine set; there is no max_iter (the cap is the strategy's).

Frames and units

The refined pose comes back with the guess's frame labels, its translation an SVector{3, Float64} (plain) or lengths. As find_absolute_pose: world points (and the pose's translation) — and ray origins — are plain numbers or lengths, all one form; physical ones are read in metres and the pose comes back physical, in metres. The residuals are pixels (radians for bearings without M) either way.

source

Result Types

Model type — Extrinsics3, VisualGeometryToolkitCore's world→camera rigid pose (import it from VisualGeometryToolkitCore). Do not confuse it with Rigid3, the unlabeled alias the hand-eye problem uses — a different type.

model_type(::AbsolutePoseProblem) = Extrinsics3 and solve returns FixedModels{4, Extrinsics3} | nothing (up to 4 P3P solutions).

Local Optimization

find_absolute_pose deploys Irls{TLSShape}() (least squares on the inliers, at the default MSAC scorer's 8 px threshold; [pipelines.absolute_pose] in configs/default.toml). Any other strategy composes, LocalOptimizationDoneRight's half-quadratic lifts on the 6-dof pose chart among them. The per-iteration M-step for AbsolutePoseProblem is a Levenberg–Marquardt refit on the 6-dof left-perturbation chart about the current pose (VGC's LeftRigidManifold6: R = exp(δω)·R₀, t = exp(δω)·t₀ + δt): it minimizes the weighted calibrated reprojection error from constraint_with_jacobians(::Extrinsics3, X, ray) in VisualGeometryToolkitCore (the raw-pixel error for a distorting lens) with an analytic Jacobian (the chart's closed-form action_jacobian), running VisualGeometryToolkitCore's chart LM (NLLSsolver, through lmsolve_chart!) on a ManifoldLmWorkspace{6}.

Correspondence Infrastructure

AbstractCorrespondenceProblem is the abstract supertype for RANSAC problems based on point correspondences (homographies, fundamental matrices, P3P).