Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GenSynthMatchesRig.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __GenSynthMatchesRig_hh__
26 #define __GenSynthMatchesRig_hh__
27 
28 #include <bias_config.h>
29 
30 #include <Base/Common/BIASpragmaStart.hh>
31 
32 #include <iostream>
33 #include <string>
34 #include <vector>
35 
36 #include <Base/Image/Image.hh>
37 #include <Base/Geometry/HomgPoint2D.hh>
38 #include <Base/Geometry/HomgPoint3D.hh>
39 #include <Base/Geometry/KMatrix.hh>
40 #include <Base/Geometry/FMatrixBase.hh>
41 #include <Base/Geometry/EuclideanTransf3D.hh>
42 #include <Base/Geometry/RMatrixBase.hh>
43 #include <Base/Geometry/PMatrixBase.hh>
44 #include <Utils/Param.hh>
45 #include <Base/Math/Random.hh>
46 #include "MatchDataBase.hh"
47 #include "GenSynthMatches.hh"
48 #include <Base/Math/Vector3.hh>
49 #include <Geometry/RMatrix.hh>
50 
51 namespace BIAS{
52 
53 #define GENSYNTHMATCHESRIG_MAX_NR_OF_CAMERAS 8
54 
55  /** \cond HIDDEN_SYMBOLS
56  needed for WIN32-DLL, templates of templates... would generate
57  too long name symbols!
58  **/
59  struct VecOMapOStrDbl {
60  VecOMapOStrDbl() {}
61  VecOMapOStrDbl(std::vector<std::map<std::string, double> > tmp) {
62  vecOMaps = tmp;
63  }
64  std::vector<std::map<std::string, double> > vecOMaps;
65  };
66  /** \endcond */
67  /**
68  @brief Generates synthetic matches for cameras in a rig
69  */
70  class BIASUtils_EXPORT GenSynthMatchesRig
71  {
72  public:
73  ///@brief Constructor - register parameters
75  virtual ~GenSynthMatchesRig();
76 
77  // clears all internal vectors and resets K and Ki
78  // also resets _rand
79  void Reset();
80 
81  ///@brief Creates 3D points and generates 2D matches for them.
82  int CreateMatches();
83 
84  ///@addtogroup ImageGeneration
85  ///@{
86  ///@brief Creates images showing the 2D matches for all cameras.
87  void DrawTrue(std::vector<Image<unsigned char> >&im, int minindex=0,
88  int maxindex=1) const;
89  ///@brief Creates an image showing the 2D matches for a camera.
90  void DrawTrue(Image<unsigned char> &img, int minindex,
91  int maxindex, int camIndex) const;
92  ///@brief Creates images showing the 2D matches for all cameras.
93  void DrawNoisy(std::vector<Image<unsigned char> >&im, int minindex=0,
94  int maxindex=1) const;
95  ///@brief Creates an image showing the 2D matches for a camera.
96  void DrawNoisy(Image<unsigned char> &img, int minindex,
97  int maxindex, int camIndex) const;
98  ///@}
99 
100  //int Create3DPoints();
101 
102  ///@brief write in xml/ascii file format
103  int Write(std::string file) const;
104  ///@brief read in xml/ascii file format
105  int Read(std::string file);
106 
107  ///@brief returns the vector of the used GenSynthMatches object
108  inline std::vector<BIAS::GenSynthMatches> GetCams() const {
109  return CamMatches_;
110  }
111 
112  friend BIASUtils_EXPORT std::ostream&
113  operator<<(std::ostream& os, const GenSynthMatchesRig& m);
114 
115  friend BIASUtils_EXPORT std::istream&
116  operator>>(std::istream& os, GenSynthMatchesRig& m);
117 
118  protected:
119  ///@brief Pointer to the parameter object
121 
122  ///@brief motion vectors read from the param file
129 
130  //camID -> transform -> value (relative).
131  std::vector<std::map<std::string, double> > SlaveCamsRelative_;
132  //camID -> timestep -> transform -> value (global).
133  std::vector<VecOMapOStrDbl > SlaveCamsGlobal_;
134  ///@brief Vector containing the cameras
135  std::vector<GenSynthMatches> CamMatches_;
136 
137  ///@brief dummy to initialize the param object
139  ///@brief The number of cameras used. Read from the param object.
141 
142  ///@brief Update the param object for the given slave camera.
143  void UpdateParams_(int camID);
144 
145  ///@brief Setup the global poses of the cameras and read the parameters.
146  void Setup_();
147  ///@brief read the parameters from the param object.
148  void GetParameters_();
149  ///@brief Add parameters to the param object.
150  void AddParameters_(Param &para);
151  ///@brief Print the poses of the cameras. For debugging only.
152  void PrintCamPoses_();
153 
154  }; // class
155 
156  BIASUtils_EXPORT std::ostream&
157  operator<<(std::ostream& os, const GenSynthMatchesRig& m);
158 
159 } // namespace
160 
161 
162 #include <Base/Common/BIASpragmaEnd.hh>
163 
164 #endif
std::vector< VecOMapOStrDbl > SlaveCamsGlobal_
BIAS::Vector< double > MasterAnglesY_
BIAS::Vector< double > MasterCenterZ_
class for generating synthetic matches
BIAS::Vector< double > MasterCenterX_
motion vectors read from the param file
Param * allParams_
Pointer to the parameter object.
BIAS::Vector< double > MasterCenterY_
std::vector< GenSynthMatches > CamMatches_
Vector containing the cameras.
BIAS::Vector< double > MasterAnglesZ_
Generates synthetic matches for cameras in a rig.
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
Definition: Array2D.hh:260
BIAS::Vector< double > MasterAnglesX_
This class Param provides generic support for parameters.
Definition: Param.hh:231
std::vector< std::map< std::string, double > > SlaveCamsRelative_
GenSynthMatches GenMatches_
dummy to initialize the param object
int * NumCameras_
The number of cameras used. Read from the param object.
std::vector< BIAS::GenSynthMatches > GetCams() const
returns the vector of the used GenSynthMatches object
BIASCommon_EXPORT std::istream & operator>>(std::istream &is, BIAS::TimeStamp &ts)
Standard input operator for TimeStamps.
Definition: TimeStamp.cpp:157