Visual Servoing Platform
version 3.2.0 under development (2019-01-22)
|
#include <visp3/core/vpCameraParameters.h>
Public Types | |
enum | vpCameraParametersProjType { perspectiveProjWithoutDistortion, perspectiveProjWithDistortion } |
Public Member Functions | |
vpCameraParameters () | |
vpCameraParameters (const vpCameraParameters &c) | |
vpCameraParameters (const double px, const double py, const double u0, const double v0) | |
vpCameraParameters (const double px, const double py, const double u0, const double v0, const double kud, const double kdu) | |
vpCameraParameters & | operator= (const vpCameraParameters &c) |
bool | operator== (const vpCameraParameters &c) const |
bool | operator!= (const vpCameraParameters &c) const |
virtual | ~vpCameraParameters () |
void | init () |
void | init (const vpCameraParameters &c) |
void | initFromCalibrationMatrix (const vpMatrix &_K) |
void | initFromFov (const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov) |
void | initPersProjWithoutDistortion (const double px, const double py, const double u0, const double v0) |
void | initPersProjWithDistortion (const double px, const double py, const double u0, const double v0, const double kud, const double kdu) |
bool | isFovComputed () const |
void | computeFov (const unsigned int &w, const unsigned int &h) |
double | getHorizontalFovAngle () const |
double | getVerticalFovAngle () const |
std::vector< vpColVector > | getFovNormals () const |
double | get_px () const |
double | get_px_inverse () const |
double | get_py_inverse () const |
double | get_py () const |
double | get_u0 () const |
double | get_v0 () const |
double | get_kud () const |
double | get_kdu () const |
vpCameraParametersProjType | get_projModel () const |
vpMatrix | get_K () const |
vpMatrix | get_K_inverse () const |
void | printParameters () |
Friends | |
class | vpMeterPixelConversion |
class | vpPixelMeterConversion |
VISP_EXPORT std::ostream & | operator<< (std::ostream &os, const vpCameraParameters &cam) |
Generic class defining intrinsic camera parameters.
Let us define the pinhole camera model implemented in ViSP. In this model [28], a scene view is formed by projecting 3D points into the image plane using a perspective transformation.
where:
When , the previous equation is equivalent to the following:
Real lenses usually have some radial distortion. So, the above model is extended as:
where is the first order radial distorsion. Higher order distorsion coefficients are not considered in ViSP.
Now in ViSP we consider also the inverse transformation, where from pixel coordinates we want to compute their normalized coordinates in the image plane. Previous equations could be written like:
Considering radial distortion, the above model is extended as:
Finally, in ViSP the main intrinsic camera parameters are the ratio between the focal length and the size of a pixel, and the coordinates of the principal point in pixel. The lens distortion can also be considered by two additional parameters .
From a practical point of view, two kinds of camera modelisation are implemented in this class:
1. Camera parameters for a perspective projection without distortion model
In this modelisation, only parameters are considered.
Initialization of such a model can be done using:
2. Camera parameters for a perspective projection with distortion model
In this modelisation, all the parameters are considered. Initialization of such a model can be done using:
The selection of the camera model (without or with distorsion) is done during vpCameraParameters initialisation.
Here an example of camera initialisation, for a model without distortion. A complete example is given in initPersProjWithoutDistortion().
Here an example of camera initialisation, for a model with distortion. A complete example is given in initPersProjWithDistortion().
The code below shows how to know the currently used projection model:
An XML parser for camera parameters is also provided in vpXmlParserCamera.
Definition at line 233 of file vpCameraParameters.h.
Enumerator | |
---|---|
perspectiveProjWithoutDistortion |
Perspective projection without distortion model |
perspectiveProjWithDistortion |
Perspective projection with distortion model |
Definition at line 239 of file vpCameraParameters.h.
vpCameraParameters::vpCameraParameters | ( | ) |
Default constructor. By default, a perspective projection without distortion model is set.
Definition at line 72 of file vpCameraParameters.cpp.
References init().
vpCameraParameters::vpCameraParameters | ( | const vpCameraParameters & | c | ) |
vpCameraParameters::vpCameraParameters | ( | const double | cam_px, |
const double | cam_py, | ||
const double | cam_u0, | ||
const double | cam_v0 | ||
) |
Constructor for perspective projection without distortion model
cam_px,cam_py | : pixel size |
cam_u0,cam_v0 | : principal points |
Definition at line 100 of file vpCameraParameters.cpp.
References initPersProjWithoutDistortion().
vpCameraParameters::vpCameraParameters | ( | const double | cam_px, |
const double | cam_py, | ||
const double | cam_u0, | ||
const double | cam_v0, | ||
const double | cam_kud, | ||
const double | cam_kdu | ||
) |
Constructor for perspective projection with distortion model
cam_px,cam_py | : pixel size |
cam_u0,cam_v0 | : principal points |
cam_kud | : undistorted to distorted radial distortion |
cam_kdu | : distorted to undistorted radial distortion |
Definition at line 119 of file vpCameraParameters.cpp.
References initPersProjWithDistortion().
|
virtual |
void vpCameraParameters::computeFov | ( | const unsigned int & | w, |
const unsigned int & | h | ||
) |
Compute angles and normals of the FOV.
w | : Width of the image |
h | : Height of the image. |
Definition at line 433 of file vpCameraParameters.cpp.
References vpColVector::normalize().
Referenced by vpMbTracker::computeProjectionErrorImpl(), vpMbtFaceDepthDense::computeROI(), vpMbtFaceDepthNormal::computeROI(), vpMbDepthNormalTracker::display(), vpMbDepthDenseTracker::display(), vpMbtDistanceLine::display(), vpMbKltTracker::display(), vpMbtFaceDepthNormal::displayFeature(), vpMbDepthDenseTracker::init(), vpMbDepthNormalTracker::init(), vpMbEdgeTracker::init(), initFromFov(), vpMbtDistanceLine::initMovingEdge(), vpMbtPolygon::isVisible(), vpMbEdgeKltTracker::postTracking(), vpMbKltTracker::reinit(), vpMbEdgeKltTracker::setPose(), vpMbKltTracker::setPose(), vpMbGenericTracker::track(), and vpMbtDistanceLine::updateMovingEdge().
vpMatrix vpCameraParameters::get_K | ( | ) | const |
Return the camera matrix given by:
Definition at line 493 of file vpCameraParameters.cpp.
Referenced by vpMbEdgeTracker::downScale(), vpPose::poseFromRectangle(), vpHomography::project(), vpMbKltTracker::setPose(), and vpMbEdgeTracker::upScale().
vpMatrix vpCameraParameters::get_K_inverse | ( | ) | const |
Return the inverted camera matrix given by:
Definition at line 515 of file vpCameraParameters.cpp.
Referenced by vpHomography::project(), and vpMbKltTracker::setPose().
|
inline |
Definition at line 337 of file vpCameraParameters.h.
Referenced by vpCalibration::computeStdDeviation_dist(), and vpXmlParserCamera::save().
|
inline |
Definition at line 336 of file vpCameraParameters.h.
Referenced by vpCalibration::computeStdDeviation_dist(), vpCalibration::displayGrid(), vpImageTools::initUndistortMap(), vpXmlParserCamera::save(), and vpImageTools::undistort().
|
inline |
Definition at line 339 of file vpCameraParameters.h.
Referenced by vpXmlParserCamera::save().
|
inline |
Definition at line 330 of file vpCameraParameters.h.
Referenced by vpFeatureLuminance::buildFrom(), vpCalibration::computeCalibration(), vpCalibration::computeCalibrationMulti(), vpMbtDistanceLine::computeInteractionMatrixError(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpCircle::computeIntersectionPoint(), vpKeyPoint::computePose(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpMbEdgeKltTracker::computeVVS(), vpMbEdgeTracker::computeVVSFirstPhase(), vpMbKltTracker::computeVVSInit(), vpMbEdgeTracker::computeVVSInit(), vpMeterPixelConversion::convertEllipse(), vpCalibration::displayGrid(), vpMomentObject::fromImage(), vpSimulatorAfma6::initDisplay(), vpSimulatorViper850::initDisplay(), vpImageTools::initUndistortMap(), vpMbXmlParser::read_camera(), vpMbtXmlGenericParser::read_camera(), vpMbtEdgeKltXmlParser::readMainClass(), vpMbtXmlParser::readMainClass(), vpMbtKltXmlParser::readMainClass(), vpMbXmlParser::readMainClass(), vpMbtXmlGenericParser::readMainClass(), vpXmlParserCamera::save(), vpSimulatorAfma6::setCameraParameters(), vpSimulatorViper850::setCameraParameters(), vpSimulator::setExternalCameraParameters(), vpWireFrameSimulator::setExternalCameraParameters(), vpSimulator::setInternalCameraParameters(), vpWireFrameSimulator::setInternalCameraParameters(), vpImageTools::undistort(), and vpAROgre::updateCameraProjection().
|
inline |
Definition at line 331 of file vpCameraParameters.h.
|
inline |
Definition at line 333 of file vpCameraParameters.h.
Referenced by vpFeatureLuminance::buildFrom(), vpCalibration::computeCalibration(), vpCalibration::computeCalibrationMulti(), vpMbtDistanceLine::computeInteractionMatrixError(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpCircle::computeIntersectionPoint(), vpKeyPoint::computePose(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpMeterPixelConversion::convertEllipse(), vpCalibration::displayGrid(), vpMomentObject::fromImage(), vpSimulatorAfma6::initDisplay(), vpSimulatorViper850::initDisplay(), vpImageTools::initUndistortMap(), vpMbXmlParser::read_camera(), vpMbtXmlGenericParser::read_camera(), vpMbtEdgeKltXmlParser::readMainClass(), vpMbtXmlParser::readMainClass(), vpMbtKltXmlParser::readMainClass(), vpMbXmlParser::readMainClass(), vpMbtXmlGenericParser::readMainClass(), vpXmlParserCamera::save(), vpSimulatorAfma6::setCameraParameters(), vpSimulatorViper850::setCameraParameters(), vpSimulator::setExternalCameraParameters(), vpWireFrameSimulator::setExternalCameraParameters(), vpSimulator::setInternalCameraParameters(), vpWireFrameSimulator::setInternalCameraParameters(), vpImageTools::undistort(), and vpAROgre::updateCameraProjection().
|
inline |
Definition at line 332 of file vpCameraParameters.h.
|
inline |
Definition at line 334 of file vpCameraParameters.h.
Referenced by vpCalibration::computeCalibration(), vpCalibration::computeCalibrationMulti(), vpMbtDistanceLine::computeInteractionMatrixError(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpCircle::computeIntersectionPoint(), vpKeyPoint::computePose(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpCalibration::displayGrid(), vpImageTools::initUndistortMap(), vpMbXmlParser::read_camera(), vpMbtXmlGenericParser::read_camera(), vpMbtEdgeKltXmlParser::readMainClass(), vpMbtXmlParser::readMainClass(), vpMbtKltXmlParser::readMainClass(), vpMbXmlParser::readMainClass(), vpMbtXmlGenericParser::readMainClass(), vpXmlParserCamera::save(), vpImageTools::undistort(), and vpAROgre::updateCameraProjection().
|
inline |
Definition at line 335 of file vpCameraParameters.h.
Referenced by vpCalibration::computeCalibration(), vpCalibration::computeCalibrationMulti(), vpMbtDistanceLine::computeInteractionMatrixError(), vpMbtDistanceCylinder::computeInteractionMatrixError(), vpCircle::computeIntersectionPoint(), vpKeyPoint::computePose(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpCalibration::displayGrid(), vpImageTools::initUndistortMap(), vpMbXmlParser::read_camera(), vpMbtXmlGenericParser::read_camera(), vpMbtEdgeKltXmlParser::readMainClass(), vpMbtXmlParser::readMainClass(), vpMbtKltXmlParser::readMainClass(), vpMbXmlParser::readMainClass(), vpMbtXmlGenericParser::readMainClass(), vpXmlParserCamera::save(), vpImageTools::undistort(), and vpAROgre::updateCameraProjection().
|
inline |
Get the list of the normals corresponding to planes describing the field of view.
Definition at line 321 of file vpCameraParameters.h.
References vpTRACE.
Referenced by vpPolygon3D::computePolygonClipped().
|
inline |
Get the horizontal angle in radian of the field of view.
Definition at line 284 of file vpCameraParameters.h.
References vpTRACE.
|
inline |
Get the vertical angle in radian of the field of view.
Definition at line 300 of file vpCameraParameters.h.
References vpTRACE.
void vpCameraParameters::init | ( | ) |
basic initialization with the default parameters
Definition at line 132 of file vpCameraParameters.cpp.
References vpException::divideByZeroError, and vpERROR_TRACE.
Referenced by vpCameraParameters().
void vpCameraParameters::init | ( | const vpCameraParameters & | c | ) |
initialization from another vpCameraParameters object
Definition at line 283 of file vpCameraParameters.cpp.
void vpCameraParameters::initFromCalibrationMatrix | ( | const vpMatrix & | _K | ) |
initialise the camera from a calibration matrix. Using a calibration matrix leads to a camera without distortion
The K matrix in parameters must be like:
_K | : the 3by3 calibration matrix |
Definition at line 299 of file vpCameraParameters.cpp.
References vpException::badValue, vpException::dimensionError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), and initPersProjWithoutDistortion().
Referenced by vpMbEdgeTracker::downScale(), and vpMbEdgeTracker::upScale().
void vpCameraParameters::initFromFov | ( | const unsigned int & | w, |
const unsigned int & | h, | ||
const double & | hfov, | ||
const double & | vfov | ||
) |
Initialize the camera model without distorsion from the image dimension and the camera field of view.
w | : Image width. |
h | : Image height. |
hfov | : Camera horizontal field of view angle expressed in radians. |
vfov | : Camera vertical field of view angle expressed in radians. |
The following sample code shows how to use this function:
It produces the following output:
Definition at line 343 of file vpCameraParameters.cpp.
References computeFov(), and perspectiveProjWithoutDistortion.
void vpCameraParameters::initPersProjWithDistortion | ( | const double | cam_px, |
const double | cam_py, | ||
const double | cam_u0, | ||
const double | cam_v0, | ||
const double | cam_kud, | ||
const double | cam_kdu | ||
) |
Initialization with specific parameters using perpective projection with distortion model.
cam_px,cam_py | : the ratio between the focal length and the size of a pixel. |
cam_u0,cam_v0 | : principal points coordinates in pixels. |
cam_kud | : undistorted to distorted radial distortion. |
cam_kdu | : distorted to undistorted radial distortion. |
The following sample code shows how to use this function:
It produces the following output:
Definition at line 249 of file vpCameraParameters.cpp.
References vpException::divideByZeroError, perspectiveProjWithDistortion, and vpERROR_TRACE.
Referenced by vpViper650::getCameraParameters(), vpViper850::getCameraParameters(), vpAfma6::getCameraParameters(), vpRealSense2::getCameraParameters(), vpRealSense::getCameraParameters(), vpXmlParserCamera::save(), vpKinect::start(), and vpCameraParameters().
void vpCameraParameters::initPersProjWithoutDistortion | ( | const double | cam_px, |
const double | cam_py, | ||
const double | cam_u0, | ||
const double | cam_v0 | ||
) |
Initialization with specific parameters using perpective projection without distortion model.
cam_px,cam_py | : the ratio between the focal length and the size of a pixel. |
cam_u0,cam_v0 | : principal point coordinates in pixels. |
The following sample code shows how to use this function:
It produces the following output:
Definition at line 183 of file vpCameraParameters.cpp.
References vpException::divideByZeroError, perspectiveProjWithoutDistortion, and vpERROR_TRACE.
Referenced by vpServolens::getCameraParameters(), vpViper650::getCameraParameters(), vpViper850::getCameraParameters(), vpAfma6::getCameraParameters(), vpSimulatorAfma6::getCameraParameters(), vpSimulatorViper850::getCameraParameters(), vpRealSense2::getCameraParameters(), vpRealSense::getCameraParameters(), vpSimulatorAfma6::initDisplay(), vpSimulatorViper850::initDisplay(), initFromCalibrationMatrix(), vpMbXmlParser::read_camera(), vpMbtXmlGenericParser::read_camera(), vpXmlParserCamera::save(), and vpCameraParameters().
|
inline |
Specify if the fov has been computed.
Definition at line 273 of file vpCameraParameters.h.
Referenced by vpPolygon3D::computePolygonClipped().
bool vpCameraParameters::operator!= | ( | const vpCameraParameters & | c | ) | const |
False if the two objects are absolutely identical.
Definition at line 423 of file vpCameraParameters.cpp.
vpCameraParameters & vpCameraParameters::operator= | ( | const vpCameraParameters & | cam | ) |
copy operator
Definition at line 361 of file vpCameraParameters.cpp.
bool vpCameraParameters::operator== | ( | const vpCameraParameters & | c | ) | const |
True if the two objects are absolutely identical.
Definition at line 387 of file vpCameraParameters.cpp.
References vpMath::equal().
void vpCameraParameters::printParameters | ( | ) |
Print the camera parameters on the standard output
Definition at line 532 of file vpCameraParameters.cpp.
References perspectiveProjWithDistortion, and perspectiveProjWithoutDistortion.
Referenced by vpCalibration::computeCalibration(), and vpCalibration::computeCalibrationMulti().
|
friend |
Print on the output stream os the camera parameters.
os | : Output stream. |
cam | : Camera parameters. |
Definition at line 561 of file vpCameraParameters.cpp.
|
friend |
Definition at line 235 of file vpCameraParameters.h.
|
friend |
Definition at line 236 of file vpCameraParameters.h.