Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Static Public Member Functions
mrpt::utils::TCamera Class Reference

Detailed Description

Structure to hold the parameters of a pinhole camera model.

The parameters obtained for one camera resolution can be used for any other resolution by means of the method TCamera::scaleToResolution()

See also
mrpt::vision::CCamModel, the application camera-calib-gui for calibrating a camera

Definition at line 32 of file TCamera.h.

#include <mrpt/utils/TCamera.h>

Inheritance diagram for mrpt::utils::TCamera:
Inheritance graph

Public Member Functions

voidoperator new (size_t size)
 
voidoperator new[] (size_t size)
 
void operator delete (void *ptr) noexcept
 
void operator delete[] (void *ptr) noexcept
 
void operator delete (void *memory, void *ptr) noexcept
 
voidoperator new (size_t size, const std::nothrow_t &) noexcept
 
void operator delete (void *ptr, const std::nothrow_t &) noexcept
 
 TCamera ()
 
void scaleToResolution (unsigned int new_ncols, unsigned int new_nrows)
 Rescale all the parameters for a new camera resolution (it raises an exception if the aspect ratio is modified, which is not permitted). More...
 
void saveToConfigFile (const std::string &section, mrpt::utils::CConfigFileBase &cfg) const
 Save as a config block: More...
 
void loadFromConfigFile (const std::string &section, const mrpt::utils::CConfigFileBase &cfg)
 Load all the params from a config source, in the format used in saveToConfigFile(), that is: More...
 
void loadFromConfigFile (const mrpt::utils::CConfigFileBase &cfg, const std::string &section)
 overload This signature is consistent with the rest of MRPT APIs More...
 
std::string dumpAsText () const
 Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile. More...
 
void setIntrinsicParamsFromValues (double fx, double fy, double cx, double cy)
 Set the matrix of intrinsic params of the camera from the individual values of focal length and principal point coordinates (in pixels) More...
 
void getDistortionParamsVector (mrpt::math::CMatrixDouble15 &distParVector) const
 Get the vector of distortion params of the camera. More...
 
std::vector< double > getDistortionParamsAsVector () const
 Get a vector with the distortion params of the camera. More...
 
void setDistortionParamsVector (const mrpt::math::CMatrixDouble15 &distParVector)
 Set the whole vector of distortion params of the camera. More...
 
template<class VECTORLIKE >
void setDistortionParamsVector (const VECTORLIKE &distParVector)
 Set the whole vector of distortion params of the camera from a 4 or 5-vector. More...
 
void setDistortionParamsFromValues (double k1, double k2, double p1, double p2, double k3=0)
 Set the vector of distortion params of the camera from the individual values of the distortion coefficients. More...
 
double cx () const
 Get the value of the principal point x-coordinate (in pixels). More...
 
double cy () const
 Get the value of the principal point y-coordinate (in pixels). More...
 
double fx () const
 Get the value of the focal length x-value (in pixels). More...
 
double fy () const
 Get the value of the focal length y-value (in pixels). More...
 
void cx (double val)
 Set the value of the principal point x-coordinate (in pixels). More...
 
void cy (double val)
 Set the value of the principal point y-coordinate (in pixels). More...
 
void fx (double val)
 Set the value of the focal length x-value (in pixels). More...
 
void fy (double val)
 Set the value of the focal length y-value (in pixels). More...
 
double k1 () const
 Get the value of the k1 distortion parameter. More...
 
double k2 () const
 Get the value of the k2 distortion parameter. More...
 
double p1 () const
 Get the value of the p1 distortion parameter. More...
 
double p2 () const
 Get the value of the p2 distortion parameter. More...
 
double k3 () const
 Get the value of the k3 distortion parameter. More...
 
void k1 (double val)
 Get the value of the k1 distortion parameter. More...
 
void k2 (double val)
 Get the value of the k2 distortion parameter. More...
 
void p1 (double val)
 Get the value of the p1 distortion parameter. More...
 
void p2 (double val)
 Get the value of the p2 distortion parameter. More...
 
void k3 (double val)
 Get the value of the k3 distortion parameter. More...
 
virtual mxArraywriteToMatlab () const
 Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More...
 
RTTI classes and functions
mrpt::utils::CObject::Ptr duplicateGetSmartPtr () const
 Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer). More...
 

Static Public Member Functions

static voidoperator new (size_t size, void *ptr)
 

Public Attributes

Camera parameters
uint32_t ncols
 Camera resolution. More...
 
uint32_t nrows
 
mrpt::math::CMatrixDouble33 intrinsicParams
 Matrix of intrinsic parameters (containing the focal length and principal point coordinates) More...
 
mrpt::math::CArrayDouble< 5 > dist
 [k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (default=0) More...
 
double focalLengthMeters
 The focal length of the camera, in meters (can be used among 'intrinsicParams' to determine the pixel size). More...
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const override
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version) override
 Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori. More...
 

RTTI stuff

using Ptr = std::shared_ptr< TCamera >
 
using ConstPtr = std::shared_ptr< const TCamera >
 
static mrpt::utils::CLASSINIT _init_TCamera
 
static const mrpt::utils::TRuntimeClassId runtimeClassId
 
static constexpr const char * className = "TCamera"
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
static const mrpt::utils::TRuntimeClassIdGetRuntimeClassIdStatic ()
 
static mrpt::utils::CObjectCreateObject ()
 
template<typename... Args>
static Ptr Create (Args &&... args)
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const override
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectclone () const override
 Returns a deep copy (clone) of the object, indepently of its class. More...
 

Member Typedef Documentation

◆ ConstPtr

using mrpt::utils::TCamera::ConstPtr = std::shared_ptr<const TCamera >

Definition at line 34 of file TCamera.h.

◆ Ptr

using mrpt::utils::TCamera::Ptr = std::shared_ptr< TCamera >

A typedef for the associated smart pointer

Definition at line 34 of file TCamera.h.

Constructor & Destructor Documentation

◆ TCamera()

mrpt::utils::TCamera::TCamera ( )
inline

Definition at line 40 of file TCamera.h.

References dist, and intrinsicParams.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId* mrpt::utils::TCamera::_GetBaseClass ( )
staticprotected

◆ clone()

virtual mrpt::utils::CObject* mrpt::utils::TCamera::clone ( ) const
overridevirtual

Returns a deep copy (clone) of the object, indepently of its class.

Implements mrpt::utils::CObject.

◆ Create()

template<typename... Args>
static Ptr mrpt::utils::TCamera::Create ( Args &&...  args)
inlinestatic

Definition at line 34 of file TCamera.h.

◆ CreateObject()

static mrpt::utils::CObject* mrpt::utils::TCamera::CreateObject ( )
static

◆ cx() [1/2]

double mrpt::utils::TCamera::cx ( ) const
inline

◆ cx() [2/2]

void mrpt::utils::TCamera::cx ( double  val)
inline

Set the value of the principal point x-coordinate (in pixels).

Definition at line 182 of file TCamera.h.

References intrinsicParams, and val.

◆ cy() [1/2]

double mrpt::utils::TCamera::cy ( ) const
inline

◆ cy() [2/2]

void mrpt::utils::TCamera::cy ( double  val)
inline

Set the value of the principal point y-coordinate (in pixels).

Definition at line 184 of file TCamera.h.

References intrinsicParams, and val.

◆ dumpAsText()

std::string TCamera::dumpAsText ( ) const

Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.

See also
saveToConfigFile

Definition at line 27 of file TCamera.cpp.

References mrpt::utils::CConfigFileMemory::getContent().

Here is the call graph for this function:

◆ fx() [1/2]

double mrpt::utils::TCamera::fx ( ) const
inline

◆ fx() [2/2]

void mrpt::utils::TCamera::fx ( double  val)
inline

Set the value of the focal length x-value (in pixels).

Definition at line 186 of file TCamera.h.

References intrinsicParams, and val.

◆ fy() [1/2]

double mrpt::utils::TCamera::fy ( ) const
inline

◆ fy() [2/2]

void mrpt::utils::TCamera::fy ( double  val)
inline

Set the value of the focal length y-value (in pixels).

Definition at line 188 of file TCamera.h.

References intrinsicParams, and val.

◆ getDistortionParamsAsVector()

std::vector<double> mrpt::utils::TCamera::getDistortionParamsAsVector ( ) const
inline

Get a vector with the distortion params of the camera.

Definition at line 135 of file TCamera.h.

References dist.

Referenced by mrpt::vision::checkerBoardCameraCalibration(), and mrpt::vision::CCamModel::undistort_point().

Here is the caller graph for this function:

◆ getDistortionParamsVector()

void mrpt::utils::TCamera::getDistortionParamsVector ( mrpt::math::CMatrixDouble15 distParVector) const
inline

Get the vector of distortion params of the camera.

Definition at line 128 of file TCamera.h.

References dist.

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId* mrpt::utils::TCamera::GetRuntimeClass ( ) const
overridevirtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

◆ GetRuntimeClassIdStatic()

static const mrpt::utils::TRuntimeClassId& mrpt::utils::TCamera::GetRuntimeClassIdStatic ( )
static

◆ k1() [1/2]

double mrpt::utils::TCamera::k1 ( ) const
inline

◆ k1() [2/2]

void mrpt::utils::TCamera::k1 ( double  val)
inline

Get the value of the k1 distortion parameter.

Definition at line 200 of file TCamera.h.

References dist, and val.

◆ k2() [1/2]

double mrpt::utils::TCamera::k2 ( ) const
inline

◆ k2() [2/2]

void mrpt::utils::TCamera::k2 ( double  val)
inline

Get the value of the k2 distortion parameter.

Definition at line 202 of file TCamera.h.

References dist, and val.

◆ k3() [1/2]

double mrpt::utils::TCamera::k3 ( ) const
inline

◆ k3() [2/2]

void mrpt::utils::TCamera::k3 ( double  val)
inline

Get the value of the k3 distortion parameter.

Definition at line 208 of file TCamera.h.

References dist, and val.

◆ loadFromConfigFile() [1/2]

void TCamera::loadFromConfigFile ( const std::string section,
const mrpt::utils::CConfigFileBase cfg 
)

Load all the params from a config source, in the format used in saveToConfigFile(), that is:

Load all the params from a config source, in the format described in saveToConfigFile()

[SECTION]
resolution = [NCOLS NROWS]
cx = CX
cy = CY
fx = FX
fy = FY
dist = [K1 K2 T1 T2 K3]
focal_length = FOCAL_LENGTH [optional field]
Exceptions
std::exceptionon missing fields

Definition at line 138 of file TCamera.cpp.

References mrpt::utils::CConfigFileBase::read_double(), mrpt::utils::CConfigFileBase::read_vector(), and THROW_EXCEPTION.

Referenced by mrpt::hwdrivers::CRovio::loadConfig(), mrpt::hwdrivers::CSwissRanger3DCamera::loadConfig_sensorSpecific(), and loadFromConfigFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromConfigFile() [2/2]

void mrpt::utils::TCamera::loadFromConfigFile ( const mrpt::utils::CConfigFileBase cfg,
const std::string section 
)
inline

overload This signature is consistent with the rest of MRPT APIs

Definition at line 105 of file TCamera.h.

References loadFromConfigFile().

Here is the call graph for this function:

◆ operator delete() [1/3]

void mrpt::utils::TCamera::operator delete ( void ptr)
inlinenoexcept

Definition at line 34 of file TCamera.h.

◆ operator delete() [2/3]

void mrpt::utils::TCamera::operator delete ( void memory,
void ptr 
)
inlinenoexcept

Definition at line 34 of file TCamera.h.

◆ operator delete() [3/3]

void mrpt::utils::TCamera::operator delete ( void ptr,
const std::nothrow_t &   
)
inlinenoexcept

Definition at line 34 of file TCamera.h.

◆ operator delete[]()

void mrpt::utils::TCamera::operator delete[] ( void ptr)
inlinenoexcept

Definition at line 34 of file TCamera.h.

◆ operator new() [1/3]

static void* mrpt::utils::TCamera::operator new ( size_t  size,
void ptr 
)
inlinestatic

Definition at line 34 of file TCamera.h.

◆ operator new() [2/3]

void* mrpt::utils::TCamera::operator new ( size_t  size,
const std::nothrow_t &   
)
inlinenoexcept

Definition at line 34 of file TCamera.h.

◆ operator new() [3/3]

void* mrpt::utils::TCamera::operator new ( size_t  size)
inline

Definition at line 34 of file TCamera.h.

◆ operator new[]()

void* mrpt::utils::TCamera::operator new[] ( size_t  size)
inline

Definition at line 34 of file TCamera.h.

◆ p1() [1/2]

double mrpt::utils::TCamera::p1 ( ) const
inline

◆ p1() [2/2]

void mrpt::utils::TCamera::p1 ( double  val)
inline

Get the value of the p1 distortion parameter.

Definition at line 204 of file TCamera.h.

References dist, and val.

◆ p2() [1/2]

double mrpt::utils::TCamera::p2 ( ) const
inline

◆ p2() [2/2]

void mrpt::utils::TCamera::p2 ( double  val)
inline

Get the value of the p2 distortion parameter.

Definition at line 206 of file TCamera.h.

References dist, and val.

◆ readFromStream()

void TCamera::readFromStream ( mrpt::utils::CStream in,
int  version 
)
overrideprotectedvirtual

Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.

Parameters
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions
std::exceptionOn any error, see CStream::ReadBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 50 of file TCamera.cpp.

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION.

◆ saveToConfigFile()

void TCamera::saveToConfigFile ( const std::string section,
mrpt::utils::CConfigFileBase cfg 
) const

Save as a config block:

[SECTION]
resolution = [NCOLS NROWS]
cx = CX
cy = CY
fx = FX
fy = FY
dist = [K1 K2 T1 T2 K3]
focal_length = FOCAL_LENGTH
[SECTION]
resolution = NCOLS NROWS
cx = CX
cy = CY
fx = FX
fy = FY
dist = K1 K2 T1 T2 T3
focal_length = FOCAL_LENGTH

Definition at line 117 of file TCamera.cpp.

References mrpt::format(), and mrpt::utils::CConfigFileBase::write().

Referenced by mrpt::vision::checkerBoardCameraCalibration(), and mrpt::obs::CObservation3DRangeScan::getDescriptionAsText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaleToResolution()

void TCamera::scaleToResolution ( unsigned int  new_ncols,
unsigned int  new_nrows 
)

Rescale all the parameters for a new camera resolution (it raises an exception if the aspect ratio is modified, which is not permitted).

Definition at line 176 of file TCamera.cpp.

References ASSERT_, and ASSERTMSG_.

Referenced by mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation(), and mrpt::utils::TStereoCamera::scaleToResolution().

Here is the caller graph for this function:

◆ setDistortionParamsFromValues()

void mrpt::utils::TCamera::setDistortionParamsFromValues ( double  k1,
double  k2,
double  p1,
double  p2,
double  k3 = 0 
)
inline

Set the vector of distortion params of the camera from the individual values of the distortion coefficients.

Definition at line 163 of file TCamera.h.

References dist, k1(), k2(), k3(), p1(), and p2().

Referenced by mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_int_params_from_yml(), and mrpt::hwdrivers::CRovio::TOptions::TOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDistortionParamsVector() [1/2]

void mrpt::utils::TCamera::setDistortionParamsVector ( const mrpt::math::CMatrixDouble15 distParVector)
inline

Set the whole vector of distortion params of the camera.

Definition at line 143 of file TCamera.h.

References dist.

Referenced by mrpt::vision::CCamModel::loadFromConfigFile().

Here is the caller graph for this function:

◆ setDistortionParamsVector() [2/2]

template<class VECTORLIKE >
void mrpt::utils::TCamera::setDistortionParamsVector ( const VECTORLIKE &  distParVector)
inline

Set the whole vector of distortion params of the camera from a 4 or 5-vector.

Definition at line 152 of file TCamera.h.

References ASSERT_, and dist.

◆ setIntrinsicParamsFromValues()

void mrpt::utils::TCamera::setIntrinsicParamsFromValues ( double  fx,
double  fy,
double  cx,
double  cy 
)
inline

Set the matrix of intrinsic params of the camera from the individual values of focal length and principal point coordinates (in pixels)

Definition at line 118 of file TCamera.h.

References cx(), cy(), fx(), fy(), and intrinsicParams.

Referenced by mrpt::hwdrivers::CImageGrabber_FlyCapture2::getObservation(), mrpt::vision::CCamModel::loadFromConfigFile(), and mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_int_params_from_yml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeToMatlab()

virtual mxArray* mrpt::utils::CSerializable::writeToMatlab ( ) const
inlinevirtualinherited

Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.

Returns
A new mxArray (caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB.

Definition at line 89 of file CSerializable.h.

◆ writeToStream()

void TCamera::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
overrideprotectedvirtual

Introduces a pure virtual method responsible for writing to a CStream.

This can not be used directly be users, instead use "stream << object;" for writing it to a stream.

Parameters
outThe output binary stream where object must be dumped.
getVersionIf nullptr, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data.
Exceptions
std::exceptionOn any error, see CStream::WriteBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 35 of file TCamera.cpp.

Member Data Documentation

◆ _init_TCamera

mrpt::utils::CLASSINIT mrpt::utils::TCamera::_init_TCamera
staticprotected

Definition at line 34 of file TCamera.h.

◆ className

constexpr const char* mrpt::utils::TCamera::className = "TCamera"
static

Definition at line 34 of file TCamera.h.

◆ dist

mrpt::math::CArrayDouble<5> mrpt::utils::TCamera::dist

◆ focalLengthMeters

double mrpt::utils::TCamera::focalLengthMeters

The focal length of the camera, in meters (can be used among 'intrinsicParams' to determine the pixel size).

Definition at line 63 of file TCamera.h.

Referenced by mrpt::obs::CObservationStereoImages::readFromStream(), mrpt::obs::CObservation3DRangeScan::recoverCameraCalibrationParameters(), and mrpt::vision::CStereoRectifyMap::setFromCamParams().

◆ intrinsicParams

mrpt::math::CMatrixDouble33 mrpt::utils::TCamera::intrinsicParams

◆ ncols

uint32_t mrpt::utils::TCamera::ncols

◆ nrows

uint32_t mrpt::utils::TCamera::nrows

◆ runtimeClassId

const mrpt::utils::TRuntimeClassId mrpt::utils::TCamera::runtimeClassId
staticprotected

Definition at line 34 of file TCamera.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019