Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
BIAS::GenSynthMatchesRig Class Reference

Generates synthetic matches for cameras in a rig. More...

#include <Utils/GenSynthMatchesRig.hh>

+ Collaboration diagram for BIAS::GenSynthMatchesRig:

Public Member Functions

int CreateMatches ()
 Creates 3D points and generates 2D matches for them. More...
 
void DrawNoisy (std::vector< Image< unsigned char > > &im, int minindex=0, int maxindex=1) const
 Creates images showing the 2D matches for all cameras. More...
 
void DrawNoisy (Image< unsigned char > &img, int minindex, int maxindex, int camIndex) const
 Creates an image showing the 2D matches for a camera. More...
 
void DrawTrue (std::vector< Image< unsigned char > > &im, int minindex=0, int maxindex=1) const
 Create images for all cameras showing the matches. More...
 
void DrawTrue (Image< unsigned char > &img, int minindex, int maxindex, int camIndex) const
 Creates an image showing the 2D matches for a camera. More...
 
 GenSynthMatchesRig (Param &para)
 Constructor - register parameters. More...
 
std::vector
< BIAS::GenSynthMatches
GetCams () const
 returns the vector of the used GenSynthMatches object More...
 
int Read (std::string file)
 read in xml/ascii file format More...
 
void Reset ()
 
int Write (std::string file) const
 write in xml/ascii file format More...
 
virtual ~GenSynthMatchesRig ()
 Default destructor... More...
 

Protected Member Functions

void AddParameters_ (Param &para)
 Add parameters to the param object. More...
 
void GetParameters_ ()
 read the parameters from the param object. More...
 
void PrintCamPoses_ ()
 Print the poses of the cameras. For debugging only. More...
 
void Setup_ ()
 Setup the global poses of the cameras and read the parameters. More...
 
void UpdateParams_ (int camID)
 Update the param object for the given slave camera. More...
 

Protected Attributes

ParamallParams_
 Pointer to the parameter object. More...
 
std::vector< GenSynthMatchesCamMatches_
 Vector containing the cameras. More...
 
GenSynthMatches GenMatches_
 dummy to initialize the param object More...
 
BIAS::Vector< double > MasterAnglesX_
 
BIAS::Vector< double > MasterAnglesY_
 
BIAS::Vector< double > MasterAnglesZ_
 
BIAS::Vector< double > MasterCenterX_
 motion vectors read from the param file More...
 
BIAS::Vector< double > MasterCenterY_
 
BIAS::Vector< double > MasterCenterZ_
 
int * NumCameras_
 The number of cameras used. Read from the param object. More...
 
std::vector< VecOMapOStrDbl > SlaveCamsGlobal_
 
std::vector< std::map
< std::string, double > > 
SlaveCamsRelative_
 

Friends

BIASUtils_EXPORT std::ostream & operator<< (std::ostream &os, const GenSynthMatchesRig &m)
 
BIASUtils_EXPORT std::istream & operator>> (std::istream &os, GenSynthMatchesRig &m)
 

Detailed Description

Generates synthetic matches for cameras in a rig.

Examples:
ExampleGenSynthMatchesRig.cpp.

Definition at line 70 of file GenSynthMatchesRig.hh.

Constructor & Destructor Documentation

GenSynthMatchesRig::GenSynthMatchesRig ( Param para)

Constructor - register parameters.

Constructor.

Registers the needed parameters in the param object. The values can then be filled externally, e.g. by a param file. The object GenMatches_ of type BIAS::GenSynthMatches is initialized with the param object - this way GenMatches will register all parameters needed for a GenSynthMatches object in the argument of the constructor. In AddParameters_() the special parameters of this class will become registered.

Parameters
paraA parameter object.
See Also
BIAS::Param for information on Param objects.
Note
The parameters should be set externally. First the parameters have to be registered. Then, before creating matches, the values should be filled by the user (e.g. reading the parameters from a file).

Definition at line 69 of file GenSynthMatchesRig.cpp.

References AddParameters_(), allParams_, and BIAS::Param::GetParamInt().

GenSynthMatchesRig::~GenSynthMatchesRig ( )
virtual

Default destructor...

Definition at line 85 of file GenSynthMatchesRig.cpp.

Member Function Documentation

void GenSynthMatchesRig::AddParameters_ ( Param para)
protected

Add parameters to the param object.

Register needed parameters.

The parameters needed by the BIAS::GenSynthMatches objects are registered by a dummy object in the constructor.

Parameters
[out]paraThe parameter object to be updated.

Definition at line 692 of file GenSynthMatchesRig.cpp.

References BIAS::Param::AddParamDouble(), BIAS::Param::AddParamInt(), BIAS::Param::CheckParam(), BIAS::Param::GetFreeGroupID(), BIAS::Param::GetGroupID(), BIAS::Param::GetParamDouble(), BIAS::Param::GetParamInt(), BIAS::Param::IsUsedGroupID(), NumCameras_, BIAS::Param::SetGroupName(), and SlaveCamsRelative_.

Referenced by GenSynthMatchesRig().

int GenSynthMatchesRig::CreateMatches ( )

Creates 3D points and generates 2D matches for them.

Generates 3D Points an creates the 2D matches for each camera at each time step.

At first Setup_() is beenig called to compute the poses of the slave cameras in the global coord system (which hast its origin at the center of the master camera). For each camera an BIAS::GenSynthMatches object will be created. The object assigned to the master cam creates random 3D Points which will be passed to the slave cameras. So all cameras work with the same 3D points and try to generate 2D matches for them. If a 3D point has no match with an image plane of a camera, the 3D point will be replaced. After 1000 reties the computation will abort.

Returns
0, if OK. -1, if too many iterations.
Todo:
Moving objects not yet supported.

Definition at line 339 of file GenSynthMatchesRig.cpp.

References allParams_, CamMatches_, BIAS::GenSynthMatches::Create3DPoints(), BIAS::GenSynthMatches::CreateCamMovement(), BIAS::GenSynthMatches::CreateMatches(), BIAS::GenSynthMatches::CreateMoving3DPoint(), BIAS::GenSynthMatches::CreateMovingTransforms(), BIAS::GenSynthMatches::CreateStatic3DPoint(), BIAS::GenSynthMatches::GetMoving3DPoints(), BIAS::GenSynthMatches::GetStatic3DPoints(), NumCameras_, BIAS::GenSynthMatches::SetMoving3DPoints(), BIAS::GenSynthMatches::SetStatic3DPoints(), Setup_(), and UpdateParams_().

std::vector<BIAS::GenSynthMatches> BIAS::GenSynthMatchesRig::GetCams ( ) const
inline

returns the vector of the used GenSynthMatches object

Definition at line 108 of file GenSynthMatchesRig.hh.

Referenced by BIAS::operator<<().

void GenSynthMatchesRig::GetParameters_ ( )
protected

read the parameters from the param object.

Read the parameters from the param object.

The relative transformations of the slave cameras to the master camera are stored in SlaveCamsRelative_.

Definition at line 269 of file GenSynthMatchesRig.cpp.

References allParams_, BIAS::Param::GetParamDouble(), BIAS::Param::GetParamInt(), BIAS::Param::GetParamVecDbl(), MasterAnglesX_, MasterAnglesY_, MasterAnglesZ_, MasterCenterX_, MasterCenterY_, MasterCenterZ_, NumCameras_, TNT::Vector< T >::size(), and SlaveCamsRelative_.

Referenced by Setup_().

void GenSynthMatchesRig::PrintCamPoses_ ( )
protected

Print the poses of the cameras. For debugging only.

Print out the camera poses of each camera and each time step.

Definition at line 669 of file GenSynthMatchesRig.cpp.

References MasterAnglesX_, MasterAnglesY_, MasterAnglesZ_, MasterCenterX_, MasterCenterY_, MasterCenterZ_, and SlaveCamsRelative_.

int GenSynthMatchesRig::Read ( std::string  file)

read in xml/ascii file format

Fill the necessary parts of this object from a file.

These are:

  • The contained GenStynthMatches objects
  • The number of cameras to be used
    Parameters
    [in]Thefile name to read from.
    Returns
  • 0: all right
  • -1: error reading from file
  • -2: no child nodes of root node found
  • -3: attribute not found in the child node

Here is an example for an xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<GenSynthMatchesRigData Version="0.1">
<Camera FileName="dataRig.xml.cam0"/>
<Camera FileName="dataRig.xml.cam1"/>
</GenSynthMatchesRigData>
Todo:
Check if the nodes and attributes have the expected names.

Definition at line 612 of file GenSynthMatchesRig.cpp.

References allParams_, CamMatches_, BIAS::XMLIO::getAttributeValueString(), BIAS::XMLIO::GetChildren(), BIAS::XMLIO::getFirstAttribute(), NumCameras_, BIAS::GenSynthMatches::Read(), and BIAS::XMLIO::read().

void BIAS::GenSynthMatchesRig::Reset ( )
void GenSynthMatchesRig::Setup_ ( )
protected

Setup the global poses of the cameras and read the parameters.

Here the values of the param (object/file) are assigned to the member variables with the GetParameters_() method.

In the next step, the vector SlaveCamsGlobal_ containing the global poses of the slave cameras is being filled. The global poses are computed by applying the movement of the master camera (first camera) to the slave cameras (which have known relative transforms to the master camera).

Precondition
The vector containing the moving information must contain at least as many elements as number of images given in the param object.
The number of cameras must not be greater then #GENSYNTHMATCHESRIG_MAX_NR_OF_CAMERAS.

Definition at line 100 of file GenSynthMatchesRig.cpp.

References allParams_, GetParameters_(), BIAS::Param::GetParamInt(), BIAS::RMatrixBase::GetRotationAnglesXYZ(), MasterAnglesX_, MasterAnglesY_, MasterAnglesZ_, MasterCenterX_, MasterCenterY_, MasterCenterZ_, BIAS::MatrixIdentity, NumCameras_, BIAS::RMatrixBase::SetXYZ(), SlaveCamsGlobal_, SlaveCamsRelative_, BIAS::Matrix3x3< T >::Transpose(), and BIAS::Matrix3x3< T >::TransposeIP().

Referenced by CreateMatches().

void GenSynthMatchesRig::UpdateParams_ ( int  camID)
protected

Update the param object for the given slave camera.

Updates the parameters for a given slave camera.

The parameters are updated before the 2D matches are computed for a BIAS::GenSynthMatches object of a slave camera. The values of the poses (motion/rotation vectors) of the camera of the BIAS::GenSynthMatches object will be filled with the global poses of the given slave cam.

Parameters
[in]camIDThe ID of the camera to be updated.
Note
The master cam must not be updated. All values are set initially.

Definition at line 434 of file GenSynthMatchesRig.cpp.

References allParams_, BIAS::Param::GetParamInt(), BIAS::Param::GetParamVecDbl(), and SlaveCamsGlobal_.

Referenced by CreateMatches().

int GenSynthMatchesRig::Write ( std::string  file) const

write in xml/ascii file format

Write the necessary components of this object to an xml file.

These are:

  • The contained GenStynthMatches objects, which is stored by setting a file name in the attribute of each "Camera" node. These will be stored to <given_filename>.cam0, <given_filename>.cam1, ...
  • The number of cameras to be used, which is stored by the number of "Camera" nodes written to the xml file.
    Parameters
    [in]fileThe file name to store the file. The extension (.xml) should be contained in the file name.
    Returns
    < 0, if an error occured.
    See Also
    Read() to read this object from a file and to see an example xml file.

Definition at line 566 of file GenSynthMatchesRig.cpp.

References BIAS::XMLIO::addAttribute(), BIAS::XMLIO::addChildNode(), CamMatches_, BIAS::XMLIO::create(), and BIAS::XMLIO::write().

Friends And Related Function Documentation

BIASUtils_EXPORT std::ostream& operator<< ( std::ostream &  os,
const GenSynthMatchesRig m 
)
friend
BIASUtils_EXPORT std::istream& operator>> ( std::istream &  os,
GenSynthMatchesRig m 
)
friend

Member Data Documentation

Param* BIAS::GenSynthMatchesRig::allParams_
protected

Pointer to the parameter object.

Definition at line 120 of file GenSynthMatchesRig.hh.

Referenced by CreateMatches(), GenSynthMatchesRig(), GetParameters_(), Read(), Setup_(), and UpdateParams_().

std::vector<GenSynthMatches> BIAS::GenSynthMatchesRig::CamMatches_
protected

Vector containing the cameras.

Definition at line 135 of file GenSynthMatchesRig.hh.

Referenced by CreateMatches(), DrawNoisy(), DrawTrue(), Read(), and Write().

GenSynthMatches BIAS::GenSynthMatchesRig::GenMatches_
protected

dummy to initialize the param object

Definition at line 138 of file GenSynthMatchesRig.hh.

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterAnglesX_
protected

Definition at line 126 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterAnglesY_
protected

Definition at line 127 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterAnglesZ_
protected

Definition at line 128 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterCenterX_
protected

motion vectors read from the param file

Definition at line 123 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterCenterY_
protected

Definition at line 124 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

BIAS::Vector<double> BIAS::GenSynthMatchesRig::MasterCenterZ_
protected

Definition at line 125 of file GenSynthMatchesRig.hh.

Referenced by GetParameters_(), PrintCamPoses_(), and Setup_().

int* BIAS::GenSynthMatchesRig::NumCameras_
protected

The number of cameras used. Read from the param object.

Definition at line 140 of file GenSynthMatchesRig.hh.

Referenced by AddParameters_(), CreateMatches(), DrawNoisy(), DrawTrue(), GetParameters_(), Read(), and Setup_().

std::vector<VecOMapOStrDbl > BIAS::GenSynthMatchesRig::SlaveCamsGlobal_
protected

Definition at line 133 of file GenSynthMatchesRig.hh.

Referenced by Setup_(), and UpdateParams_().

std::vector<std::map<std::string, double> > BIAS::GenSynthMatchesRig::SlaveCamsRelative_
protected

Definition at line 131 of file GenSynthMatchesRig.hh.

Referenced by AddParameters_(), GetParameters_(), PrintCamPoses_(), and Setup_().


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