NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
mitkVideoTrackerMatching.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 mitkVideoTrackerMatching_h
16 #define mitkVideoTrackerMatching_h
17 
18 #include "niftkOpenCVExports.h"
19 #include <mitkOpenCVPointTypes.h>
20 #include <cv.h>
21 #include <itkObject.h>
22 #include <itkObjectFactory.h>
23 #include <mitkCommon.h>
26 
27 namespace mitk
28 {
29 
33 class NIFTKOPENCV_EXPORT VideoTrackerMatching : public itk::Object
34 {
35 public:
36  mitkClassMacroItkParent ( VideoTrackerMatching, itk::Object)
37  itkNewMacro (VideoTrackerMatching)
38 
39 
42  void Initialise (std::string directory);
43 
47  cv::Mat GetTrackerMatrix ( unsigned int FrameNumber, long long * TimingError = NULL, unsigned int TrackerIndex = 0,
48  int ReferenceIndex = -1);
49 
53  cv::Mat GetCameraTrackingMatrix ( unsigned int FrameNumber, long long * TimingError = NULL, unsigned int TrackerIndex = 0 , std::vector <double> * Perturbation = NULL , int ReferenceIndex = -1 );
54 
58  cv::Mat GetVideoFrame ( unsigned int FrameNumber, unsigned long long * TimingStamp = NULL );
59 
63  unsigned long long GetVideoFrameTimeStamp ( unsigned int FrameNumber );
64 
68  bool IsReady ()
69  {
70  return m_Ready;
71  }
72 
76  itkSetMacro (FlipMatrices, bool);
77 
81  itkSetMacro (WriteTimingErrors, bool);
82 
86  itkSetMacro (HaltOnFrameSkip, bool);
87 
91  itkSetMacro (InterpolateMatrices, bool);
92 
96  itkGetMacro (FrameMap, std::string);
97 
102  {
103  return m_FrameNumbers.size();
104  }
105 
111  void SetVideoLagMilliseconds(unsigned long long VideoLag, bool VideoLeadsTracking =false, int trackerIndex = -1);
112 
117  void SetCameraToTracker( cv::Mat, int trackerIndex = -1 );
118 
119  /*
120  * \brief Convienient way to set the camera to tracker matrices where multiple tracking
121  * directories are present. File contains camera to tracker matrices in same order as
122  * tracker indices
123  */
124  void SetCameraToTrackers ( std::string filename );
125 
126  /*
127  * \brief Return the size of the TrackingMatrices vector (how many tracker indeces are available)
128  */
129  unsigned int GetTrackingMatricesSize ();
130 
131 
132 protected:
134  virtual ~VideoTrackerMatching();
135 
136  VideoTrackerMatching(const VideoTrackerMatching&); // Purposefully not implemented.
137  VideoTrackerMatching& operator=(const VideoTrackerMatching&); // Purposefully not implemented.
138 
139  std::vector<unsigned int> m_FrameNumbers;
141  bool m_Ready;
146 
153  std::vector < mitk::WorldPointsWithTimingError > ReadPointsInLensCSFile (std::string filename,
154  int PointsPerFrame = 1 ,
155  std::vector < mitk::ProjectedPointPairsWithTimingError >* onScreenPoints = NULL);
156 
157 private:
158 
159  std::vector<mitk::TrackingAndTimeStampsContainer> m_TrackingMatricesAndTimeStamps;
160  std::vector< std::vector<long long> > m_TimingErrors; //for each frame a set of timing errors
161  std::vector<std::string> m_TrackingMatrixDirectories;
162  std::string m_FrameMap;
163 
164  void ProcessFrameMapFile();
165  bool CheckTimingErrorStats();
166  bool m_HaltOnFrameSkip;
167  std::vector<cv::Mat> m_CameraToTracker;
168 
169  std::vector <unsigned long long> m_VideoLag; //the delay between the tracking and video data
170  std::vector <bool> m_VideoLeadsTracking; //if the video lag is negative, set this to true
171 
172 };
173 
174 
175 } // namespace
176 
177 
178 #endif // niftkVideoTrackerMatching_h
A class to match video frames to tracking frames, when reading recorded tracking data.
Definition: mitkVideoTrackerMatching.h:33
TimeStampsContainer m_VideoTimeStamps
Definition: mitkVideoTrackerMatching.h:140
int GetNumberOfFrames()
Get the frame count.
Definition: mitkVideoTrackerMatching.h:101
Definition: ReceptorMemberCommandTest.cxx:25
std::vector< cv::Mat > FlipMatrices(const std::vector< cv::Mat > Matrices)
Flips the matrices in the vector from left handed coordinate system to right handed and vice versa...
Definition: mitkOpenCVMaths.cxx:1815
bool m_Ready
Definition: mitkVideoTrackerMatching.h:141
bool m_FlipMatrices
Definition: mitkVideoTrackerMatching.h:142
bool IsReady()
returns state of m_Ready
Definition: mitkVideoTrackerMatching.h:68
Derived point types to contain data for projection and analysis.
#define NIFTKOPENCV_EXPORT
Definition: niftkSequentialCpuQds.h:27
std::string m_Directory
Definition: mitkVideoTrackerMatching.h:145
bool m_InterpolateMatrices
Definition: mitkVideoTrackerMatching.h:144
Helper class that contains a vector of timestamps, that are assumed to be strictly increasing...
Definition: mitkTimeStampsContainer.h:30
std::vector< unsigned int > m_FrameNumbers
Definition: mitkVideoTrackerMatching.h:139
bool m_WriteTimingErrors
Definition: mitkVideoTrackerMatching.h:143
GLsizei const GLcharARB ** string
Definition: glew.h:5194