vrcore  0.45
visuReal Messkern
 All Classes Files Functions Variables
aspect.h
Go to the documentation of this file.
1 #ifndef ASPECT_H
2 #define ASPECT_H
3 
6 namespace vr {
7 
12 template <int n> struct FramePoint {
13  cv::Vec<double, n> point;
14  StatusInfo statusInfo;
15 };
16 
17 template <int n> struct Frame {
18  FramePoint<n> bottom;
19  FramePoint<n> nasal;
20  FramePoint<n> top;
21  FramePoint<n> temporal;
22 };
23 
27 template <int n> class FrameSideView
28 {
29 public:
30  cv::Vec<double, n> top;
31  cv::Vec<double, n> temporal;
32  cv::Vec<double, n> bottom;
33 };
34 
35 template <int n> struct ProgressiveCorridor
36 {
37  cv::Vec<double, n> top;
39  cv::Vec<double, n> bottom;
40 };
41 
44 template <int n> struct FrontGeneral
45 {
46  Frame<n> frame[LATERAL_SIDE];
47  ProgressiveCorridor<n> progCorridor[LATERAL_SIDE];
48  cv::Vec<double, n> pupil[LATERAL_SIDE];
49 };
50 
53 template <int n> class FrontMarks
54 {
55 public:
56  cv::Vec<double, n> m_R;
57  cv::Vec<double, n> m_L;
58  cv::Vec<double, n> m_M;
59  // (Fassungsscheibenwinkel engl. "face form angle")
60  struct FaceFormAngle {
61  cv::Vec<double, n> mark;
62  cv::Vec<double, n> ring;
63  FaceFormAngle& operator= (const FaceFormAngle& ffa)
64  {
65  mark = ffa.mark;
66  ring = ffa.ring;
67  return *this;
68  }
69  } ffa[LATERAL_SIDE];
70 };
71 
72 template <int n> struct Front1Cam : public FrontGeneral<n>, public FrontMarks<n>
73 {
74 };
75 
76 typedef Front1Cam<2> FrontPic2D;
77 typedef Front1Cam<3> FrontPic3D;
78 
81 struct FrontB : public FrontGeneral<3>
82 {
83  cv::Vec3d K[LATERAL_SIDE];
84  cv::Vec3d Null_nrect_P[LATERAL_SIDE];
85  cv::Vec3d Null_rect_P[LATERAL_SIDE];
86  // erc = eye rotation center, Augendrehpunkt
87  cv::Vec3d erc[LATERAL_SIDE];
88 };
89 
92 struct Marks
93 {
94  cv::Vec3d M_R;
95  cv::Vec3d M_L;
96  cv::Vec3d M_M;
97 };
98 
100 struct Front3D : FrontB, Marks
101 {
102 };
103 
104 template <int n> class SidePic
105 {
106 public:
107  // Vektoren enthalten die Koordinaten auf der Bildebene
108  cv::Vec<double, n> m_O;
109  cv::Vec<double, n> m_U;
110  //cv::Vec<double, n> ffaRing;
111  FrameSideView<n> frame;
112  cv::Vec<double, n> pupil;
113  cv::Vec<double, n> cornealVertex; //Hornhautscheitel
114 };
115 
116 typedef SidePic<2> SidePic2D;
117 typedef SidePic<3> SidePic3D;
118 
119 
122 struct Side3D {
123  cv::Vec3d M_O;
124  cv::Vec3d M_U;
125  FrameSideView<3> frame;
126  cv::Vec3d pupil;
127 };
128 
129 
132 struct SideB {
133  FrameSideView<3> frame;
134  cv::Vec3d pupil;
135 };
136 
137 
138 class Aspect {
139 public:
140  ExposureArrangement exposureArrangement;
142  cv::Vec3d O_B;
143  Aspect(const PhotoParams& photoValues);
144  virtual ~Aspect() {};
146  cv::Vec3d imagePoint2dTo3d(const cv::Vec2d& point2D) const;
148  cv::Vec2d imagePoint3dTo2d(const cv::Vec3d& point3D) const;
150  cv::Vec3d transformToB(const cv::Vec3d& point) const;
152  cv::Vec3d transformFromB(const cv::Vec3d& point) const;
154  const cv::Matx33d& getRotationMatrixBToCam3d() const;
156  vr::Line getViewRay(const cv::Vec2d& point) const;
158  vr::Line getViewRay(const cv::Vec3d& point) const;
159 protected:
160  cv::Matx33d cameraMatrix;
164  cv::Matx33d R_;
166  cv::Matx33d _2dTo3d;
168  cv::Matx33d _3dTo2d;
169  virtual cv::Matx33d get2dTo3dMatrix(const PhotoParams& photoValues) = 0;
170 };
171 
173 static const double sign[LATERAL_SIDE] = {+1.0, -1.0};
174 
175 class SideAspect : public Aspect {
176 public:
177  SidePic2D im2D;
178  SidePic3D im3D;
179  Side3D S;
180  SideB B;
181  LateralSide side_;
182  SideAspect(const PhotoParams& photoValues, const LateralSide side);
183  virtual ~SideAspect() {};
185  void computeRotationMatrix();
187  void computeO_B();
189  void transformSToB();
190  void transform2Dto3D();
191  void printTo(std::ofstream& rFile) const;
192 protected:
193  cv::Matx33d get2dTo3dMatrix(const PhotoParams& photoValues);
194 private:
196  double getRotationAngle() const;
197 };
198 
199 class FrontAspect : public Aspect {
200 public:
201  FrontPic2D im2D; //Bildkoords
202  FrontPic3D im3D; //deren Koords im System F auf der Mattscheibe/Bildebene
203  Front3D& F; //Rekonstruktion im System F
204  FrontB B;
205  double approximateDistance;
206 
207  FrontAspect(Front3D& FIn, //Rekonstruktion im System F
208  const PhotoParams& frontValues);
209  virtual ~FrontAspect() {};
211  cv::Vec3d compute3D(const cv::Vec3d& p, double z);
212  void compute3D(const LateralSide halfFace, const SideAspect& side);
214  void transform2Dto3D(const LateralSide halfFace);
215  Line transformFToB(const Line& line) const;
216  void transformFToB(LateralSide d);
217  void transformFToB(const bool isRightAvailable, const bool isLeftAvailable);
220  int calcSys_B(const RealConstants& real, double* residuum);
221  int calcSys_BfromExtern(const RealConstants& real, double* residuum,
222  const cv::Vec2d& m_R, const cv::Vec2d& m_L, const cv::Vec2d& m_M);
223 
229  cv::Vec2d XClampToXIm(const cv::Vec3d& XClamp) const;
230  cv::Vec3d XImToXClamp(const cv::Point2d& XIm) const;
231 
232  double getComputedDistance() const { return computedDistance_; };
233 
234  void printTo(std::ofstream& rFile) const;
235 protected:
236  cv::Matx33d get2dTo3dMatrix(const PhotoParams& photoValues);
237 private:
238  double computedDistance_;
239  void getSys_B(std::vector<float>& null_B, std::vector<float>& axis_B) const;
240  void computeSpringStrutPosition(LateralSide side);
241 };
242 
243 } // namespace vr
244 
245 cv::Vec3d getCol(const cv::Matx33d& m, int i);
246 
247 
248 #endif // ASPECT_H
Definition: aspect.h:44
Koordinatensystemunabhängige Daten, Dinge, die innerhalb der Engine sind und defaultwerte.
Definition: RealConstants.h:5
cv::Vec2d imagePoint3dTo2d(const cv::Vec3d &point3D) const
Projektion auf Bildebene (3D) -> Bildkoordinaten.
Definition: aspect.cpp:42
Definition: aspect.h:81
cv::Matx33d _3dTo2d
Trafo-Matrix Projektion auf Bildebene -> Bild.
Definition: aspect.h:168
vr::Line getViewRay(const cv::Vec2d &point) const
Sehstrahl zum Bildpunkt point, ins Bügelsystem transformiert.
Definition: aspect.cpp:67
const cv::Matx33d & getRotationMatrixBToCam3d() const
Drehmatrix Bügelsystem -> Kamera-3d.
Definition: aspect.cpp:26
cv::Vec3d compute3D(const cv::Vec3d &p, double z)
Ermittelt den Raumpunkt eines Punktes auf dem Frontalbild, z ist die zuvor ermittelte Tiefe im Bügels...
Definition: aspect.cpp:102
Definition: aspect.h:27
Definition: aspect.h:12
int calcSys_BfromExtern(const RealConstants &real, double *residuum, const cv::Vec2d &m_R, const cv::Vec2d &m_L, const cv::Vec2d &m_M)
Definition: aspect.cpp:269
Definition: aspect.h:199
cv::Vec< double, n > bottom
Definition: aspect.h:39
Definition: aspect.h:60
Definition: aspect.h:175
cv::Matx33d R_
Definition: aspect.h:164
Definition: aspect.h:122
int calcSys_B(const RealConstants &real, double *residuum)
Definition: aspect.cpp:206
cv::Vec3d transformToB(const cv::Vec3d &point) const
Koordinatentransformation Kamera-3d -> Bügelsystem.
Definition: aspect.cpp:49
void computeRotationMatrix()
Berechnet die Drehmatrix.
Definition: aspect.cpp:356
Definition: aspect.h:92
Definition: aspect.h:72
Definition: aspect.h:132
Definition: aspect.h:53
void computeO_B()
Berechnet Bügel-Null im Kamerasystem S.
Definition: aspect.cpp:367
Definition: aspect.h:104
Definition: aspect.h:100
cv::Vec3d O_B
Definition: aspect.h:142
Definition: aspect.h:35
cv::Vec3d transformFromB(const cv::Vec3d &point) const
Koordinatentransformation Bügelsystem -> Kamera-3d.
Definition: aspect.cpp:58
void transform2Dto3D(const LateralSide halfFace)
für Gesichtshälfte halfFace
Definition: aspect.cpp:155
cv::Matx33d _2dTo3d
Trafo-Matrix Bild -> Projektion auf Bildebene.
Definition: aspect.h:166
Definition: aspect.h:17
void transformSToB()
Transformiert die Raumpunkte in S in Punkte in B.
Definition: aspect.cpp:378
cv::Vec3d imagePoint2dTo3d(const cv::Vec2d &point2D) const
Bildkoordinaten -> Projektion auf Bildebene.
Definition: aspect.cpp:31
Definition: aspect.h:138
Definition: PhotoParams.h:27
Gerade im Raum.
Definition: algorithms.h:22
cv::Vec2d XClampToXIm(const cv::Vec3d &XClamp) const
Definition: aspect.cpp:328