Medical Imaging Interaction Toolkit  2022.10.99-122321bb
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 <vnl/vnl_matrix_fixed.h>
21 #include "mitkXMLSerializable.h"
23 
24 #include "opencv2/core.hpp"
25 
26 #include <mutex>
27 
28 int mitkCameraIntrinsicsTest(int, char* []);
29 
30 namespace mitk
31 {
35  class MITKCAMERACALIBRATION_EXPORT CameraIntrinsics: virtual public itk::Object,
36  virtual public mitk::XMLSerializable
37  {
38  public:
42  friend int mitkCameraIntrinsicsTest(int argc, char* argv[]);
50  itkFactorylessNewMacro(Self);
51 
55  itkCloneMacro(Self);
56 
60  void Copy(const CameraIntrinsics* other);
61 
65  bool Equals( const CameraIntrinsics* other ) const;
66 
70  vnl_matrix_fixed<mitk::ScalarType, 3, 3> GetVnlCameraMatrix() const;
71 
76  vnl_matrix_fixed<mitk::ScalarType, 3, 4> GetVnlCameraMatrix3x4() const;
77 
82  bool IsValid() const;
83  void SetValid(bool valid);
84  cv::Mat GetCameraMatrix() const;
85  cv::Mat GetDistorsionCoeffs();
86  cv::Mat GetDistorsionCoeffs() const;
87  void ToXML(tinyxml2::XMLElement* elem) const override;
88  std::string ToString() const;
89  std::string GetString();
90  double GetFocalLengthX() const;
91  double GetFocalLengthY() const;
92  double GetPrincipalPointX() const;
93  double GetPrincipalPointY() const;
94  mitk::Point4D GetDistorsionCoeffsAsPoint4D() const;
95  mitk::Point3D GetFocalPoint() const;
96  mitk::Point3D GetPrincipalPoint() const;
97  vnl_vector_fixed<mitk::ScalarType, 2> GetFocalPointAsVnlVector() const;
98  vnl_vector_fixed<mitk::ScalarType, 2> GetPrincipalPointAsVnlVector() const;
99 
103  void SetCameraMatrix( const vnl_matrix_fixed<mitk::ScalarType, 3, 3>&
104  _CameraMatrix );
105 
106  void SetIntrinsics( const cv::Mat& _CameraMatrix
107  , const cv::Mat& _DistorsionCoeffs);
108 
109  void SetFocalLength( double x, double y );
110  void SetPrincipalPoint( double x, double y );
111  void SetDistorsionCoeffs( double k1, double k2, double p1, double p2 );
112 
113  void SetIntrinsics( const mitk::Point3D& focalPoint,
114  const mitk::Point3D& principalPoint,
115  const mitk::Point4D& distortionCoefficients);
116 
117  void FromXML(const tinyxml2::XMLElement* elem) override;
118  void FromGMLCalibrationXML(const tinyxml2::XMLElement* elem);
119  std::string ToOctaveString(const std::string& varName="CameraIntrinsics");
120 
121  ~CameraIntrinsics() override;
122 
123  protected:
125  CameraIntrinsics(const CameraIntrinsics& other);
126 
127  cv::Mat m_CameraMatrix;
129  bool m_Valid;
130  mutable std::mutex m_Mutex;
131 
132  private:
133 
134  itk::LightObject::Pointer InternalClone() const override;
135  };
136 
137 } // namespace mitk
138 
139 MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
140  (std::ostream& os, mitk::CameraIntrinsics::Pointer p);
141 
142 #endif // mitkCameraIntrinsics_h
mitkCameraIntrinsicsTest
int mitkCameraIntrinsicsTest(int, char *[])
mitk::XMLSerializable
interface for all classes able to write themselves to XML files
Definition: mitkXMLSerializable.h:30
mitk::CameraIntrinsics
class representing camera intrinsics and related functions
Definition: mitkCameraIntrinsics.h:35
mitkXMLSerializable.h
MitkCameraCalibrationExports.h
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
MITKCAMERACALIBRATION_EXPORT
#define MITKCAMERACALIBRATION_EXPORT
Definition: MitkCameraCalibrationExports.h:15
mitk::CameraIntrinsics::m_CameraMatrix
cv::Mat m_CameraMatrix
Definition: mitkCameraIntrinsics.h:127
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::Point
Definition: mitkPoint.h:36
mitkNumericTypes.h
mitkCommon.h
mitk::CameraIntrinsics::m_DistorsionCoeffs
cv::Mat m_DistorsionCoeffs
Definition: mitkCameraIntrinsics.h:128
mitk::CameraIntrinsics::m_Valid
bool m_Valid
Definition: mitkCameraIntrinsics.h:129
mitk::CameraIntrinsics::m_Mutex
std::mutex m_Mutex
Definition: mitkCameraIntrinsics.h:130