cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svlSampleCameraGeometry.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: 2011
8 
9  (C) Copyright 2006-2011 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 _svlSampleCameraGeometry_h
23 #define _svlSampleCameraGeometry_h
24 
28 #include <ostream>
29 
30 // Always include last!
32 
33 
35 {
37 
38 public:
39  struct Intrinsics
40  {
41  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const Intrinsics & objref);
42 
45  double a;
47  };
48 
49  struct Extrinsics
50  {
51  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const Extrinsics & objref);
52 
56  };
57 
58 public:
59  friend CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlSampleCameraGeometry & objref);
60 
64 
65  svlSample* GetNewInstance() const;
66  svlStreamType GetType() const;
67  int SetSize(const svlSample* sample);
68  int SetSize(const svlSample& sample);
69  int CopyOf(const svlSample* sample);
70  int CopyOf(const svlSample& sample);
71  bool IsInitialized() const;
72  unsigned char* GetUCharPointer();
73  const unsigned char* GetUCharPointer() const;
74  unsigned int GetDataSize() const;
75  void SerializeRaw(std::ostream & outputStream) const;
76  void DeSerializeRaw(std::istream & inputStream);
77 
78  svlSampleCameraGeometry(const std::string & calibration_filepath);
79 
80  unsigned int GetCameraCount() const;
81 
82  int LoadCalibration(const std::string & filepath);
83 
84  void SetIntrinsics(const Intrinsics & intrinsics, const unsigned int cam_id = 0);
85  void SetIntrinsics(const vctDouble2 fc, const vctDouble2 cc, const double a, const vctDouble7 kc, const unsigned int cam_id = 0);
86  void SetIntrinsics(const double fcx, const double fcy,
87  const double ccx, const double ccy,
88  const double a,
89  const double kc0, const double kc1, const double kc2, const double kc3, const double kc4, const double kc5, const double kc6,
90  const unsigned int cam_id = 0);
91  void SetExtrinsics(const Extrinsics & extrinsics, const unsigned int cam_id = 0);
92  void SetExtrinsics(const vctDouble3 om, const vctDouble3 T, const unsigned int cam_id = 0);
93  void SetExtrinsics(const double om0, const double om1, const double om2,
94  const double T0, const double T1, const double T2,
95  const unsigned int cam_id = 0);
96 
97  int GetIntrinsics(Intrinsics & intrinsics, const unsigned int cam_id = 0) const;
98  Intrinsics GetIntrinsics(const unsigned int cam_id = 0) const;
99  const Intrinsics* GetIntrinsicsPtr(const unsigned int cam_id = 0) const;
100  int GetIntrinsics(double& fcx, double& fcy,
101  double& ccx, double& ccy,
102  double& a,
103  double& kc0, double& kc1, double& kc2, double& kc3, double& kc4, double& kc5, double& kc6,
104  const unsigned int cam_id = 0);
105  int GetExtrinsics(Extrinsics & extrinsics, const unsigned int cam_id = 0) const;
106  Extrinsics GetExtrinsics(const unsigned int cam_id = 0) const;
107  const Extrinsics* GetExtrinsicsPtr(const unsigned int cam_id = 0) const;
108  int GetExtrinsics(double& om0, double& om1, double& om2,
109  double& T0, double& T1, double& T2,
110  const unsigned int cam_id = 0);
111 
112  void SetPerspective(const double focallength, const unsigned int width, const unsigned int height, const unsigned int cam_id = 0);
113 
114  int GetPosition(vctDouble3 & position, const unsigned int cam_id = 0) const;
115  int GetAxis(vctDouble3 & axis, const unsigned int cam_id = 0) const;
116  int GetViewUp(vctDouble3 & viewup, const unsigned int cam_id = 0) const;
117  int GetPositionAxisViewUp(vctDouble3 & position, vctDouble3 & axis, vctDouble3 & viewup, const unsigned int cam_id = 0) const;
118  double GetViewAngleHorizontal(double imagewidth, const unsigned int cam_id = 0) const;
119  double GetViewAngleVertical(double imageheight, const unsigned int cam_id = 0) const;
120 
121  int IsCameraPerspective(const unsigned int cam_id) const;
122  int IsCameraPairRectified(const unsigned int cam_id1, const unsigned int cam_id2) const;
123 
124  int SetWorldToCenter();
125  int RotateWorldAboutY(double degrees);
126  int RotateWorldAboutZ(double degrees);
127 
128  void Wrld2Cam(const unsigned int cam_id, vctDouble2 & point2D, const vctDouble3 & point3D);
129  vctDouble2 Wrld2Cam(const unsigned int cam_id, const vctDouble3 & point3D);
130 
131  template<class _ValueType>
132  void Cam2Wrld(vctFixedSizeVector<_ValueType, 3>& point3D,
133  const unsigned int cam_id1,
134  const vctFixedSizeVector<_ValueType, 2>& point2D_1,
135  const unsigned int cam_id2,
136  const vctFixedSizeVector<_ValueType, 2>& point2D_2);
137 
138  template<class _ValueType>
139  vctFixedSizeVector<_ValueType, 3> Cam2Wrld(const unsigned int cam_id1,
140  const vctFixedSizeVector<_ValueType, 2>& point2D_1,
141  const unsigned int cam_id2,
142  const vctFixedSizeVector<_ValueType, 2>& point2D_2);
143 
144  void Empty();
145 
146 private:
147  vctDynamicVector<Intrinsics> IntrinsicVector;
148  vctDynamicVector<Extrinsics> ExtrinsicVector;
149 };
150 
152 
153 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlSampleCameraGeometry::Intrinsics & objref);
154 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlSampleCameraGeometry::Extrinsics & objref);
155 CISST_EXPORT std::ostream & operator << (std::ostream & stream, const svlSampleCameraGeometry & objref);
156 
157 #endif // _svlSampleCameraGeometry_h
158 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
vctDouble3 T
Definition: svlSampleCameraGeometry.h:54
virtual svlSample * GetNewInstance() const =0
A vector object of dynamic size.
Definition: vctDynamicVector.h:127
svlStreamType
Definition: svlDefinitions.h:193
#define CMN_DECLARE_SERVICES_INSTANTIATION_EXPORT(className)
Definition: cmnClassRegisterMacros.h:209
vctDouble2 fc
Definition: svlSampleCameraGeometry.h:43
virtual svlStreamType GetType() const =0
virtual int CopyOf(const svlSample *sample)=0
virtual unsigned char * GetUCharPointer()=0
Typedef for fixed size vectors.
virtual unsigned int GetDataSize() const =0
Typedef for different transformations.
svlSample & operator=(const svlSample &other)
virtual void SerializeRaw(std::ostream &outputStream) const =0
vctDouble7 kc
Definition: svlSampleCameraGeometry.h:46
CISST_EXPORT std::ostream & operator<<(std::ostream &stream, const svlSampleCameraGeometry::Intrinsics &objref)
double a
Definition: svlSampleCameraGeometry.h:45
vctDoubleFrm4x4 frame
Definition: svlSampleCameraGeometry.h:55
virtual int SetSize(const svlSample *sample)=0
virtual void DeSerializeRaw(std::istream &inputStream)=0
Definition: svlSampleCameraGeometry.h:49
Macros to export the symbols of cisstStereoVision (in a Dll).
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Definition: svlSampleCameraGeometry.h:39
virtual bool IsInitialized() const
vctDouble2 cc
Definition: svlSampleCameraGeometry.h:44
const int CMN_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:331
vctDoubleRodRot3 om
Definition: svlSampleCameraGeometry.h:53
Definition: svlSampleCameraGeometry.h:34
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
Definition: svlSample.h:31