cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svlCameraGeometry.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Balazs Vagvolgyi
7  Created on: 2009
8 
9  (C) Copyright 2006-2008 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _svlCameraGeometry_h
23 #define _svlCameraGeometry_h
24 
25 #include <ostream>
28 
29 // Always include last!
31 
33 {
34 public:
35  typedef struct _Intrinsics {
36  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const _Intrinsics & objref);
37 
38  double fc[2];
39  double cc[2];
40  double a;
41  double kc[5];
42  } Intrinsics;
43 
44  typedef struct _Extrinsics {
45  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const _Extrinsics & objref);
46 
50  } Extrinsics;
51 
52 public:
53  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlCameraGeometry & objref);
54 
55  void SetIntrinsics(const Intrinsics & intrinsics, const unsigned int cam_id = 0);
56  void SetIntrinsics(const double fc[2], const double cc[2], const double a, const double kc[5], const unsigned int cam_id = 0);
57  void SetIntrinsics(const double fcx, const double fcy,
58  const double ccx, const double ccy,
59  const double a,
60  const double kc0, const double kc1, const double kc2, const double kc3, const double kc4,
61  const unsigned int cam_id = 0);
62  void SetExtrinsics(const Extrinsics & extrinsics, const unsigned int cam_id = 0);
63  void SetExtrinsics(const double om[3], const double T[3], const unsigned int cam_id = 0);
64  void SetExtrinsics(const double om0, const double om1, const double om2,
65  const double T0, const double T1, const double T2,
66  const unsigned int cam_id = 0);
67  void SetPerspective(const double focallength, const unsigned int width, const unsigned int height, const unsigned int cam_id = 0);
68  int LoadCalibration(const std::string & filepath);
69 
70  int GetIntrinsics(Intrinsics & intrinsics, const unsigned int cam_id = 0) const;
71  Intrinsics GetIntrinsics(const unsigned int cam_id = 0) const;
72  const Intrinsics* GetIntrinsicsPtr(const unsigned int cam_id = 0) const;
73  int GetIntrinsics(double& fcx, double& fcy,
74  double& ccx, double& ccy,
75  double& a,
76  double& kc0, double& kc1, double& kc2, double& kc3, double& kc4,
77  const unsigned int cam_id = 0);
78  int GetExtrinsics(Extrinsics & extrinsics, const unsigned int cam_id = 0) const;
79  Extrinsics GetExtrinsics(const unsigned int cam_id = 0) const;
80  const Extrinsics* GetExtrinsicsPtr(const unsigned int cam_id = 0) const;
81  int GetExtrinsics(double& om0, double& om1, double& om2,
82  double& T0, double& T1, double& T2,
83  const unsigned int cam_id = 0);
84 
85  int GetPosition(vctDouble3 & position, const unsigned int cam_id = 0) const;
86  int GetAxis(vctDouble3 & axis, const unsigned int cam_id = 0) const;
87  int GetViewUp(vctDouble3 & viewup, const unsigned int cam_id = 0) const;
88  int GetPositionAxisViewUp(vctDouble3 & position, vctDouble3 & axis, vctDouble3 & viewup, const unsigned int cam_id = 0) const;
89  double GetViewAngleHorizontal(double imagewidth, const unsigned int cam_id = 0) const;
90  double GetViewAngleVertical(double imageheight, const unsigned int cam_id = 0) const;
91 
92  int IsCameraPerspective(const unsigned int cam_id) const;
93  int IsCameraPairRectified(const unsigned int cam_id1, const unsigned int cam_id2) const;
94 
95  int SetWorldToCenter();
96  int RotateWorldAboutY(double degrees);
97  int RotateWorldAboutZ(double degrees);
98 
99  void Wrld2Cam(const unsigned int cam_id, vctDouble2 & point2D, const vctDouble3 & point3D);
100  vctDouble2 Wrld2Cam(const unsigned int cam_id, const vctDouble3 & point3D);
101 
102  template<class _ValueType>
103  void Cam2Wrld(vctFixedSizeVector<_ValueType, 3>& point3D,
104  const unsigned int cam_id1,
105  const vctFixedSizeVector<_ValueType, 2>& point2D_1,
106  const unsigned int cam_id2,
107  const vctFixedSizeVector<_ValueType, 2>& point2D_2);
108 
109  template<class _ValueType>
110  vctFixedSizeVector<_ValueType, 3> Cam2Wrld(const unsigned int cam_id1,
111  const vctFixedSizeVector<_ValueType, 2>& point2D_1,
112  const unsigned int cam_id2,
113  const vctFixedSizeVector<_ValueType, 2>& point2D_2);
114 
115  void Empty();
116 
117 private:
118  vctDynamicVector<Intrinsics> IntrinsicParams;
119  vctDynamicVector<Extrinsics> ExtrinsicParams;
120 };
121 
122 
123 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlCameraGeometry::_Intrinsics & objref);
124 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlCameraGeometry::_Extrinsics & objref);
125 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlCameraGeometry & objref);
126 
127 
128 #endif // _svlCameraGeometry_h
129 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
A vector object of dynamic size.
Definition: vctDynamicVector.h:127
CISST_EXPORT std::ostream & operator<<(std::ostream &stream, const svlCameraGeometry::_Intrinsics &objref)
vctDouble3 T
Definition: svlCameraGeometry.h:48
Typedef for fixed size vectors.
vctDoubleRodRot3 om
Definition: svlCameraGeometry.h:47
vctDoubleFrm4x4 frame
Definition: svlCameraGeometry.h:49
Typedef for different transformations.
double a
Definition: svlCameraGeometry.h:40
Macros to export the symbols of cisstStereoVision (in a Dll).
Definition: svlCameraGeometry.h:32
Definition: svlCameraGeometry.h:35
Definition: svlCameraGeometry.h:44