Image Component Library (ICL)
SoftPosit.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLGeom/src/ICLGeom/SoftPosit.h **
10 ** Module : ICLGeom **
11 ** Authors: Christian Groszewski **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLMath/DynMatrix.h>
35 #include <ICLMath/FixedVector.h>
36 #include <ICLUtils/Macros.h>
37 #include <ICLUtils/Thread.h>
38 #include <ICLUtils/Point32f.h>
39 #include <ICLUtils/BasicTypes.h>
40 
41 #ifdef ICL_HAVE_QT
42 #include<ICLQt/DrawWidget.h>
43 #endif
44 
45 #ifdef WIN32
46  #undef max
47 #endif
48 
49 namespace icl{
50  namespace geom{
52  private:
53  //M
54  unsigned int nbWorldPts;
55  //N
56  unsigned int nbImagePts;
57 
59 
61 
63 
64  double beta;
65 
66  double betaFinal;
67 
68  static const double betaUpdate;// not allowed in clang = 1.05;
69 
70  static const double betaZero;;// not allowed in clang = 0.0004;
71 #ifdef ICL_HAVE_QT
73 #endif
76 
77  //expected or random pose
78  //math::DynMatrix<icl64f> Q1;
79  //expected or random pose
80  //math::DynMatrix<icl64f> Q2;
81  //squared distances
83 
85  //object points
86  std::vector<math::DynMatrix<icl64f> > P;
87  //image points
88  std::vector<math::DynMatrix<icl64f> > p;
89 
92 
97 
99 
103 
108 
113 
115 
117 
118 
121 
125 
127 
129  double Tz;
130  double Tx;
131  double Ty;
132 
133  double sumNonslack;
134 
135  double sum;
136 
137  double alpha;
138 
139  bool draw;
140 
142 
143  void maxPosRatio(math::DynMatrix<icl64f> &assignMat, math::DynMatrix<icl64f> &pos, math::DynMatrix<icl64f> &ratios);
144 
146 
147  double cond(math::DynMatrix<icl64f> &A);
148 
149  double max(math::DynMatrix<icl64f> s);
150 
151 
152  public:
153  SoftPosit();
154 
155  ~SoftPosit();
156 
157  void init();
158 
160  return ROT;
161  }
162 
164  return T;
165  }
166 
167  //unused
168  int numMatches(math::DynMatrix<icl64f> &assignMat);
169 
170  void softPosit(math::DynMatrix<icl64f> imagePts, math::DynMatrix<icl64f> worldPts, double beta0, int noiseStd, math::DynMatrix<icl64f> initRot,
171  math::DynMatrix<icl64f> initTrans, double focalLength, math::DynMatrix<icl64f> center = math::DynMatrix<icl64f>(2,0), bool draw = true);
172 #ifdef ICL_HAVE_QT
173  void softPosit(math::DynMatrix<icl64f> imagePts, math::DynMatrix<icl64f> imageAdj, math::DynMatrix<icl64f> worldPts,
174  math::DynMatrix<icl64f> worldAdj, double beta0, int noiseStd, math::DynMatrix<icl64f> initRot,
175  math::DynMatrix<icl64f> initTrans, double focalLength, qt::ICLDrawWidget &w,
176  math::DynMatrix<icl64f> center = math::DynMatrix<icl64f>(2,0), bool draw = true);
177 #endif
178  void softPosit(std::vector<utils::Point32f> imagePts, std::vector<math::FixedColVector<double,3> > worldPts,
179  double beta0, int noiseStd, math::DynMatrix<icl64f> initRot, math::DynMatrix<icl64f> initTrans,
180  double focalLength, math::DynMatrix<icl64f> center = math::DynMatrix<icl64f>(2,0));
181 #ifdef ICL_HAVE_QT
182  void softPosit(std::vector<utils::Point32f> imagePts, math::DynMatrix<icl64f> imageAdj, std::vector<math::FixedColVector<double,3> > worldPts,
183  math::DynMatrix<icl64f> worldAdj, double beta0, int noiseStd, math::DynMatrix<icl64f> initRot,
184  math::DynMatrix<icl64f> initTrans, double focalLength, qt::ICLDrawWidget &w,
185  math::DynMatrix<icl64f> center = math::DynMatrix<icl64f>(2,0), bool draw=true);
186 #endif
187  void proj3dto2d(math::DynMatrix<icl64f> pts3d, math::DynMatrix<icl64f> &rot, math::DynMatrix<icl64f> &trans,
188  double flength, int objdim, math::DynMatrix<icl64f> &center, math::DynMatrix<icl64f> &pts2d);
189 
191  bool isNull = true;
192  for(unsigned int i=0;i<M.cols();++i){
193  for(unsigned int j=0;j<M.rows();++j){
194  if(M[i+j*M.cols()] != 0){
195  isNull = false;
196  return isNull;
197  }
198  }
199  }
200  return isNull;
201  }
202 
203 #ifdef ICL_HAVE_QT
204  void visualize(const math::DynMatrix<icl64f> & imagePts, const math::DynMatrix<icl64f> &projWorldPts, unsigned int delay=200);
205 
206  void visualize(qt::ICLDrawWidget &w,const math::DynMatrix<icl64f> & imagePts, const math::DynMatrix<icl64f> &imageAdj,
207  const math::DynMatrix<icl64f> &projWorldPts, const math::DynMatrix<icl64f> &worldAdj, unsigned int delay=200);
208 #endif
209  };
210  } // namespace geom
211 }
212 
math::DynMatrix< icl64f > projectedV
Definition: SoftPosit.h:105
math::DynMatrix< icl64f > replicatedProjectedU
Definition: SoftPosit.h:106
math::DynMatrix< icl64f > weightedVi
Definition: SoftPosit.h:120
undocument this line if you encounter any issues!
Definition: Any.h:37
std::vector< math::DynMatrix< icl64f > > p
Definition: SoftPosit.h:88
math::DynMatrix< icl64f > distMat
Definition: SoftPosit.h:60
math::DynMatrix< icl64f > d
Definition: SoftPosit.h:82
double Ty
Definition: SoftPosit.h:131
math::DynMatrix< icl64f > U
Definition: SoftPosit.h:93
math::FixedColVector< T, 4 > cross(const math::FixedMatrix< T, 1, 4 > &v1, const math::FixedMatrix< T, 1, 4 > &v2)
homogeneous 3D cross-product
Definition: HomogeneousMath.h:203
math::DynMatrix< icl64f > pts2d
Definition: SoftPosit.h:114
math::DynMatrix< icl64f > wAdj
Definition: SoftPosit.h:75
qt::ICLDrawWidget * dw
Definition: SoftPosit.h:70
#define ICLGeom_API
Definition: CompatMacros.h:179
math::DynMatrix< icl64f > r1T
Definition: SoftPosit.h:100
math::DynMatrix< icl64f > invL
Definition: SoftPosit.h:91
math::DynMatrix< icl64f > getTranslation()
Definition: SoftPosit.h:163
math::DynMatrix< icl64f > col2
Definition: SoftPosit.h:111
double sumNonslack
Definition: SoftPosit.h:133
math::DynMatrix< icl64f > R3
Definition: SoftPosit.h:124
math::DynMatrix< icl64f > r3T
Definition: SoftPosit.h:102
double beta
Definition: SoftPosit.h:64
bool draw
Definition: SoftPosit.h:139
double Tz
Definition: SoftPosit.h:129
math::DynMatrix< icl64f > replicatedProjectedV
Definition: SoftPosit.h:107
double betaFinal
Definition: SoftPosit.h:66
math::DynMatrix< icl64f > wkxj
Definition: SoftPosit.h:110
unsigned int rows() const
height of the matrix (number of rows)
Definition: DynMatrix.h:471
math::DynMatrix< icl64f > svdResult
Definition: SoftPosit.h:96
double sum
Definition: SoftPosit.h:135
unsigned int cols() const
width of the matrix (number of columns)
Definition: DynMatrix.h:474
math::DynMatrix< icl64f > T
Definition: SoftPosit.h:128
unsigned int nbWorldPts
Definition: SoftPosit.h:54
Extended Image visualization widget, with a drawing state machine interface.
Definition: DrawWidget.h:142
math::DynMatrix< icl64f > projectedU
Definition: SoftPosit.h:104
math::DynMatrix< icl64f > assignMat
Definition: SoftPosit.h:62
math::DynMatrix< icl64f > wkyj
Definition: SoftPosit.h:112
std::vector< math::DynMatrix< icl64f > > P
Definition: SoftPosit.h:86
math::DynMatrix< icl64f > r2T
Definition: SoftPosit.h:101
unsigned int nbImagePts
Definition: SoftPosit.h:56
math::DynMatrix< icl64f > centeredImage
Definition: SoftPosit.h:58
math::DynMatrix< icl64f > L
Definition: SoftPosit.h:90
math::DynMatrix< icl64f > s
Definition: SoftPosit.h:94
math::DynMatrix< icl64f > iAdj
Definition: SoftPosit.h:74
static const double betaUpdate
Definition: SoftPosit.h:68
math::DynMatrix< icl64f > R2
Definition: SoftPosit.h:123
math::DynMatrix< icl64f > getRotationMat()
Definition: SoftPosit.h:159
bool isNullMatrix(const math::DynMatrix< icl64f > &M)
Definition: SoftPosit.h:190
math::DynMatrix< icl64f > ROT
Definition: SoftPosit.h:126
math::DynMatrix< icl64f > eye2_2
Definition: SoftPosit.h:98
math::DynMatrix< icl64f > R1
Definition: SoftPosit.h:122
Definition: FixedVector.h:40
Definition: SoftPosit.h:51
math::DynMatrix< icl64f > w
Definition: SoftPosit.h:84
math::DynMatrix< icl64f > V
Definition: SoftPosit.h:95
math::DynMatrix< icl64f > col1
Definition: SoftPosit.h:109
math::DynMatrix< icl64f > weightedUi
Definition: SoftPosit.h:119
double alpha
Definition: SoftPosit.h:137
math::DynMatrix< icl64f > summedByColAssign
Definition: SoftPosit.h:116
double Tx
Definition: SoftPosit.h:130