Perspective-3-Point
RecoverPose.p3p — Functionp3p(points, pdn_pixels::AbstractVector{SVector{3, T}}, K)Recover pose using P3P algorithm.
Arguments:
points: Vector of 3D points in(x, y, z)` format.pdn_pixels::AbstractVector{SVector{3, Float64}}: Corresponding projections ofpointsonto image plane, predivided byKintrinsics and normalized. E.g.:Ki = inv(K); p = Ki [x, y, 1]; p /= norm(p).K::SMatrix{3, 3, Float64}: Camera intrinsics.
Returns:
Vector{SMatrix{3, 4, Float64}} vector of up to 4 possible solutions. Each element is a projection matrix P = K * [R|t]. To get pure transformation matrix, multiply P by inv(K).
References:
Link: https://cmp.felk.cvut.cz/~pajdla/gvg/GVG-2016-Lecture.pdf
chapter: 7.3 Calibrated camera pose computation.
pages: 51-59RecoverPose.p3p_select_model — Functionp3p_select_model(models, points, pixels; threshold = 1.0)Select best pose from models.
Arguments:
models: Projection matrices from which to select best one.points: 3D points in(x, y, z)pixels: Corresponding projections onto image plane in(x, y)format.threshold: Maximum distance in pixels between projected point and its target pixel, for the point to be considered inlier. Default value is1.0.
Returns:
n_inliers, (projection, inliers, error).
n_inliers: Number of inliers for theprojection.projection:K * Pprojection matrix that projectspointsonto image plane.inliers: Boolean vector indicating which point is inlier.error: Average reprojection error for thepose.
RecoverPose.p3p_ransac — Functionp3p_ransac(points, pixels, pdn_pixels, K; threshold = 1.0, ransac_kwargs...)Recover pose K*[R|t] using P3P Ransac algorithm.
Arguments:
points: 3D points in(x, y, z)pixels: Corresponding projections onto image plane in(x, y)format.pdn_pixels: Corresponding projections onto image plane, predivided byKintrinsics and normalized. E.g.:Ki = inv(K); p = Ki [x, y, 1]; p /= norm(p).K: Camera intrinsics.threshold: Maximum distance in pixels between projected point and its target pixel, for the point to be considered inlier. Default value is1.0.ransac_kwargs...: Keyword arguments passed toransac.
Returns:
n_inliers, (projection, inliers, error).
n_inliers: Number of inliers for theprojection.projection:K * Pprojection matrix that projectspointsonto image plane.inliers: Boolean vector indicating which point is inlier.error: Average reprojection error for thepose.
References:
Link: https://cmp.felk.cvut.cz/~pajdla/gvg/GVG-2016-Lecture.pdf
chapter: 7.3 Calibrated camera pose computation.
pages: 51-59p3p_ransac(points, pixels, K; threshold = 1.0, ransac_kwargs...)Recover pose K*[R|t] using P3P Ransac algorithm.
Arguments:
points: 3D points in(x, y, z)pixels: Corresponding projections onto image plane in(x, y)format. These values, WILL be predivided and normalized by the intrinsic matrix. E.g.:Ki = inv(K); p = Ki [x, y, 1]; p /= norm(p).K: Camera intrinsics.threshold::Real: Maximum distance in pixels between projected point and its target pixel, for the point to be considered inlier. Default value is1.0.ransac_kwargs...: Keyword arguments passed toransac.
Returns:
Vector{SMatrix{3, 4, Float64}} vector of up to 4 possible solutions. Each element is a projection matrix P = K * [R|t]. To get pure transformation matrix, multiply P by inv(K).
References:
Link: https://cmp.felk.cvut.cz/~pajdla/gvg/GVG-2016-Lecture.pdf
chapter: 7.3 Calibrated camera pose computation.
pages: 51-59RecoverPose.pre_divide_normalize — Functionpre_divide_normalize(pixels, K)Divide pixels by K intrinsic matrix and normalize them. pixels in (x, y) format.