Class PinholeCamera

Inheritance Relationships

Base Type

Class Documentation

class aslam::PinholeCamera : public aslam::Cloneable<Camera, PinholeCamera>

An implementation of the pinhole camera model with (optional) distortion.

The usual model of a pinhole camera follows these steps:

  • Transformation: Transform the point into a coordinate frame associated with the camera

  • Normalization: Project the point onto the normalized image plane: \(\mathbf y := \left[ x/z,y/z\right] \)

  • Distortion: apply a nonlinear transformation to \(y\) to account for radial and tangential distortion of the lens

  • Projection: Project the point into the image using a standard \(3 \time 3\) projection matrix

Intrinsic parameters ordering: fu, fv, cu, cv Reference: http://en.wikipedia.org/wiki/Pinhole_camera_model

Constructors/destructors and operators

friend friend std::ostream & operator<< (std::ostream &out, const PinholeCamera &camera)

Convenience function to print the state using streams.

PinholeCamera()

Empty constructor for serialization interface.

PinholeCamera(const PinholeCamera &other) = default

Copy constructor for clone operation.

void operator=(const PinholeCamera&) = delete
PinholeCamera(const Eigen::VectorXd &intrinsics, uint32_t image_width, uint32_t image_height, aslam::Distortion::UniquePtr &distortion)

Construct a PinholeCamera with distortion.

Parameters
  • intrinsics[in] Vector containing the intrinsic parameters (fu,fv,cu,cv).

  • image_width[in] Image width in pixels.

  • image_height[in] Image height in pixels.

  • distortion[in] Pointer to the distortion model.

PinholeCamera(const Eigen::VectorXd &intrinsics, uint32_t image_width, uint32_t image_height)

Construct a PinholeCamera without distortion.

Parameters
  • intrinsics[in] Vector containing the intrinsic parameters (fu,fv,cu,cv).

  • image_width[in] Image width in pixels.

  • image_height[in] Image height in pixels.

PinholeCamera(double focallength_cols, double focallength_rows, double imagecenter_cols, double imagecenter_rows, uint32_t image_width, uint32_t image_height, aslam::Distortion::UniquePtr &distortion)

Construct a PinholeCamera with distortion.

Parameters
  • focallength_cols[in] Focal length in pixels; cols (width-direction).

  • focallength_rows[in] Focal length in pixels; rows (height-direction).

  • imagecenter_cols[in] Image center in pixels; cols (width-direction).

  • imagecenter_rows[in] Image center in pixels; rows (height-direction).

  • image_width[in] Image width in pixels.

  • image_height[in] Image height in pixels.

  • distortion[in] Pointer to the distortion model.

PinholeCamera(double focallength_cols, double focallength_rows, double imagecenter_cols, double imagecenter_rows, uint32_t image_width, uint32_t image_height)

Construct a PinholeCamera without distortion.

Parameters
  • focallength_cols[in] Focal length in pixels; cols (width-direction).

  • focallength_rows[in] Focal length in pixels; rows (height-direction).

  • imagecenter_cols[in] Image center in pixels; cols (width-direction).

  • imagecenter_rows[in] Image center in pixels; rows (height-direction).

  • image_width[in] Image width in pixels.

  • image_height[in] Image height in pixels.

inline virtual ~PinholeCamera()

Methods to project and back-project euclidean points

virtual bool backProject3(const Eigen::Ref<const Eigen::Vector2d> &keypoint, Eigen::Vector3d *out_point_3d) const

Compute the 3d bearing vector in euclidean coordinates given a keypoint in image coordinates.

Uses the projection (& distortion) models. The result might be in normalized image plane for some camera implementations but not for the general case.

Parameters
  • keypoint[in] Keypoint in image coordinates.

  • out_point_3d[out] Bearing vector in euclidean coordinates

template<typename DerivedKeyPoint, typename DerivedPoint3d>
inline const ProjectionResult evaluateProjectionResult(const Eigen::MatrixBase<DerivedKeyPoint> &keypoint, const Eigen::MatrixBase<DerivedPoint3d> &point_3d) const

Checks the success of a projection operation and returns the result in a ProjectionResult object.

Parameters
  • keypoint[in] Keypoint in image coordinates.

  • point_3d[in] Projected point in euclidean.

Returns

The ProjectionResult object contains details about the success of the projection.

Functional methods to project and back-project points

template<typename ScalarType, typename DistortionType, typename MIntrinsics, typename MDistortion>
const ProjectionResult project3Functional(const Eigen::Matrix<ScalarType, 3, 1> &point_3d, const Eigen::MatrixBase<MIntrinsics> &intrinsics_external, const Eigen::MatrixBase<MDistortion> &distortion_coefficients_external, Eigen::Matrix<ScalarType, 2, 1> *out_keypoint) const

Template version of project3Functional.

virtual const ProjectionResult project3Functional(const Eigen::Ref<const Eigen::Vector3d> &point_3d, const Eigen::VectorXd *intrinsics_external, const Eigen::VectorXd *distortion_coefficients_external, Eigen::Vector2d *out_keypoint, Eigen::Matrix<double, 2, 3> *out_jacobian_point, Eigen::Matrix<double, 2, Eigen::Dynamic> *out_jacobian_intrinsics, Eigen::Matrix<double, 2, Eigen::Dynamic> *out_jacobian_distortion) const

This function projects a point into the image using the intrinsic parameters that are passed in as arguments.

If any of the Jacobians are nonnull, they should be filled in with the Jacobian with respect to small changes in the argument.

Parameters
  • point_3d[in] The point in euclidean coordinates.

  • intrinsics_external[in] External intrinsic parameter vector. NOTE: If nullptr, use internal distortion parameters.

  • distortion_coefficients_external[in] External distortion parameter vector. Parameter is ignored is no distortion is active. NOTE: If nullptr, use internal distortion parameters.

  • out_keypoint[out] The keypoint in image coordinates.

  • out_jacobian_point[out] The Jacobian wrt. to changes in the euclidean point. nullptr: calculation is skipped.

  • out_jacobian_intrinsics[out] The Jacobian wrt. to changes in the intrinsics. nullptr: calculation is skipped.

  • out_jacobian_distortion[out] The Jacobian wrt. to changes in the distortion parameters. nullptr: calculation is skipped.

Returns

Contains information about the success of the projection. Check ProjectionResult for more information.

Methods to support unit testing.

virtual Eigen::Vector2d createRandomKeypoint() const

Creates a random valid keypoint..

virtual Eigen::Vector3d createRandomVisiblePoint(double depth) const

Creates a random visible point.

Negative depth means random between 0 and 100 meters.

void getBorderRays(Eigen::MatrixXd &rays) const

Get a set of border rays.

Methods to access intrinsics.

inline Eigen::Matrix3d getCameraMatrix() const

Returns the camera matrix for the pinhole projection.

inline double fu() const

The horizontal focal length in pixels.

inline double fv() const

The vertical focal length in pixels.

inline double cu() const

The horizontal image center in pixels.

inline double cv() const

The vertical image center in pixels.

inline virtual int getParameterSize() const

Returns the number of intrinsic parameters used in this camera model.

virtual bool intrinsicsValid(const Eigen::VectorXd &intrinsics) const

Function to check whether the given intrinsic parameters are valid for this model.

virtual void printParameters(std::ostream &out, const std::string &text) const

Print the internal parameters of the camera in a human-readable form Print to the ostream that is passed in.

The text is extra text used by the calling function to distinguish cameras

static inline constexpr int parameterCount()

Returns the number of intrinsic parameters used in this camera model.

static bool areParametersValid(const Eigen::VectorXd &parameters)

Static function that checks whether the given intrinsic parameters are valid for this model.

Public Types

enum [anonymous]

Values:

enumerator CLASS_SERIALIZATION_VERSION
enum Parameters

Values:

enumerator kFu
enumerator kFv
enumerator kCu
enumerator kCv

Public Functions

ASLAM_POINTER_TYPEDEFS(PinholeCamera)

Public Static Functions

template<typename DistortionType>
static inline PinholeCamera::Ptr createTestCamera()

Create a test camera object for unit testing.

template<typename DistortionType>
static inline PinholeCamera::UniquePtr createTestCameraUnique()

Create a test camera object for unit testing.

static PinholeCamera::Ptr createTestCamera()

Create a test camera object for unit testing. (without distortion)