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

Class with "focal" (scale) and center offset. More...

#include <IntrinsicScaleOffset.hpp>

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

Public Member Functions

 IntrinsicScaleOffset (unsigned int w, unsigned int h, double scaleX, double scaleY, double offsetX, double offsetY)
 
void copyFrom (const IntrinsicScaleOffset &other)
 
bool operator== (const IntrinsicBase &otherBase) const override
 operator == More...
 
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 updateFromParams (const std::vector< double > &params) override
 Update intrinsic parameters. 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...
 
virtual Vec2 transformProject (const Eigen::Matrix4d &pose, const Vec4 &pt3D, bool applyDistortion=true) const =0
 Projection of a 3D point into the camera plane (Apply pose, disto (if any) and Intrinsics) More...
 
virtual Vec2 project (const Vec4 &pt3D, bool applyDistortion=true) const =0
 Projection of a 3D point into the camera plane (Apply 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)
 
virtual Eigen::Matrix< double, 2, 3 > getDerivativeTransformProjectWrtPoint3 (const Eigen::Matrix4d &pose, const Vec4 &pt3D) const =0
 Get the derivative of a projection of a 3D point into the camera plane. More...
 
virtual Eigen::Matrix< double, 2, Eigen::Dynamic > getDerivativeTransformProjectWrtParams (const Eigen::Matrix4d &pos, const Vec4 &pt3D) const =0
 Get the derivative of a projection of a 3D point into the camera plane. More...
 
virtual Eigen::Matrix< double, 3, Eigen::Dynamic > getDerivativeBackProjectUnitWrtParams (const Vec2 &pt2D) const =0
 Get the derivative of the unit sphere backprojection. More...
 
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...
 
virtual IntrinsicBaseclone () const =0
 Polymorphic clone.
 
virtual void assign (const IntrinsicBase &other)=0
 Assign object. More...
 
virtual EINTRINSIC getType () const =0
 Get embed camera type. More...
 
std::string getTypeStr () const
 Get the string describing the intrinsic type. More...
 
virtual std::vector< double > getParameters () const =0
 Get the intrinsic parameters. More...
 
virtual std::size_t getParametersSize () const =0
 Get the count of intrinsic parameters. More...
 
virtual bool hasDistortion () const
 Camera model handles a distortion field. More...
 
virtual Vec2 addDistortion (const Vec2 &p) const =0
 Add the distortion field to a point (that is in normalized camera frame) More...
 
virtual Vec2 removeDistortion (const Vec2 &p) const =0
 Remove the distortion to a camera point (that is in normalized camera frame) More...
 
virtual Vec2 getUndistortedPixel (const Vec2 &p) const =0
 Return the undistorted pixel (with removed distortion) More...
 
virtual Vec2 getDistortedPixel (const Vec2 &p) const =0
 Return the distorted pixel (with added distortion) More...
 
virtual void setDistortionInitializationMode (EInitMode distortionInitializationMode)=0
 Set The intrinsic disto initialization mode. More...
 
virtual EInitMode getDistortionInitializationMode () const =0
 Get the intrinsic disto initialization mode. More...
 
virtual double imagePlaneToCameraPlaneError (double value) const =0
 Normalize a given unit pixel error to the camera plane. More...
 
virtual double pixelProbability () const =0
 What is the probability of a pixel wrt the whole fov. More...
 
virtual bool isValid () const
 Return true if the intrinsic is valid. More...
 
virtual bool isVisibleRay (const Vec3 &ray) const =0
 Return true if this ray should be visible in the image. 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 Vec3 toUnitSphere (const Vec2 &pt) const =0
 Transform a given point (in pixels) to unit sphere in meters. More...
 
virtual double getHorizontalFov () const =0
 Get the horizontal FOV in radians. More...
 
virtual double getVerticalFov () const =0
 Get the vertical FOV in radians. 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< IntrinsicScaleOffsetcast (std::shared_ptr< IntrinsicBase > sptr)
 

Protected Attributes

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
 

Additional Inherited Members

- Public Types inherited from aliceVision::camera::IntrinsicBase
using sptr = std::shared_ptr< IntrinsicBase >
 
using ptr = IntrinsicBase *
 

Detailed Description

Class with "focal" (scale) and center offset.

Member Function Documentation

◆ cam2ima()

Vec2 aliceVision::camera::IntrinsicScaleOffset::cam2ima ( const Vec2 &  p) const
overridevirtual

Transform a point from the camera plane to the image plane.

Parameters
[in]pA point from the camera plane
Returns
Image plane point

Implements aliceVision::camera::IntrinsicBase.

◆ getFocalLength()

double aliceVision::camera::IntrinsicScaleOffset::getFocalLength ( ) const

get focal length in mm

Returns
focal length in mm

◆ getInitialFocalLength()

double aliceVision::camera::IntrinsicScaleOffset::getInitialFocalLength ( ) const

get initial focal length in mm

Returns
initial focal length in mm

◆ getInitialScale()

Vec2 aliceVision::camera::IntrinsicScaleOffset::getInitialScale ( ) const
inline

Get the intrinsic initial scale.

Returns
The intrinsic initial scale

◆ getPixelAspectRatio()

double aliceVision::camera::IntrinsicScaleOffset::getPixelAspectRatio ( ) const

estimate the pixel aspect ratio

Returns
the pixel aspect ratio

◆ ima2cam()

Vec2 aliceVision::camera::IntrinsicScaleOffset::ima2cam ( const Vec2 &  p) const
overridevirtual

Transform a point from the image plane to the camera plane.

Parameters
[in]pA point from the image plane
Returns
Camera plane point

Implements aliceVision::camera::IntrinsicBase.

◆ importFromParams()

bool aliceVision::camera::IntrinsicScaleOffset::importFromParams ( const std::vector< double > &  params,
const Version inputVersion 
)
overridevirtual

Import a vector of params loaded from a file. It is similar to updateFromParams but it deals with file compatibility.

Parameters
[in]paramsa vector containing the intrinsic's parameters
[in]inputVersion
Returns
True if the parameters were correctly updated, false otherwise

Implements aliceVision::camera::IntrinsicBase.

◆ operator==()

bool aliceVision::camera::IntrinsicScaleOffset::operator== ( const IntrinsicBase other) const
overridevirtual

operator ==

Parameters
[in]other
Returns
True if equals

Reimplemented from aliceVision::camera::IntrinsicBase.

Reimplemented in aliceVision::camera::IntrinsicScaleOffsetDisto.

◆ rescale()

void aliceVision::camera::IntrinsicScaleOffset::rescale ( float  factorW,
float  factorH 
)
overridevirtual

Rescale intrinsics to reflect a rescale of the camera image.

Parameters
factorWa scale factor for Width
factorHa scale factor for Height

Reimplemented from aliceVision::camera::IntrinsicBase.

◆ setFocalLength()

void aliceVision::camera::IntrinsicScaleOffset::setFocalLength ( double  focalLengthMM,
double  pixelAspectRatio,
bool  useCompatibility = false 
)

@Brief set scale given focal length and pixelaspectratio

Parameters
focalLengthMMfocal length in mm
pixelAspectRatiopixel aspect ratio (image with = pixelAspectRatio * realwidth)
usePixelRatioForXuse pixel ratio

◆ setInitialFocalLength()

void aliceVision::camera::IntrinsicScaleOffset::setInitialFocalLength ( double  initialFocalLengthMM,
double  pixelAspectRatio,
bool  useCompatibility = false 
)

@Brief set initial scale given initial focal length and pixelaspectratio

Parameters
initialFocalLengthMMinitial focal length in mm
pixelAspectRatiopixel aspect ratio (image with = pixelAspectRatio * realwidth)
useCompabilitymake sure compatibility mode is used

◆ setOffsetLocked()

void aliceVision::camera::IntrinsicScaleOffset::setOffsetLocked ( bool  lock)
inline

Lock the offset.

Parameters
lockTrue if the offset is locked, false otherwise

◆ setRatioLocked()

void aliceVision::camera::IntrinsicScaleOffset::setRatioLocked ( bool  lock)
inline

Lock the ratio between fx and fy.

Parameters
lockTrue if the ratio is locked, false otherwise

◆ setScaleLocked()

void aliceVision::camera::IntrinsicScaleOffset::setScaleLocked ( bool  lock)
inline

Lock the scale.

Parameters
lockTrue if the scale is locked, false otherwise

◆ updateFromParams()

bool aliceVision::camera::IntrinsicScaleOffset::updateFromParams ( const std::vector< double > &  params)
overridevirtual

Update intrinsic parameters.

Parameters
[in]intrinsicparameters
Returns
True if the parameters were successfully updated, false otherwise

Implements aliceVision::camera::IntrinsicBase.

Reimplemented in aliceVision::camera::IntrinsicScaleOffsetDisto.


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