Medical Imaging Interaction Toolkit  2018.4.99-6a3ea89d
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef mitkCameraIntrinsics_h
15 #define mitkCameraIntrinsics_h
16 
17 #include <mitkCommon.h>
18 #include <mitkNumericTypes.h>
19 #include <itkDataObject.h>
20 #include <itkFastMutexLock.h>
21 #include <vnl/vnl_matrix_fixed.h>
22 #include "mitkXMLSerializable.h"
24 
25 #include "opencv2/core.hpp"
26 
27 int mitkCameraIntrinsicsTest(int, char* []);
28 
29 namespace mitk
30 {
34  class MITKCAMERACALIBRATION_EXPORT CameraIntrinsics: virtual public itk::Object,
35  virtual public mitk::XMLSerializable
36  {
37  public:
41  friend int mitkCameraIntrinsicsTest(int argc, char* argv[]);
49  itkFactorylessNewMacro(Self);
50 
54  itkCloneMacro(Self);
55 
59  void Copy(const CameraIntrinsics* other);
60 
64  bool Equals( const CameraIntrinsics* other ) const;
65 
69  vnl_matrix_fixed<mitk::ScalarType, 3, 3> GetVnlCameraMatrix() const;
70 
75  vnl_matrix_fixed<mitk::ScalarType, 3, 4> GetVnlCameraMatrix3x4() const;
76 
81  bool IsValid() const;
82  void SetValid(bool valid);
83  cv::Mat GetCameraMatrix() const;
84  cv::Mat GetDistorsionCoeffs();
85  cv::Mat GetDistorsionCoeffs() const;
86  void ToXML(TiXmlElement* elem) const override;
87  std::string ToString() const;
88  std::string GetString();
89  double GetFocalLengthX() const;
90  double GetFocalLengthY() const;
91  double GetPrincipalPointX() const;
92  double GetPrincipalPointY() const;
93  mitk::Point4D GetDistorsionCoeffsAsPoint4D() const;
94  mitk::Point3D GetFocalPoint() const;
95  mitk::Point3D GetPrincipalPoint() const;
96  vnl_vector_fixed<mitk::ScalarType, 2> GetFocalPointAsVnlVector() const;
97  vnl_vector_fixed<mitk::ScalarType, 2> GetPrincipalPointAsVnlVector() const;
98 
102  void SetCameraMatrix( const vnl_matrix_fixed<mitk::ScalarType, 3, 3>&
103  _CameraMatrix );
104 
105  void SetIntrinsics( const cv::Mat& _CameraMatrix
106  , const cv::Mat& _DistorsionCoeffs);
107 
108  void SetFocalLength( double x, double y );
109  void SetPrincipalPoint( double x, double y );
110  void SetDistorsionCoeffs( double k1, double k2, double p1, double p2 );
111 
112  void SetIntrinsics( const mitk::Point3D& focalPoint,
113  const mitk::Point3D& principalPoint,
114  const mitk::Point4D& distortionCoefficients);
115 
116  void FromXML(TiXmlElement* elem) override;
117  void FromGMLCalibrationXML(TiXmlElement* elem);
118  std::string ToOctaveString(const std::string& varName="CameraIntrinsics");
119 
120  ~CameraIntrinsics() override;
121 
122  protected:
124  CameraIntrinsics(const CameraIntrinsics& other);
125 
126  cv::Mat m_CameraMatrix;
128  bool m_Valid;
129  itk::FastMutexLock::Pointer m_Mutex;
130 
131  private:
132 
133  itk::LightObject::Pointer InternalClone() const override;
134  };
135 
136 } // namespace mitk
137 
138 MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
139  (std::ostream& os, mitk::CameraIntrinsics::Pointer p);
140 
141 #endif // mitkCameraIntrinsics_h
class representing camera intrinsics and related functions
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKCAMERACALIBRATION_EXPORT
itk::FastMutexLock::Pointer m_Mutex
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
int mitkCameraIntrinsicsTest(int, char *[])
interface for all classes able to write themselves to XML files