This class represent a pinhole camera model for Monocular SLAM and implements some associated Jacobians.
The camera parameters are accessible in the public member CCamModel::cam
Definition at line 36 of file CCamModel.h.
#include <mrpt/vision/CCamModel.h>
Classes | |
struct | CameraTempVariables |
Public Member Functions | |
CCamModel () | |
Default Constructor. More... | |
void | loadFromConfigFile (const mrpt::utils::CConfigFileBase &source, const std::string §ion) override |
This method load the options from a ".ini"-like file or memory-stored string list. More... | |
void | dumpToTextStream (mrpt::utils::CStream &out) const override |
This method displays clearly all the contents of the structure in textual form, sending it to a CStream. More... | |
CCamModel (const mrpt::utils::CConfigFileBase &cfgIni) | |
Constructor from a ini file. More... | |
void | jacob_undistor_fm (const mrpt::utils::TPixelCoordf &uvd, math::CMatrixDouble &J_undist) |
Jacobian for undistortion the image coordinates. More... | |
void | jacob_undistor (const mrpt::utils::TPixelCoordf &p, mrpt::math::CMatrixDouble &J_undist) |
Calculate the image coordinates undistorted. More... | |
void | distort_a_point (const mrpt::utils::TPixelCoordf &p, mrpt::utils::TPixelCoordf &distorted_p) |
Return the pixel position distorted by the camera. More... | |
void | undistort_point (const mrpt::utils::TPixelCoordf &p, mrpt::utils::TPixelCoordf &undistorted_p) |
Return the pixel position undistorted by the camera The input values 'col' and 'row' will be replace for the new values (undistorted) More... | |
void | project_3D_point (const mrpt::math::TPoint3D &p3D, mrpt::utils::TPixelCoordf &distorted_p) const |
Return the (distorted) pixel position of a 3D point given in coordinates relative to the camera (+Z pointing forward, +X to the right) More... | |
void | unproject_3D_point (const mrpt::utils::TPixelCoordf &distorted_p, mrpt::math::TPoint3D &p3D) const |
Return the 3D location of a point (at a fixed distance z=1), for the given (distorted) pixel position. More... | |
void | jacobian_project_with_distortion (const mrpt::math::TPoint3D &p3D, math::CMatrixDouble &dh_dy) const |
Jacobian of the projection of 3D points (with distortion), as done in project_3D_point , evaluated at the point p3D (read below the full explanation) More... | |
void | jacobian_unproject_with_distortion (const mrpt::utils::TPixelCoordf &p, math::CMatrixDouble &dy_dh) const |
Jacobian of the unprojection of a pixel (with distortion) back into a 3D point, as done in unproject_3D_point , evaluated at the pixel p. More... | |
template<typename T , typename POINT > | |
void | getTemporaryVariablesForTransform (const POINT &p, CameraTempVariables< T > &v) const |
template<typename T , typename POINT , typename PIXEL > | |
void | getFullProjection (const POINT &pIn, PIXEL &pOut) const |
template<typename T , typename PIXEL > | |
void | getFullProjectionT (const CameraTempVariables< T > &tmp, PIXEL &pOut) const |
template<typename T , typename POINT , typename MATRIX > | |
void | getFullJacobian (const POINT &pIn, MATRIX &mOut) const |
template<typename T , typename POINT , typename MATRIX > | |
void | getFullJacobianT (const POINT &pIn, const CameraTempVariables< T > &tmp, MATRIX &mOut) const |
template<typename POINTIN , typename POINTOUT , typename MAT22 > | |
void | getFullInverseModelWithJacobian (const POINTIN &pIn, POINTOUT &pOut, MAT22 &jOut) const |
void | loadFromConfigFileName (const std::string &config_file, const std::string §ion) |
Behaves like loadFromConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to load the file. More... | |
virtual void | saveToConfigFile (mrpt::utils::CConfigFileBase &target, const std::string §ion) const |
This method saves the options to a ".ini"-like file or memory-stored string list. More... | |
void | saveToConfigFileName (const std::string &config_file, const std::string §ion) const |
Behaves like saveToConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to save the file. More... | |
void | dumpToConsole () const |
Just like dumpToTextStream() but sending the text to the console (std::cout) More... | |
Public Attributes | |
mrpt::utils::TCamera | cam |
The parameters of a camera. More... | |
Static Protected Member Functions | |
static void | dumpVar_int (CStream &out, const char *varName, int v) |
Used to print variable info from dumpToTextStream with the macro LOADABLEOPTS_DUMP_VAR. More... | |
static void | dumpVar_float (CStream &out, const char *varName, float v) |
static void | dumpVar_double (CStream &out, const char *varName, double v) |
static void | dumpVar_bool (CStream &out, const char *varName, bool v) |
static void | dumpVar_string (CStream &out, const char *varName, const std::string &v) |
Private Member Functions | |
mrpt::math::CMatrixFixedNumeric< double, 2, 2 > | firstInverseJacobian () const |
mrpt::math::CMatrixFixedNumeric< double, 4, 2 > | secondInverseJacobian () const |
mrpt::math::CMatrixFixedNumeric< double, 3, 4 > | thirdInverseJacobian () const |
CCamModel::CCamModel | ( | ) |
mrpt::vision::CCamModel::CCamModel | ( | const mrpt::utils::CConfigFileBase & | cfgIni | ) |
Constructor from a ini file.
void CCamModel::distort_a_point | ( | const mrpt::utils::TPixelCoordf & | p, |
mrpt::utils::TPixelCoordf & | distorted_p | ||
) |
Return the pixel position distorted by the camera.
Definition at line 103 of file CCamModel.cpp.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::k1(), mrpt::math::square(), mrpt::utils::TPixelCoordf::x, and mrpt::utils::TPixelCoordf::y.
|
inherited |
Just like dumpToTextStream() but sending the text to the console (std::cout)
Definition at line 44 of file CLoadableOptions.cpp.
References mrpt::utils::CLoadableOptions::dumpToTextStream(), and loadable_opts_my_cout.
Referenced by mrpt::hmtslam::CTopLCDetector_GridMatching::computeTopologicalObservationModel(), and mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::printParams().
|
overridevirtual |
This method displays clearly all the contents of the structure in textual form, sending it to a CStream.
Reimplemented from mrpt::utils::CLoadableOptions.
Definition at line 332 of file CCamModel.cpp.
References MRPT_UNUSED_PARAM.
|
staticprotectedinherited |
Definition at line 65 of file CLoadableOptions.cpp.
References LOADABLEOPTS_COLUMN_WIDTH, and mrpt::utils::CStream::printf().
|
staticprotectedinherited |
Definition at line 59 of file CLoadableOptions.cpp.
References LOADABLEOPTS_COLUMN_WIDTH, and mrpt::utils::CStream::printf().
|
staticprotectedinherited |
Definition at line 54 of file CLoadableOptions.cpp.
References LOADABLEOPTS_COLUMN_WIDTH, and mrpt::utils::CStream::printf().
|
staticprotectedinherited |
Used to print variable info from dumpToTextStream with the macro LOADABLEOPTS_DUMP_VAR.
Definition at line 49 of file CLoadableOptions.cpp.
References LOADABLEOPTS_COLUMN_WIDTH, and mrpt::utils::CStream::printf().
|
staticprotectedinherited |
Definition at line 71 of file CLoadableOptions.cpp.
References LOADABLEOPTS_COLUMN_WIDTH, and mrpt::utils::CStream::printf().
|
inlineprivate |
Definition at line 251 of file CCamModel.h.
Referenced by getFullInverseModelWithJacobian().
|
inline |
Definition at line 283 of file CCamModel.h.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), firstInverseJacobian(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), mrpt::utils::TCamera::k2(), mrpt::utils::TCamera::k3(), mrpt::utils::TCamera::p1(), mrpt::utils::TCamera::p2(), secondInverseJacobian(), mrpt::mrpt::math::square(), mrpt::math::square(), and thirdInverseJacobian().
|
inline |
Definition at line 200 of file CCamModel.h.
References getFullJacobianT(), and getTemporaryVariablesForTransform().
|
inline |
Definition at line 208 of file CCamModel.h.
References cam, mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::vision::CCamModel::CameraTempVariables< T >::K, mrpt::utils::TCamera::k1(), mrpt::utils::TCamera::k2(), mrpt::utils::TCamera::k3(), mrpt::utils::TCamera::p1(), mrpt::utils::TCamera::p2(), mrpt::vision::CCamModel::CameraTempVariables< T >::R, mrpt::math::square(), mrpt::vision::CCamModel::CameraTempVariables< T >::x_, and mrpt::vision::CCamModel::CameraTempVariables< T >::y_.
Referenced by getFullJacobian().
|
inline |
Definition at line 184 of file CCamModel.h.
References getFullProjectionT(), and getTemporaryVariablesForTransform().
|
inline |
Definition at line 192 of file CCamModel.h.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::vision::CCamModel::CameraTempVariables< T >::x__, and mrpt::vision::CCamModel::CameraTempVariables< T >::y__.
Referenced by getFullProjection().
|
inline |
Definition at line 169 of file CCamModel.h.
References cam, mrpt::utils::TCamera::k1(), mrpt::utils::TCamera::k2(), mrpt::utils::TCamera::k3(), mrpt::utils::TCamera::p1(), mrpt::utils::TCamera::p2(), and mrpt::math::square().
Referenced by getFullJacobian(), and getFullProjection().
void CCamModel::jacob_undistor | ( | const mrpt::utils::TPixelCoordf & | p, |
mrpt::math::CMatrixDouble & | J_undist | ||
) |
Calculate the image coordinates undistorted.
Definition at line 56 of file CCamModel.cpp.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::k1(), and mrpt::math::square().
void CCamModel::jacob_undistor_fm | ( | const mrpt::utils::TPixelCoordf & | uvd, |
math::CMatrixDouble & | J_undist | ||
) |
Jacobian for undistortion the image coordinates.
Definition at line 25 of file CCamModel.cpp.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), and mrpt::utils::TCamera::k2().
void CCamModel::jacobian_project_with_distortion | ( | const mrpt::math::TPoint3D & | p3D, |
math::CMatrixDouble & | dh_dy | ||
) | const |
Jacobian of the projection of 3D points (with distortion), as done in project_3D_point , evaluated at the point p3D (read below the full explanation)
We define as the projected point in pixels (origin at the top-left corner), and as the 3D point in space, in coordinates relative to the camera (+Z pointing forwards).
Then this method computes the 2x3 Jacobian:
With:
where is the focal length in units of pixel sizes in x and y, respectively. And, if we define:
then:
Definition at line 200 of file CCamModel.cpp.
References ASSERT_, cam, mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), mrpt::math::square(), mrpt::math::TPoint3D::x, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.
void CCamModel::jacobian_unproject_with_distortion | ( | const mrpt::utils::TPixelCoordf & | p, |
math::CMatrixDouble & | dy_dh | ||
) | const |
Jacobian of the unprojection of a pixel (with distortion) back into a 3D point, as done in unproject_3D_point , evaluated at the pixel p.
Definition at line 265 of file CCamModel.cpp.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), and mrpt::math::square().
|
overridevirtual |
This method load the options from a ".ini"-like file or memory-stored string list.
Only those parameters found in the given "section" and having the same name that the variable are loaded. Those not found in the file will stay with their previous values (usually the default values loaded at initialization). An example of an ".ini" file:
Implements mrpt::utils::CLoadableOptions.
Definition at line 300 of file CCamModel.cpp.
References ASSERT_, cam, MRPT_END, MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT, MRPT_START, mrpt::utils::TCamera::setDistortionParamsVector(), and mrpt::utils::TCamera::setIntrinsicParamsFromValues().
|
inherited |
Behaves like loadFromConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to load the file.
Definition at line 22 of file CLoadableOptions.cpp.
References mrpt::utils::CLoadableOptions::loadFromConfigFile().
Referenced by mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::loadParams().
void CCamModel::project_3D_point | ( | const mrpt::math::TPoint3D & | p3D, |
mrpt::utils::TPixelCoordf & | distorted_p | ||
) | const |
Return the (distorted) pixel position of a 3D point given in coordinates relative to the camera (+Z pointing forward, +X to the right)
Definition at line 150 of file CCamModel.cpp.
References ASSERT_, cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), mrpt::math::square(), mrpt::utils::TPixelCoordf::x, mrpt::math::TPoint3D::x, mrpt::utils::TPixelCoordf::y, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.
|
virtualinherited |
This method saves the options to a ".ini"-like file or memory-stored string list.
Reimplemented in mrpt::vision::TMultiResDescOptions, mrpt::vision::TMultiResDescMatchOptions, mrpt::nav::CPTG_RobotShape_Circular, mrpt::nav::CPTG_RobotShape_Polygonal, mrpt::nav::CParameterizedTrajectoryGenerator, mrpt::nav::CAbstractPTGBasedReactive::TAbstractPTGNavigatorParams, mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams, mrpt::nav::CPTG_DiffDrive_CollisionGridBased, mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams, mrpt::nav::CHolonomicFullEval::TOptions, mrpt::bayes::CParticleFilter::TParticleFilterOptions, mrpt::nav::CReactiveNavigationSystem::TReactiveNavigatorParams, mrpt::nav::CHolonomicND::TOptions, mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase, mrpt::nav::CHolonomicVFF::TOptions, mrpt::maps::CPointCloudFilterByDistance::TOptions, mrpt::nav::CPTG_DiffDrive_C, mrpt::nav::CPTG_DiffDrive_alpha, mrpt::nav::CMultiObjMotionOpt_Scalarization::TParams, mrpt::nav::CPTG_DiffDrive_CC, mrpt::nav::CPTG_DiffDrive_CCS, mrpt::nav::CPTG_DiffDrive_CS, and mrpt::nav::CPTG_Holo_Blend.
Definition at line 29 of file CLoadableOptions.cpp.
References MRPT_UNUSED_PARAM.
Referenced by mrpt::utils::CLoadableOptions::dumpToTextStream(), and mrpt::utils::CLoadableOptions::saveToConfigFileName().
|
inherited |
Behaves like saveToConfigFile, but you can pass directly a file name and a temporary CConfigFile object will be created automatically to save the file.
Definition at line 37 of file CLoadableOptions.cpp.
References mrpt::utils::CLoadableOptions::saveToConfigFile().
|
inlineprivate |
Definition at line 258 of file CCamModel.h.
Referenced by getFullInverseModelWithJacobian().
|
inlineprivate |
Definition at line 267 of file CCamModel.h.
Referenced by getFullInverseModelWithJacobian().
void CCamModel::undistort_point | ( | const mrpt::utils::TPixelCoordf & | p, |
mrpt::utils::TPixelCoordf & | undistorted_p | ||
) |
Return the pixel position undistorted by the camera The input values 'col' and 'row' will be replace for the new values (undistorted)
Definition at line 125 of file CCamModel.cpp.
References ASSERT_, cam, mrpt::utils::TCamera::getDistortionParamsAsVector(), mrpt::utils::TCamera::intrinsicParams, and mrpt::vision::pinhole::undistort_points().
void CCamModel::unproject_3D_point | ( | const mrpt::utils::TPixelCoordf & | distorted_p, |
mrpt::math::TPoint3D & | p3D | ||
) | const |
Return the 3D location of a point (at a fixed distance z=1), for the given (distorted) pixel position.
Definition at line 179 of file CCamModel.cpp.
References cam, mrpt::utils::TCamera::cx(), mrpt::utils::TCamera::cy(), mrpt::utils::TCamera::fx(), mrpt::utils::TCamera::fy(), mrpt::utils::TCamera::k1(), mrpt::math::square(), mrpt::utils::TPixelCoordf::x, mrpt::math::TPoint3D::x, mrpt::utils::TPixelCoordf::y, mrpt::math::TPoint3D::y, and mrpt::math::TPoint3D::z.
mrpt::utils::TCamera mrpt::vision::CCamModel::cam |
The parameters of a camera.
Definition at line 40 of file CCamModel.h.
Referenced by distort_a_point(), getFullInverseModelWithJacobian(), getFullJacobianT(), getFullProjectionT(), getTemporaryVariablesForTransform(), jacob_undistor(), jacob_undistor_fm(), jacobian_project_with_distortion(), jacobian_unproject_with_distortion(), loadFromConfigFile(), project_3D_point(), undistort_point(), and unproject_3D_point().
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 |