GSoC2011SfM
0.1
Google Summer of Code 2011: Structure from motion
|
This class represent the 3D position of the device which take the pictures. The role of the class is to store everything related to the filed of view: picture, 3D position, points, matches and 3D points. More...
#include <PointOfView.h>
Public Member Functions | |
PointOfView (cv::Ptr< Camera > device, cv::Mat rotation=cv::Mat::eye(3, 3, CV_64F), cv::Vec3d translation=cv::Vec3d(0.0, 0.0, 0.0)) | |
PointOfView (cv::Mat projection_matrix) | |
PointOfView (const PointOfView &ref) | |
virtual | ~PointOfView (void) |
cv::Ptr< Camera > | getIntraParameters () const |
uchar | getNbMissingParams () const |
virtual std::vector< cv::Vec2d > | project3DPointsIntoImage (std::vector< TrackOfPoints > points) const |
virtual std::vector< cv::Vec2d > | project3DPointsIntoImage (std::vector< cv::Vec3d > points) const |
virtual cv::Vec2d | project3DPointIntoImage (cv::Vec3d point) const |
virtual bool | pointInFrontOfCamera (cv::Vec4d point) const |
virtual cv::Mat | getProjectionMatrix () const |
cv::Mat | getRotationMatrix () const |
virtual void | setRotationMatrix (cv::Mat newRot) |
cv::Mat | getTranslationVector () const |
void | setTranslationVector (cv::Mat newVect) |
void | rotationAroundX (double angle) |
void | rotationAroundY (double angle) |
void | rotationAroundZ (double angle) |
void | print (std::ostream &flux) const |
Static Public Member Functions | |
static cv::Ptr< PointOfView > | read (const cv::FileNode &node) |
static void | write (cv::FileStorage &fs, const PointOfView &points) |
Protected Attributes | |
cv::Mat | rotation_ |
Rotation matrix R ( data is stored into projection_matrix_ ) | |
cv::Mat | translation_ |
Translation vector t ( Matrix instead of vector because data is stored into projection_matrix_ ) | |
cv::Mat | projection_matrix_ |
redundancy but speed improvement | |
cv::Ptr< Camera > | device_ |
intra parameters and distortion coefs | |
unsigned char | config_ |
This attribut is used to know what we should estimate... If equal to 0, nothing should be estimated... |
This class represent the 3D position of the device which take the pictures. The role of the class is to store everything related to the filed of view: picture, 3D position, points, matches and 3D points.
We use the so-called pinhole camera model. That is, a scene view is formed by projecting 3D points into the image plane using a perspective transformation. Usual notation says that a point [ u,v ] from an image is related to the point [ X,Y,Z ] using the following notation :
This leads to the following relation between local coordinates and global ones:
Definition at line 44 of file PointOfView.h.
OpencvSfM::PointOfView::PointOfView | ( | cv::Ptr< Camera > | device, |
cv::Mat | rotation = cv::Mat::eye( 3, 3, CV_64F ) , |
||
cv::Vec3d | translation = cv::Vec3d( 0.0,0.0,0.0 ) |
||
) |
To create a point of view, we need two things : a camera, and a point ( with orientation ). Here we give an address of a Camera, and the file name of the picture. If we have more informations, we can use the last parameters...
device | address of existing Camera. This camera can be calibrated or not... |
rotation | Matrix of the known rotation ( optional )... |
translation | Vector of the known translation ( optional )... |
Definition at line 33 of file PointOfView.cpp.
Referenced by read().
OpencvSfM::PointOfView::PointOfView | ( | cv::Mat | projection_matrix | ) |
To create a point of view using a projection matrix. (will create a Pinhole Camera without distortion parameters) We will extract intra, rotation and translation from this projection matrix.
projection_matrix | Projection matrix of the camera |
Definition at line 72 of file PointOfView.cpp.
OpencvSfM::PointOfView::PointOfView | ( | const PointOfView & | ref | ) |
Copy constructor
Definition at line 55 of file PointOfView.cpp.
OpencvSfM::PointOfView::~PointOfView | ( | void | ) | [virtual] |
Destructor of PointOfView, release all vectors... TODO: define how we should release the vectors...
Definition at line 113 of file PointOfView.cpp.
cv::Ptr<Camera> OpencvSfM::PointOfView::getIntraParameters | ( | ) | const [inline] |
use this function to get acces to the camera parameters
Definition at line 84 of file PointOfView.h.
Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().
uchar OpencvSfM::PointOfView::getNbMissingParams | ( | ) | const |
use this function to know which parameters are missing
Definition at line 132 of file PointOfView.cpp.
cv::Mat OpencvSfM::PointOfView::getProjectionMatrix | ( | ) | const [virtual] |
This method return the intra parameters of the camera
Definition at line 252 of file PointOfView.cpp.
cv::Mat OpencvSfM::PointOfView::getRotationMatrix | ( | ) | const [inline] |
Use this method to get the rotation matrix of this camera
Definition at line 126 of file PointOfView.h.
Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().
cv::Mat OpencvSfM::PointOfView::getTranslationVector | ( | ) | const [inline] |
Use this method to get the translation vector of this camera
Definition at line 145 of file PointOfView.h.
Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().
bool OpencvSfM::PointOfView::pointInFrontOfCamera | ( | cv::Vec4d | point | ) | const [virtual] |
This method test is 3D point is in front of Camera ( can be view with the camera )
point | 3D point in world coordinates ( homogeneous, that is 4 values ). |
Definition at line 241 of file PointOfView.cpp.
void OpencvSfM::PointOfView::print | ( | std::ostream & | flux | ) | const |
This operator overload allow us to print easily a point of view:
Definition at line 294 of file PointOfView.cpp.
cv::Vec2d OpencvSfM::PointOfView::project3DPointIntoImage | ( | cv::Vec3d | point | ) | const [virtual] |
This method can convert 3D point from world coordinates to 2D point in pixel image coordinates
point | 3D point in world coordinates. |
Definition at line 142 of file PointOfView.cpp.
std::vector< cv::Vec2d > OpencvSfM::PointOfView::project3DPointsIntoImage | ( | std::vector< TrackOfPoints > | points | ) | const [virtual] |
This method can convert 3D points from world coordinates to 2D points in pixel image coordinates
points | 3D points in world coordinates. |
Definition at line 203 of file PointOfView.cpp.
std::vector< cv::Vec2d > OpencvSfM::PointOfView::project3DPointsIntoImage | ( | std::vector< cv::Vec3d > | points | ) | const [virtual] |
This method can convert 3D points from world coordinates to 2D points in pixel image coordinates
points | 3D points in world coordinates. |
Definition at line 170 of file PointOfView.cpp.
cv::Ptr< PointOfView > OpencvSfM::PointOfView::read | ( | const cv::FileNode & | node | ) | [static] |
Create a new camera's point of view from a YAML file.
node | Previously opened YAML file node |
Definition at line 258 of file PointOfView.cpp.
void OpencvSfM::PointOfView::rotationAroundX | ( | double | angle | ) | [inline] |
Rotate this camera around X axis
angle | of rotation |
Definition at line 163 of file PointOfView.h.
void OpencvSfM::PointOfView::rotationAroundY | ( | double | angle | ) | [inline] |
Rotate this camera around Y axis
angle | of rotation |
Definition at line 173 of file PointOfView.h.
void OpencvSfM::PointOfView::rotationAroundZ | ( | double | angle | ) | [inline] |
Rotate this camera around Z axis
angle | of rotation |
Definition at line 183 of file PointOfView.h.
virtual void OpencvSfM::PointOfView::setRotationMatrix | ( | cv::Mat | newRot | ) | [inline, virtual] |
Use this method to change the rotation matrix of this camera
newRot | new rotation matrix |
Definition at line 134 of file PointOfView.h.
void OpencvSfM::PointOfView::setTranslationVector | ( | cv::Mat | newVect | ) | [inline] |
Use this method to change the translation vector of this camera
newVect | new translation vector |
Definition at line 153 of file PointOfView.h.
void OpencvSfM::PointOfView::write | ( | cv::FileStorage & | fs, |
const PointOfView & | points | ||
) | [static] |
Save the camera's point of view into a YAML file.
fs | Previously opened YAML file node |
points | sequence to save... |
Definition at line 286 of file PointOfView.cpp.