Julia bindings to PoseLib, the C++
library of minimal solvers and robust refiners for camera pose estimation by
Viktor Larsson and contributors. Loading PoseLib.jl adds a PoseLib backend,
PoseLibSolver(), to the minimal solvers of
VisualGeometryToolkitCore,
and exports PoseLib's robust Levenberg–Marquardt refiners for homographies,
fundamental matrices, relative poses and absolute poses.
pkg> add PoseLib VisualGeometryToolkitCoreJulia 1.13 or later. Every dependency is in the General registry. The C++
library is downloaded prebuilt, as the binary package PoseLib_jll, so no
compiler is needed.
The example estimates a camera's pose from three points with PoseLib's P3P solver, then refines it on all the points with PoseLib's absolute-pose refiner.
using PoseLib, VisualGeometryToolkitCore
# A camera at the origin looks down the z axis at 25 points on a curved
# surface, six units away; K is its intrinsic matrix, in pixels.
K = [800.0 0.0 320.0; 0.0 800.0 240.0; 0.0 0.0 1.0]
X = [Point3(x, y, 6.0 + 0.5x * y) for x in -1.0:0.5:1.0 for y in -1.0:0.5:1.0]
pixel(x) = (y = K * x; Point2(y[1] / y[3], y[2] / y[3]))
u = pixel.(X)
# PoseLib's P3P solver on three of the points and their bearings (unit rays).
f = [Vec3(x / sqrt(sum(abs2, x))) for x in X]
poses = solve(P3P(PoseLibSolver()), Correspondences(X, f), [1, 13, 25])
# Keep the solution that reprojects all 25 points best, then refine it.
reprojection(pose) = sum(sum(abs2, pixel(pose(x)) - v) for (x, v) in zip(X, u))
best = poses[argmin(reprojection.(poses))]
result = refine_absolute_pose(unlabel(best), K, Correspondences(X, u); max_iter = 50,
optimization_strategy = Irls{TLSShape}(), width = 2.0)
pose = estimate(result)
maximum(abs, pose.t) < 1e-8 # true: the camera is at the originGetting started continues with the relative-pose and homography refiners.
- Getting started: a P3P solve and each refiner.
- Minimal solvers and Refiners: selecting the PoseLib backend, the strategies and the unit of the width.
- Platforms and binaries: what is downloaded, for which platforms, under which licenses.
- API reference.
PoseLib.jl is part of the VisualGeometryToolkit packages. Its inputs and outputs are VisualGeometryToolkitCore's types, and VisualGeometryToolkitEstimation's RANSAC estimators can select its solver backend. The rules every package of the toolkit follows are on VisualGeometryToolkitCore's Conventions page, and the portal links every package.
Cite PoseLib, and the original publications of the methods you use (PoseLib's README lists them):
@misc{PoseLib,
title = {{PoseLib - Minimal Solvers for Camera Pose Estimation}},
author = {Viktor Larsson and contributors},
URL = {https://github.com/vlarsson/PoseLib},
year = {2020}
}PoseLib.jl is part of VisualGeometryToolkit. Cite the toolkit as well. Its CITATION.cff is the source of this entry:
@software{pritts2026vgtk,
author = {Pritts, James and Sauer, Hendrik},
title = {{VisualGeometryToolkit.jl}: Julia Packages for Multiple-View Geometry},
url = {https://github.com/VisualGeometryToolkit/VisualGeometryToolkit.jl},
doi = {10.5281/zenodo.23548372},
year = {2026}
}PoseLib.jl is released under the MIT license (see LICENSE). The
prebuilt library it loads contains upstream
PoseLib, released under the
BSD-3-Clause license, and Eigen, released under
the Mozilla Public License 2.0. Their license texts ship inside PoseLib_jll's
artifact, under share/licenses/PoseLib/.