NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
mitkVideoToSurface.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 mitkVideoToSurface_h
16 #define mitkVideoToSurface_h
17 
18 #include "niftkOpenCVExports.h"
19 #include <mitkOpenCVPointTypes.h>
20 #include <string>
21 #include <fstream>
22 #include <itkObject.h>
23 #include <itkObjectFactory.h>
24 #include <mitkCommon.h>
25 #include <cv.h>
26 #include <highgui.h>
28 
29 namespace mitk {
30 
39 class NIFTKOPENCV_EXPORT VideoToSurface : public itk::Object
40 {
41 
42 public:
43 
44  mitkClassMacroItkParent(VideoToSurface, itk::Object)
45  itkNewMacro(VideoToSurface)
46 
47 
52  void Initialise (std::string directory, std::string calibrationParameterDirectory);
58  void Initialise (std::string directory);
59 
64  void Reconstruct(mitk::VideoTrackerMatching::Pointer matcher);
65 
71  void SetMatcherCameraToTracker(mitk::VideoTrackerMatching::Pointer matcher);
72 
73  void SetSaveVideo( bool state );
74  itkSetMacro ( TrackerIndex, int);
75  itkSetMacro ( ReferenceIndex, int);
76  itkSetMacro ( EndFrame, unsigned int);
77  itkSetMacro ( HaltOnVideoReadFail, bool);
78  itkSetMacro ( VisualiseTrackingStatus, bool);
79  itkSetMacro ( AllowableTimingError, long long);
80 
81  itkGetMacro ( InitOK, bool);
82  itkGetMacro ( WorldToLeftCameraMatrices, std::vector < cv::Mat > );
83 
84 protected:
85 
87  virtual ~VideoToSurface();
88 
89  VideoToSurface(const VideoToSurface&); // Purposefully not implemented.
90  VideoToSurface& operator=(const VideoToSurface&); // Purposefully not implemented.
91 
92 private:
93  bool m_SaveVideo; //if true the project function will buffer frames into a object to write out.
94  std::string m_VideoIn; //the video in file
95  std::string m_VideoOut; //video needs to be saved on the fly
96  std::string m_Directory; //the directory containing the data
97  std::string m_OutDirectory; //where to write out any video
98 
99  int m_TrackerIndex; //the tracker index to use for frame matching
100  int m_ReferenceIndex; //the reference index to use for frame matching, not used by default
101 
102  bool m_InitOK;
103  bool m_HaltOnVideoReadFail; //stop processing if video read fails
104  bool m_VisualiseTrackingStatus; //draw something on screen to indicate whether tracking was working got frame
105 
106  unsigned int m_StartFrame; //you can exclude some frames at the start
107  unsigned int m_EndFrame; // and at the end
108 
109  double m_TriangulationTolerance;
110 
111  //the camera calibration parameters
112  cv::Mat* m_LeftIntrinsicMatrix;
113  cv::Mat* m_LeftDistortionVector;
114  cv::Mat* m_RightIntrinsicMatrix;
115  cv::Mat* m_RightDistortionVector;
116  cv::Mat* m_RightToLeftRotationMatrix;
117  cv::Mat* m_RightToLeftTranslationVector;
118  cv::Mat* m_LeftCameraToTracker;
119 
120  //the dimensions of the video screen in pixels
121  double m_VideoWidth;
122  double m_VideoHeight;
123 
124  //the dimensions of the patch to reconstruct in pixels, and its offset from origin
125  double m_PatchWidth;
126  double m_PatchHeight;
127  double m_PatchOriginX;
128  double m_PatchOriginY;
129 
130  //defaults for generating a reconstruction depth histogram
131  double m_HistogramMaximumDepth;
132 
133  std::vector < cv::Mat > m_WorldToLeftCameraMatrices; // the saved camera positions
134 
135  cv::VideoCapture* m_Capture;
136  CvVideoWriter* m_LeftWriter;
137  CvVideoWriter* m_RightWriter;
138 
139  long long m_AllowableTimingError; // the maximum permisable timing error when setting points or calculating projection errors;
140 
141  void FindVideoData (mitk::VideoTrackerMatching::Pointer trackerMatcher);
142 
143  //returns a patch of image, based on patch definition above
144  cv::Mat GetPatch ( const cv::Mat& image );
145 
146  //annotates the image with patch, recconstruction, and tracking statistics
147 
148  void AnnotateImage ( cv::Mat& image, const cv::Mat& patch,
149  const long long& timingError,
150  const double& patchDepthMean,
151  const double& patchDepthStdDev,
152  const unsigned int& patchVectorSize,
153  const std::vector < unsigned int >& patchDepthHistogram,
154  const double& meanTriangulationError );
155 
156 }; // end class
157 
158 } // end namespace
159 
160 #endif
std::vector< std::string > FindVideoData(const std::string &directory)
Definition: niftkFileHelper.cxx:443
Definition: mitkVideoToSurface.h:39
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:4052
Definition: ReceptorMemberCommandTest.cxx:25
Derived point types to contain data for projection and analysis.
#define NIFTKOPENCV_EXPORT
Definition: niftkSequentialCpuQds.h:27
GLsizei const GLcharARB ** string
Definition: glew.h:5194