AliceVision
Photogrammetric Computer Vision Framework
Public Member Functions | Static Public Member Functions | List of all members
aliceVision::camera::Pinhole Class Reference

Define a classic Pinhole camera. More...

#include <Pinhole.hpp>

Inheritance diagram for aliceVision::camera::Pinhole:
aliceVision::camera::IntrinsicScaleOffsetDisto aliceVision::camera::IntrinsicScaleOffset aliceVision::camera::IntrinsicBase

Public Member Functions

 Pinhole (unsigned int w, unsigned int h, const Mat3 &K)
 
 Pinhole (unsigned int w, unsigned int h, double focalLengthPixX, double focalLengthPixY, double offsetX, double offsetY, std::shared_ptr< Distortion > distortion=nullptr, std::shared_ptr< Undistortion > undistortion=nullptr)
 
Pinholeclone () const override
 Polymorphic clone.
 
void assign (const IntrinsicBase &other) override
 Assign object. More...
 
double getFocalLengthPixX () const
 
double getFocalLengthPixY () const
 
bool isValid () const override
 Return true if the intrinsic is valid. More...
 
EINTRINSIC getType () const override
 Get embed camera type. More...
 
Mat3 K () const
 
void setK (double focalLengthPixX, double focalLengthPixY, double ppx, double ppy)
 
void setK (const Mat3 &K)
 
Vec2 transformProject (const geometry::Pose3 &pose, const Vec4 &pt3D, bool applyDistortion=true) const
 
Vec2 transformProject (const Eigen::Matrix4d &pose, const Vec4 &pt, bool applyDistortion=true) const override
 Projection of a 3D point into the camera plane (Apply pose, disto (if any) and Intrinsics) More...
 
Vec2 project (const Vec4 &pt, bool applyDistortion=true) const override
 Projection of a 3D point into the camera plane (Apply disto (if any) and Intrinsics) More...
 
Eigen::Matrix< double, 2, 3 > getDerivativeTransformProjectWrtPoint3 (const Eigen::Matrix4d &pose, const Vec4 &pt) const override
 Get the derivative of a projection of a 3D point into the camera plane. More...
 
Eigen::Matrix< double, 2, 2 > getDerivativeTransformProjectWrtPrincipalPoint (const Eigen::Matrix4d &pose, const Vec4 &pt) const
 
Eigen::Matrix< double, 2, 2 > getDerivativeTransformProjectWrtScale (const Eigen::Matrix4d &pose, const Vec4 &pt) const
 
Eigen::Matrix< double, 2, Eigen::Dynamic > getDerivativeTransformProjectWrtParams (const Eigen::Matrix4d &pose, const Vec4 &pt3D) const override
 Get the derivative of a projection of a 3D point into the camera plane. More...
 
Eigen::Matrix< double, 2, Eigen::Dynamic > getDerivativeTransformProjectWrtDistortion (const Eigen::Matrix4d &pose, const Vec4 &pt) const override
 
Eigen::Matrix< double, 3, Eigen::Dynamic > getDerivativeBackProjectUnitWrtDistortion (const Vec2 &pt2D) const override
 
Vec3 toUnitSphere (const Vec2 &pt) const override
 Transform a given point (in pixels) to unit sphere in meters. More...
 
Eigen::Matrix< double, 3, 2 > getDerivativetoUnitSphereWrtPoint (const Vec2 &pt) const
 
Eigen::Matrix< double, 3, Eigen::Dynamic > getDerivativeBackProjectUnitWrtParams (const Vec2 &pt2D) const override
 Get the derivative of the unit sphere backprojection. More...
 
double imagePlaneToCameraPlaneError (double value) const override
 Normalize a given unit pixel error to the camera plane. More...
 
Mat34 getProjectiveEquivalent (const geometry::Pose3 &pose) const
 
bool isVisibleRay (const Vec3 &ray) const override
 Return true if this ray should be visible in the image. More...
 
double getHorizontalFov () const override
 Get the horizontal FOV in radians. More...
 
double getVerticalFov () const override
 Get the vertical FOV in radians. More...
 
double pixelProbability () const override
 how a one pixel change relates to an angular change More...
 
- Public Member Functions inherited from aliceVision::camera::IntrinsicScaleOffsetDisto
 IntrinsicScaleOffsetDisto (unsigned int w, unsigned int h, double scaleX, double scaleY, double offsetX, double offsetY, std::shared_ptr< Distortion > distortion=nullptr, std::shared_ptr< Undistortion > undistortion=nullptr)
 
 IntrinsicScaleOffsetDisto (const IntrinsicScaleOffsetDisto &other)
 
bool operator== (const IntrinsicBase &otherBase) const override
 compare to another intrinsic object More...
 
bool equalTo (const IntrinsicBase &otherBase, bool ignoreDistortion) const
 compare to another intrinsic object More...
 
void setDistortionObject (std::shared_ptr< Distortion > object)
 
bool hasDistortion () const override
 Camera model handles a distortion field. More...
 
Vec2 addDistortion (const Vec2 &p) const override
 Create a new point from a given point by adding distortion. More...
 
Vec2 removeDistortion (const Vec2 &p) const override
 Create a new point from a given point by removing distortion. More...
 
Vec2 getUndistortedPixel (const Vec2 &p) const override
 Return the un-distorted pixel (with removed distortion)
 
Vec2 getDistortedPixel (const Vec2 &p) const override
 Return the distorted pixel (with added distortion)
 
std::size_t getDistortionParamsSize () const
 
std::vector< double > getDistortionParams () const
 
void setDistortionParams (const std::vector< double > &distortionParams)
 
template<class F >
void setDistortionParamsFn (F &&callback)
 
template<class F >
void setDistortionParamsFn (std::size_t count, F &&callback)
 
std::vector< double > getParameters () const override
 Get the intrinsic parameters. More...
 
std::size_t getParametersSize () const override
 Get the count of intrinsic parameters. More...
 
bool updateFromParams (const std::vector< double > &params) override
 Update intrinsic parameters. More...
 
float getMaximalDistortion ([[maybe_unused]] double minRadius, double maxRadius) const override
 
Eigen::Matrix< double, 2, 2 > getDerivativeAddDistoWrtPt (const Vec2 &pt) const
 
Eigen::Matrix< double, 2, 2 > getDerivativeRemoveDistoWrtPt (const Vec2 &pt) const
 
Eigen::MatrixXd getDerivativeAddDistoWrtDisto (const Vec2 &pt) const
 
Eigen::MatrixXd getDerivativeRemoveDistoWrtDisto (const Vec2 &pt) const
 
void setDistortionInitializationMode (EInitMode distortionInitializationMode) override
 Set The intrinsic disto initialization mode. More...
 
EInitMode getDistortionInitializationMode () const override
 Get the intrinsic disto initialization mode. More...
 
std::shared_ptr< DistortiongetDistortion () const
 
void setUndistortionObject (std::shared_ptr< Undistortion > object)
 
std::shared_ptr< UndistortiongetUndistortion () const
 
- Public Member Functions inherited from aliceVision::camera::IntrinsicScaleOffset
 IntrinsicScaleOffset (unsigned int w, unsigned int h, double scaleX, double scaleY, double offsetX, double offsetY)
 
void copyFrom (const IntrinsicScaleOffset &other)
 
void setScale (const Vec2 &scale)
 
Vec2 getScale () const
 
void setOffset (const Vec2 &offset)
 
Vec2 getOffset () const
 
const Vec2 getPrincipalPoint () const
 Principal point in image coordinate ((0,0) is image top-left).
 
Vec2 cam2ima (const Vec2 &p) const override
 Transform a point from the camera plane to the image plane. More...
 
virtual Eigen::Matrix2d getDerivativeCam2ImaWrtScale (const Vec2 &p) const
 
virtual Eigen::Matrix2d getDerivativeCam2ImaWrtPoint () const
 
virtual Eigen::Matrix2d getDerivativeCam2ImaWrtPrincipalPoint () const
 
Vec2 ima2cam (const Vec2 &p) const override
 Transform a point from the image plane to the camera plane. More...
 
virtual Eigen::Matrix< double, 2, 2 > getDerivativeIma2CamWrtScale (const Vec2 &p) const
 
virtual Eigen::Matrix2d getDerivativeIma2CamWrtPoint () const
 
virtual Eigen::Matrix2d getDerivativeIma2CamWrtPrincipalPoint () const
 
void rescale (float factorW, float factorH) override
 Rescale intrinsics to reflect a rescale of the camera image. More...
 
bool importFromParams (const std::vector< double > &params, const Version &inputVersion) override
 Import a vector of params loaded from a file. It is similar to updateFromParams but it deals with file compatibility. More...
 
void setInitialScale (const Vec2 &initialScale)
 Set the initial scale for the intrinsic (used to constrain minimization)
 
Vec2 getInitialScale () const
 Get the intrinsic initial scale. More...
 
void setRatioLocked (bool lock)
 Lock the ratio between fx and fy. More...
 
bool isRatioLocked () const
 
void setOffsetLocked (bool lock)
 Lock the offset. More...
 
bool isOffsetLocked () const
 
void setScaleLocked (bool lock)
 Lock the scale. More...
 
bool isScaleLocked () const
 
double getFocalLength () const
 get focal length in mm More...
 
double getInitialFocalLength () const
 get initial focal length in mm More...
 
double getPixelAspectRatio () const
 estimate the pixel aspect ratio More...
 
void setFocalLength (double focalLengthMM, double pixelAspectRatio, bool useCompatibility=false)
 
void setInitialFocalLength (double initialFocalLengthMM, double pixelAspectRatio, bool useCompatibility=false)
 
- Public Member Functions inherited from aliceVision::camera::IntrinsicBase
 IntrinsicBase (unsigned int width, unsigned int height, const std::string &serialNumber="")
 
bool isLocked () const
 Get the lock state of the intrinsic. More...
 
unsigned int w () const
 Get the intrinsic image width. More...
 
unsigned int h () const
 Get the intrinsic image height. More...
 
double sensorWidth () const
 Get the intrinsic sensor width. More...
 
double sensorHeight () const
 Get the intrinsic sensor height. More...
 
const std::string & serialNumber () const
 Get the intrinsic serial number. More...
 
EInitMode getInitializationMode () const
 Get the intrinsic initialization mode. More...
 
bool operator!= (const IntrinsicBase &other) const
 
Vec2 transformProject (const geometry::Pose3 &pose, const Vec4 &pt3D, bool applyDistortion=true) const
 Projection of a 3D point into the camera plane (Apply pose, disto (if any) and Intrinsics) More...
 
Vec3 backprojectTransform (const Vec2 &pt2D, bool applyUndistortion=true, const geometry::Pose3 &pose=geometry::Pose3(), double depth=1.0) const
 Back-projection of a 2D point at a specific depth into a 3D point. More...
 
Vec3 backProjectUnit (const Vec2 &pt2D) const
 Back-projection of a 2D point on a unitsphere. More...
 
Vec4 getCartesianfromSphericalCoordinates (const Vec3 &pt)
 
Eigen::Matrix< double, 4, 3 > getDerivativeCartesianfromSphericalCoordinates (const Vec3 &pt)
 
Vec2 residual (const geometry::Pose3 &pose, const Vec4 &X, const Vec2 &x, bool applyDistortion=true) const
 Compute the residual between the 3D projected point X and an image observation x. More...
 
Mat2X residuals (const geometry::Pose3 &pose, const Mat3X &X, const Mat2X &x) const
 Compute the residuals between the 3D projected point X and an image observation x. More...
 
void lock ()
 Lock the intrinsic.
 
void unlock ()
 Unlock the intrinsic.
 
void setWidth (unsigned int width)
 Set the intrinsic image width. More...
 
void setHeight (unsigned int height)
 Set the intrinsic image height. More...
 
void setSensorWidth (double width)
 Set the intrinsic sensor width. More...
 
void setSensorHeight (double height)
 Set the intrinsic sensor height. More...
 
void setSerialNumber (const std::string &serialNumber)
 Set the serial number. More...
 
void setInitializationMode (EInitMode initializationMode)
 Set the intrinsic initialization mode. More...
 
std::string getTypeStr () const
 Get the string describing the intrinsic type. More...
 
virtual bool isVisible (const Vec2 &pix) const
 Return true if these pixel coordinates should be visible in the image. More...
 
virtual bool isVisible (const Vec2f &pix) const
 Return true if these pixel coordinates should be visible in the image. More...
 
virtual float getMaximalDistortion (double minRadius, double maxRadius) const
 Assuming the distortion is a function of radius, estimate the maximal undistorted radius for a range of distorted radius. More...
 
virtual std::size_t hashValue () const
 Generate an unique Hash from the camera parameters (used for grouping) More...
 
virtual void initializeState ()
 Initialize state with default values The estimator state is used in the bundle adjustment to decide if we update it. It is set to constant if the intrinsic is locked It is set to refined if unlocked.
 
EEstimatorParameterState getState () const
 accessor to estimator state More...
 
void setState (EEstimatorParameterState state)
 mutator for the estimator state More...
 

Static Public Member Functions

static std::shared_ptr< Pinholecast (std::shared_ptr< IntrinsicBase > sptr)
 
- Static Public Member Functions inherited from aliceVision::camera::IntrinsicScaleOffsetDisto
static std::shared_ptr< IntrinsicScaleOffsetDistocast (std::shared_ptr< IntrinsicBase > sptr)
 
- Static Public Member Functions inherited from aliceVision::camera::IntrinsicScaleOffset
static std::shared_ptr< IntrinsicScaleOffsetcast (std::shared_ptr< IntrinsicBase > sptr)
 

Additional Inherited Members

- Public Types inherited from aliceVision::camera::IntrinsicBase
using sptr = std::shared_ptr< IntrinsicBase >
 
using ptr = IntrinsicBase *
 
- Protected Member Functions inherited from aliceVision::camera::IntrinsicScaleOffsetDisto
void throwSetDistortionParamsCountError (std::size_t expected, std::size_t received)
 
- Protected Attributes inherited from aliceVision::camera::IntrinsicScaleOffsetDisto
std::shared_ptr< Distortion_pDistortion
 
std::shared_ptr< Undistortion_pUndistortion
 
EInitMode _distortionInitializationMode = EInitMode::NONE
 
- Protected Attributes inherited from aliceVision::camera::IntrinsicScaleOffset
bool _ratioLocked {true}
 
bool _offsetLocked {false}
 
bool _scaleLocked {false}
 
Vec2 _scale {1.0, 1.0}
 
Vec2 _offset {0.0, 0.0}
 
Vec2 _initialScale {-1.0, -1.0}
 
- Protected Attributes inherited from aliceVision::camera::IntrinsicBase
std::string _serialNumber
 
double _sensorWidth = 36.0
 
double _sensorHeight = 24.0
 
unsigned int _w = 0
 
unsigned int _h = 0
 
EInitMode _initializationMode = EInitMode::NONE
 initialization mode
 
bool _locked = false
 intrinsic lock
 
EEstimatorParameterState _state = EEstimatorParameterState::REFINED
 

Detailed Description

Define a classic Pinhole camera.

Member Function Documentation

◆ assign()

void aliceVision::camera::Pinhole::assign ( const IntrinsicBase other)
inlineoverridevirtual

Assign object.

Parameters
[in]other

Reimplemented from aliceVision::camera::IntrinsicScaleOffsetDisto.

◆ getDerivativeBackProjectUnitWrtParams()

Eigen::Matrix< double, 3, Eigen::Dynamic > aliceVision::camera::Pinhole::getDerivativeBackProjectUnitWrtParams ( const Vec2 &  pt2D) const
overridevirtual

Get the derivative of the unit sphere backprojection.

Parameters
[in]pt2DThe 2D point
Returns
The backproject jacobian with respect to the pose

Implements aliceVision::camera::IntrinsicBase.

◆ getDerivativeTransformProjectWrtParams()

Eigen::Matrix< double, 2, Eigen::Dynamic > aliceVision::camera::Pinhole::getDerivativeTransformProjectWrtParams ( const Eigen::Matrix4d &  pos,
const Vec4 &  pt3D 
) const
overridevirtual

Get the derivative of a projection of a 3D point into the camera plane.

Parameters
[in]poseThe pose
[in]pt3DThe 3D point
Returns
The projection jacobian with respect to the params

Implements aliceVision::camera::IntrinsicBase.

◆ getDerivativeTransformProjectWrtPoint3()

Eigen::Matrix< double, 2, 3 > aliceVision::camera::Pinhole::getDerivativeTransformProjectWrtPoint3 ( const Eigen::Matrix4d &  pose,
const Vec4 &  pt3D 
) const
overridevirtual

Get the derivative of a projection of a 3D point into the camera plane.

Parameters
[in]poseThe pose
[in]pt3DThe 3D point
Returns
The projection jacobian with respect to the point

Implements aliceVision::camera::IntrinsicBase.

◆ getHorizontalFov()

double aliceVision::camera::Pinhole::getHorizontalFov ( ) const
overridevirtual

Get the horizontal FOV in radians.

Returns
Horizontal FOV in radians

Implements aliceVision::camera::IntrinsicBase.

◆ getType()

EINTRINSIC aliceVision::camera::Pinhole::getType ( ) const
overridevirtual

Get embed camera type.

Returns
EINTRINSIC enum value

Implements aliceVision::camera::IntrinsicBase.

◆ getVerticalFov()

double aliceVision::camera::Pinhole::getVerticalFov ( ) const
overridevirtual

Get the vertical FOV in radians.

Returns
Vertical FOV in radians

Implements aliceVision::camera::IntrinsicBase.

◆ imagePlaneToCameraPlaneError()

double aliceVision::camera::Pinhole::imagePlaneToCameraPlaneError ( double  value) const
overridevirtual

Normalize a given unit pixel error to the camera plane.

Parameters
[in]valueGiven unit pixel error
Returns
Normalized unit pixel error to the camera plane

Implements aliceVision::camera::IntrinsicBase.

◆ isValid()

bool aliceVision::camera::Pinhole::isValid ( ) const
inlineoverridevirtual

Return true if the intrinsic is valid.

Returns
True if the intrinsic is valid

Reimplemented from aliceVision::camera::IntrinsicBase.

◆ isVisibleRay()

bool aliceVision::camera::Pinhole::isVisibleRay ( const Vec3 &  ray) const
overridevirtual

Return true if this ray should be visible in the image.

Parameters
[in]raythe ray that may or may not be visible in the image
Returns
True if this ray is visible theoretically, false otherwise

Implements aliceVision::camera::IntrinsicBase.

◆ pixelProbability()

double aliceVision::camera::Pinhole::pixelProbability ( ) const
overridevirtual

how a one pixel change relates to an angular change

Returns
a value in radians

Implements aliceVision::camera::IntrinsicBase.

◆ project()

Vec2 aliceVision::camera::Pinhole::project ( const Vec4 &  pt3D,
bool  applyDistortion = true 
) const
overridevirtual

Projection of a 3D point into the camera plane (Apply disto (if any) and Intrinsics)

Parameters
[in]pt3DThe 3D point
[in]applyDistortionIf true, apply the distortion if there is any
Returns
The 2D projection in the camera plane

Implements aliceVision::camera::IntrinsicBase.

◆ toUnitSphere()

Vec3 aliceVision::camera::Pinhole::toUnitSphere ( const Vec2 &  pt) const
overridevirtual

Transform a given point (in pixels) to unit sphere in meters.

Parameters
ptthe input point
Returns
A point on the unit sphere

Implements aliceVision::camera::IntrinsicBase.

◆ transformProject()

Vec2 aliceVision::camera::Pinhole::transformProject ( const Eigen::Matrix4d &  pose,
const Vec4 &  pt3D,
bool  applyDistortion = true 
) const
overridevirtual

Projection of a 3D point into the camera plane (Apply pose, disto (if any) and Intrinsics)

Parameters
[in]poseThe pose
[in]pt3DThe 3D point
[in]applyDistortionIf true, apply the distortion if there is any
Returns
The 2D projection in the camera plane

Implements aliceVision::camera::IntrinsicBase.


The documentation for this class was generated from the following files: