NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
mitkFindAndTriangulateCrossHair.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef mitkFindAndTriangulateCrossHair_h
16 #define mitkFindAndTriangulateCrossHair_h
17 
18 #include "niftkOpenCVExports.h"
19 #include <string>
20 #include <itkObject.h>
21 #include <itkObjectFactory.h>
22 #include <mitkCommon.h>
23 #include <cv.h>
24 #include <highgui.h>
26 
27 namespace mitk {
28 
41 {
42 
43 public:
44 
45  mitkClassMacroItkParent(FindAndTriangulateCrossHair, itk::Object)
46  itkNewMacro(FindAndTriangulateCrossHair)
47 
48 
53  void Initialise (std::string directory, std::string calibrationParameterDirectory);
54 
59  void Triangulate();
60 
61  void SetVisualise( bool) ;
62  void SetSaveVideo( bool);
63  itkSetMacro ( TrackerIndex, int);
64  itkSetMacro ( FramesToProcess, int);
65  itkSetMacro ( HaltOnVideoReadFail, bool);
66  itkGetMacro ( PointsInLeftLensCS, std::vector<mitk::WorldPoint> );
67  itkGetMacro ( WorldPoints, std::vector<mitk::WorldPoint> );
68  itkGetMacro ( ScreenPoints, std::vector<mitk::ProjectedPointPair> );
69  itkGetMacro ( InitOK, bool);
70  itkGetMacro ( TriangulateOK, bool);
71 
75  void SetFlipMatrices (bool);
76 
80  void SetVideoLagMilliseconds (unsigned long long videoLag, bool videoLeadsTracking = false);
81 
82 protected:
83 
85  virtual ~FindAndTriangulateCrossHair();
86 
87  FindAndTriangulateCrossHair(const FindAndTriangulateCrossHair&); // Purposefully not implemented.
88  FindAndTriangulateCrossHair& operator=(const FindAndTriangulateCrossHair&); // Purposefully not implemented.
89 
90 private:
91  bool m_Visualise; // if true the project function attempts to open a couple of windows to show projection in real time
92  bool m_SaveVideo; // if true the project function will buffer frames into a object to write out.
93  std::string m_VideoIn; // the video in file
94  std::string m_VideoOut; // video needs to be saved on the fly
95  std::string m_Directory; // the directory containing the data
96 
97  std::vector<mitk::WorldPoint> m_WorldPoints; // the triangulated points in world coordinates
98  std::vector<mitk::WorldPoint> m_PointsInLeftLensCS; // the triangulated points in world coordinates
99  int m_TrackerIndex; // the tracker index to use for frame matching
100  mitk::VideoTrackerMatching::Pointer
101  m_TrackerMatcher; //the tracker matcher
102 
103  bool m_InitOK;
104  bool m_TriangulateOK;
105 
106  int m_FramesToProcess; //can stop early, if negative it runs to the end
107 
108  // The camera calibration parameters
109  cv::Mat* m_LeftIntrinsicMatrix;
110  cv::Mat* m_LeftDistortionVector;
111  cv::Mat* m_RightIntrinsicMatrix;
112  cv::Mat* m_RightDistortionVector;
113  cv::Mat* m_RightToLeftRotationMatrix;
114  cv::Mat* m_RightToLeftTranslationVector;
115  cv::Mat* m_LeftCameraToTracker;
116 
117  // The video screen dimensions
118  double m_VideoWidth;
119  double m_VideoHeight;
120  double m_DefaultVideoWidth;
121  double m_DefaultVideoHeight;
122 
123  std::vector < mitk::ProjectedPointPair >
124  m_ScreenPoints; // the projected points
125 
126  cv::VideoCapture* m_Capture;
127  bool m_HaltOnVideoReadFail;
128  CvVideoWriter* m_Writer;
129 
130  cv::Size m_BlurKernel; // For blurring
131 
132  double m_HoughRho; // For the hough filter
133  double m_HoughTheta; // For the hough filter
134  int m_HoughThreshold; // For the hough filter
135  int m_HoughLineLength; // For the hough filter
136  int m_HoughLineGap; // For the hough filter
137 
138  void TriangulatePoints();
139  void TransformPointsToWorld();
140 
141 }; // end class
142 
143 } // end namespace
144 
145 #endif
Definition: ReceptorMemberCommandTest.cxx:25
Definition: mitkFindAndTriangulateCrossHair.h:40
#define NIFTKOPENCV_EXPORT
Definition: niftkSequentialCpuQds.h:27
std::vector< mitk::WorldPoint > Triangulate(const std::vector< mitk::ProjectedPointPair > &onScreenPointPairs, const cv::Mat &leftIntrinsicMatrix, const cv::Mat &leftDistortionVector, const cv::Mat &rightIntrinsicMatrix, const cv::Mat &rightDistortionVector, const cv::Mat &rightToLeftRotationMatrix, const cv::Mat &rightToLeftTranslationVector, const bool &cropPointsToScreen, const double &xLow, const double &xHigh, const double &yLow, const double &yHigh, const double &cropValue)
Wrapper to triangulate vector of mitk::ProjectedPointPair to vector of mitk::WorldPoint.
Definition: mitkCameraCalibrationFacade.cxx:1933
GLsizei const GLcharARB ** string
Definition: glew.h:5194