A general solution to the P4P problem for camera with unknown focal length

Martin Bujnak, Zuzana Kukelova, Tomás PajdlaCVPR 2008

Abstract

This paper presents a general solution to the determination of the pose of a perspective camera with unknown focal length from images of four 3D reference points. Our problem is a generalization of the P3P and P4P problems previously developed for fully calibrated cameras. Given four 2D-to-3D correspondences, we estimate camera position, orientation and recover the camera focal length. We formulate the problem and provide a minimal solution from four points by solving a system of algebraic equations. We compare the Hidden variable resultant and Grobner basis techniques for solving the algebraic equations of our problem. By evaluating them on synthetic and on real-data, we show that the Grobner basis technique provides stable results.

Introduction

In computer vision, the Perspective-n-Point (PnP) problem involves finding the 3D pose (position and orientation) of a camera given a set of 3D points in the world and their corresponding 2D projections in an image. Standard solutions usually assume the camera is "calibrated," meaning internal parameters like the focal length are known. However, in many real-world scenarios—such as using a zooming security camera or analyzing an archival photo—the focal length is unknown.

While solutions existed for three points (P3P) with a known camera, or four points (P4P) for planar scenes, a general solution for four arbitrary points in 3D space with an unknown focal length remained elusive. This research provides a "minimal" solution—using the absolute fewest points mathematically required to solve for the six degrees of freedom of pose plus the unknown focal length.

Methodology

The problem is formulated by examining the distances between four 3D points. Since rigid transformations preserve distances, the authors set up a system of polynomial equations where the unknown depths of the points and the unknown focal length must satisfy the observed geometry. Two algebraic approaches were compared:

  1. Hidden Variable Resultant Method: This involves "hiding" one variable (like focal length) to reduce system complexity. While accurate with high-precision arithmetic, it is computationally expensive.
  2. Gröbner Basis Method: This technique finds a simpler set of equations (a basis) sharing the same solutions. Using an "action matrix" approach, solutions are found via eigenvalue calculation.

The Gröbner basis solver proved superior for practical use. By pre-calculating the problem's structure offline, the authors created an online solver that is fast and stable using standard double-precision floating-point math. A key discovery was that the general P4P problem with unknown focal length has exactly 10 potential solutions; a fifth point or geometric constraints can be used to identify the correct one.

Experimental Results

The algorithm was evaluated on both synthetic and real-world data. Synthetic tests involved random 3D scenes projected onto virtual cameras with added Gaussian noise to test robustness. Real-world tests utilized photographs of planar objects (books) and complex 3D structures.

Pose and focal length estimation on a non-planar 3D block structure. The white wireframe indicates the projected model based on the recovered parameters.

Key performance metrics include:

  • Efficiency: The Gröbner basis solver takes approximately 233 milliseconds in Matlab, significantly faster than the Hidden Variable method.
  • Accuracy: On real data, estimated focal lengths were within 0.1mm of the ground truth EXIF metadata.
  • Versatility: The method works equally well for points on a flat surface or scattered throughout a 3D volume.

Conclusion

This paper provides a robust, general solution to the P4P problem with unknown focal length. The solver is best utilized as a kernel within a RANSAC loop, allowing it to quickly process large datasets to find the best geometric fit. While highly effective, accuracy remains dependent on the quality and distribution of the four chosen points. Future extensions may address more complex camera models, including those with radial lens distortion.

Summary updated

BibTeX
@inproceedings{bujnak2008general,
  author = {Martin Bujnak and Zuzana Kukelova and Tomás Pajdla},
  title = {{A general solution to the P4P problem for camera with unknown focal length}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2008},
  url = {https://openreview.net/forum?id=H1bd52bu-r},
}
Figure