Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCameraIntrinsics.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef mitkCameraIntrinsics_h
19 #define mitkCameraIntrinsics_h
20 
21 #include <mitkCommon.h>
22 #include <mitkNumericTypes.h>
23 #include <itkDataObject.h>
24 #include <itkFastMutexLock.h>
25 #include <cv.h>
26 #include <vnl/vnl_matrix_fixed.h>
27 #include "mitkXMLSerializable.h"
28 #include <MitkCameraCalibrationExports.h>
29 
30 int mitkCameraIntrinsicsTest(int argc, char* argv[]);
31 
32 namespace mitk
33 {
37  class MITKCAMERACALIBRATION_EXPORT CameraIntrinsics: virtual public itk::Object,
38  virtual public mitk::XMLSerializable
39  {
40  public:
44  friend int mitkCameraIntrinsicsTest(int argc, char* argv[]);
52  itkFactorylessNewMacro(Self);
53 
57  itkCloneMacro(Self)
58 
59 
60  void Copy(const CameraIntrinsics* other);
63 
67  bool Equals( const CameraIntrinsics* other ) const;
68 
72  vnl_matrix_fixed<mitk::ScalarType, 3, 3> GetVnlCameraMatrix() const;
73 
78  vnl_matrix_fixed<mitk::ScalarType, 3, 4> GetVnlCameraMatrix3x4() const;
79 
84  bool IsValid() const;
85  void SetValid(bool valid);
86  cv::Mat GetCameraMatrix() const;
87  cv::Mat GetDistorsionCoeffs();
88  cv::Mat GetDistorsionCoeffs() const;
89  void ToXML(TiXmlElement* elem) const override;
90  std::string ToString() const;
91  std::string GetString();
92  double GetFocalLengthX() const;
93  double GetFocalLengthY() const;
94  double GetPrincipalPointX() const;
95  double GetPrincipalPointY() const;
96  mitk::Point4D GetDistorsionCoeffsAsPoint4D() const;
97  mitk::Point3D GetFocalPoint() const;
98  mitk::Point3D GetPrincipalPoint() const;
99  vnl_vector_fixed<mitk::ScalarType, 2> GetFocalPointAsVnlVector() const;
100  vnl_vector_fixed<mitk::ScalarType, 2> GetPrincipalPointAsVnlVector() const;
101 
105  void SetCameraMatrix( const vnl_matrix_fixed<mitk::ScalarType, 3, 3>&
106  _CameraMatrix );
107 
108  void SetIntrinsics( const cv::Mat& _CameraMatrix
109  , const cv::Mat& _DistorsionCoeffs);
110 
111  void SetFocalLength( double x, double y );
112  void SetPrincipalPoint( double x, double y );
113  void SetDistorsionCoeffs( double k1, double k2, double p1, double p2 );
114 
115  void SetIntrinsics( const mitk::Point3D& focalPoint,
116  const mitk::Point3D& principalPoint,
117  const mitk::Point4D& distortionCoefficients);
118 
119  void FromXML(TiXmlElement* elem) override;
120  void FromGMLCalibrationXML(TiXmlElement* elem);
121  std::string ToOctaveString(const std::string& varName="CameraIntrinsics");
122 
123  virtual ~CameraIntrinsics();
124 
125  protected:
127  CameraIntrinsics(const CameraIntrinsics& other);
128 
129  cv::Mat m_CameraMatrix;
131  bool m_Valid;
133 
134  private:
135 
136  virtual itk::LightObject::Pointer InternalClone() const override;
137  };
138 
139 } // namespace mitk
140 
141 MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
142  (std::ostream& os, mitk::CameraIntrinsics::Pointer p);
143 
144 #endif // mitkCameraIntrinsics_h
itk::SmartPointer< Self > Pointer
class representing camera intrinsics and related functions
DataCollection - Class to facilitate loading/accessing structured data.
itk::FastMutexLock::Pointer m_Mutex
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
interface for all classes able to write themselves to XML files
int mitkCameraIntrinsicsTest(int argc, char *argv[])