Medical Imaging Interaction Toolkit  2018.4.99-bd7b41ba
Medical Imaging Interaction Toolkit
mitkOptitrackTrackingDevice.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 #ifndef OptitrackTrackingDevice_H_HEADER_INCLUDED
14 #define OptitrackTrackingDevice_H_HEADER_INCLUDED
15 
16 #include <MitkIGTExports.h>
17 #include <mitkTrackingDevice.h>
18 #include <itkMultiThreader.h>
19 #include <mitkTrackingTypes.h>
20 #include <mitkIGTTimeStamp.h>
21 #include <itkFastMutexLock.h>
22 #include <itksys/SystemTools.hxx>
23 #include <itkMutexLockHolder.h>
24 #include <string>
25 #include <cstdlib>
26 #include <cstdio>
27 #include <ctime>
28 
32 #include "mitkIGTIOException.h"
33 #include "mitkIGTTimeStamp.h"
34 #include "mitkIGTException.h"
35 
40 
41 
42 
47 
48 
49 
50 
51 namespace mitk
52 {
63  {
64 
65  friend class OptitrackTrackingTool;
66 
67  public:
69  itkNewMacro(Self);
70 
74  bool IsDeviceInstalled() override;
75 
76  // Define the Type of Tracker as DefinitionOfTool (MITK)
78 
85  bool OpenConnection() override;
86 
93  bool CloseConnection() override;
94 
101  bool StartTracking() override;
102 
108  bool StopTracking() override;
109 
116  TrackingTool* GetTool(unsigned int toolNumber) const override;
117 
125  OptitrackTrackingTool* GetOptitrackTool(unsigned int toolNumber) const;
126 
131  unsigned int GetToolCount() const override;
132 
134  itkSetMacro(Exp,int);
135 
137  itkGetMacro(Exp,int);
138 
140  itkSetMacro(Led,int);
141 
143  itkGetMacro(Led,int);
144 
146  itkSetMacro(Thr,int);
147 
149  itkGetMacro(Thr,int);
150 
152  void SetCalibrationPath(std::string calibrationPath);
153 
155  itkGetMacro(calibrationPath,std::string);
156 
161  static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void* data);
162 
167  void TrackTools();
168 
174  bool LoadCalibration();
175 
187  bool SetCameraParams(int exposure, int threshold, int intensity, int videoType = 4);
188 
194  bool InitializeCameras();
195 
209  bool AddToolByDefinitionFile(std::string fileName); // ^????? We should give an example of defined tool
210 
216 // bool AddToolByConfigurationFil(std::string fileName); // For next release....
217 
218  protected:
223  ~OptitrackTrackingDevice() override;
224 
225 
226  private:
231  std::string m_calibrationPath;
232 
236  int m_Exp;
237 
241  int m_Led;
242 
246  int m_Thr;
247 
252  bool m_initialized;
253 
257  std::vector<mitk::OptitrackTrackingTool::Pointer> m_AllTools;
258 
262  itk::FastMutexLock::Pointer m_ToolsMutex;
263 
267  itk::MultiThreader::Pointer m_MultiThreader;
268 
272  int m_ThreadID;
273 
274 
275 /* TODO:
276 
277 // For Tracking
278 -bool AddToolByConfigurationFil(std::string fileName);
279 TTAPI NPRESULT TT_LoadTrackables (const char *filename); //== Load Trackables ======----
280 TTAPI NPRESULT TT_SaveTrackables (const char *filename); //== Save Trackables ======----
281 TTAPI NPRESULT TT_AddTrackables (const char *filename); //== Add Trackables ======----
282 TTAPI void TT_ClearTrackableList(); //== Clear all trackables =====---
283 TTAPI NPRESULT TT_RemoveTrackable(int Index); //== Remove single trackable ====---
284 TTAPI void TT_SetTrackableEnabled(int index, bool enabled); //== Set Tracking ====---
285 TTAPI bool TT_TrackableEnabled(int index); //== Get Tracking ====---
286 TTAPI int TT_TrackableMarkerCount(int index); //== Get marker count ====---
287 TTAPI void TT_TrackableMarker(int RigidIndex, //== Get Trackable mrkr ====---
288  int MarkerIndex, float *x, float *y, float *z);
289 
290 //For projects
291 TTAPI NPRESULT TT_LoadProject(const char *filename); //== Load Project File ==========--
292 TTAPI NPRESULT TT_SaveProject(const char *filename); //== Save Project File ==========--
293 
294 // For VRPN connection
295 TTAPI NPRESULT TT_StreamVRPN(bool enabled, int port);//== Start/stop VRPN Stream ===----
296 
297 // For frame testing
298 TTAPI int TT_FrameMarkerCount(); //== Returns Frame Markers Count ---
299 TTAPI float TT_FrameMarkerX(int index); //== Returns X Coord of Marker -----
300 TTAPI float TT_FrameMarkerY(int index); //== Returns Y Coord of Marker -----
301 TTAPI float TT_FrameMarkerZ(int index); //== Returns Z Coord of Marker -----
302 TTAPI int TT_FrameMarkerLabel(int index); //== Returns Label of Marker -------
303 TTAPI double TT_FrameTimeStamp(); //== Time Stamp of Frame (seconds) -
304 
305 // For cameras handling
306 TTAPI int TT_CameraCount(); //== Returns Camera Count =====-----
307 TTAPI float TT_CameraXLocation(int index); //== Returns Camera's X Coord =-----
308 TTAPI float TT_CameraYLocation(int index); //== Returns Camera's Y Coord =-----
309 TTAPI float TT_CameraZLocation(int index); //== Returns Camera's Z Coord =-----
310 TTAPI float TT_CameraOrientationMatrix(int camera, int index); //== Orientation -----
311 
312 
313 */
314 
315 
316 };
317 
318 
319 }
320 #endif
Interface for all Tracking Tools.
mitk::TrackingDeviceType OptiTrackTrackingDeviceType
An object of this class represents the Optitrack device. You can add tools to this device...
DataCollection - Class to facilitate loading/accessing structured data.
#define MITKIGT_EXPORT
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
An object of this class represents the a Tool tracked by Optitrack System. You can define the tool by...
Interface for all Tracking Devices.
itk::MutexLockHolder< itk::FastMutexLock > MutexLockHolder
IGT Exceptions.
std::string TrackingDeviceType