MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkUndistortCameraImage.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#ifndef mitkUndistortCameraImage_h
14#define mitkUndistortCameraImage_h
15
16#include "mitkCommon.h"
17#include <MitkOpenCVVideoSupportExports.h>
18#include "itkObject.h"
19
20#include "mitkPoint.h"
21
22#include <opencv2/core.hpp>
23#include <opencv2/core/types_c.h>
24
39namespace mitk
40{
41
42class MITKOPENCVVIDEOSUPPORT_EXPORT UndistortCameraImage : public itk::Object
43{
44 public:
45
49
51 /*
52 * Set the camera's intrinsic focal length
53 */
54 void SetFocalLength(float fc_x, float fc_y)
55 {
56 m_fcX = fc_x; m_fcY = fc_y;
57 }
58 /*
59 * Set the camera's intrinsic principal point
60 */
61 void SetPrincipalPoint(float cc_x, float cc_y)
62 {
63 m_ccX = cc_x; m_ccY = cc_y;
64 }
65 /*
66 * Set the camera's intrinsic distortion parameters
67 */
68 void SetCameraDistortion(float kc1, float kc2, float kc3, float kc4)
69 {
70 m_distortionMatrixData[0] = kc1; m_distortionMatrixData[1] = kc2;
71 m_distortionMatrixData[2] = kc3; m_distortionMatrixData[3] = kc4;
72 }
73 /*
74 * Pre-Calculates matrices for the later use of UndistortImageFast()
75 */
76 void InitRemapUndistortion(int sizeX, int sizeY);
77
79 /*
80 * Undistort a single pixel, returns undistorted pixel
81 */
82 mitk::Point2D UndistortPixel(const mitk::Point2D& src);
83 /*
84 * Complete undistortion of an OpenCV image, including all calculations
85 */
86 void UndistortImage(IplImage* src, IplImage* dst);
87
88
89 /*
90 * Complete undistortion of an OpenCV image, using pre-calculated matrices from SetUndistortImageFastInfo()
91 * The use of only a source parameter will cause the source to be overwritten.
92 * NOTE: Using the Fast undistortion methods does not require a initialization via the Set... methods.
93 */
94 void UndistortImageFast( IplImage * src, IplImage* dst = nullptr );
95 void SetUndistortImageFastInfo(float in_dF1, float in_dF2,
96 float in_dPrincipalX, float in_dPrincipalY,
97 float in_Dist[4], float ImageSizeX, float ImageSizeY);
98
100 ~UndistortCameraImage() override;
101
102 protected:
103
104 // principal point and focal length parameters
105 float m_ccX, m_ccY, m_fcX, m_fcY;
106 // undistortion parameters
107 float m_distortionMatrixData[4];
108 // intrinsic camera parameters
109 float m_intrinsicMatrixData[9];
110 // precalculated matrices for fast image undistortion with UndistortImageFast()
111 CvMat * m_mapX, * m_mapY;
112 // intrinsic and undistortion camera matrices
113 CvMat m_intrinsicMatrix, m_distortionMatrix;
114 // temp image
115 IplImage * m_tempImage;
116
117
118
121};
122
123}
124
125#endif
void SetPrincipalPoint(float cc_x, float cc_y)
mitkClassMacroItkParent(UndistortCameraImage, itk::Object)
void SetCameraDistortion(float kc1, float kc2, float kc3, float kc4)
void SetFocalLength(float fc_x, float fc_y)
Initialization ///.
void InitRemapUndistortion(int sizeX, int sizeY)
IGT Exceptions.