Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef OptitrackTrackingDevice_H_HEADER_INCLUDED
18 #define OptitrackTrackingDevice_H_HEADER_INCLUDED
19 
20 #include <MitkIGTExports.h>
21 #include <mitkTrackingDevice.h>
22 #include <itkMultiThreader.h>
23 #include <mitkTrackingTypes.h>
24 #include <mitkIGTTimeStamp.h>
25 #include <itkFastMutexLock.h>
26 #include <itksys/SystemTools.hxx>
27 #include <itkMutexLockHolder.h>
28 #include <string>
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <time.h>
32 
36 #include "mitkIGTIOException.h"
37 #include "mitkIGTTimeStamp.h"
38 #include "mitkIGTException.h"
39 
44 
45 
46 
51 
52 
53 
54 
55 namespace mitk
56 {
66  class MITKIGT_EXPORT OptitrackTrackingDevice : public mitk::TrackingDevice
67  {
68 
69  friend class OptitrackTrackingTool;
70 
71  public:
73  itkNewMacro(Self);
74 
78  virtual bool IsDeviceInstalled() override;
79 
80  // Define the Type of Tracker as DefinitionOfTool (MITK)
82 
89  virtual bool OpenConnection() override;
90 
97  virtual bool CloseConnection() override;
98 
105  virtual bool StartTracking() override;
106 
112  virtual bool StopTracking() override;
113 
120  TrackingTool* GetTool(unsigned int toolNumber) const override;
121 
129  OptitrackTrackingTool* GetOptitrackTool(unsigned int toolNumber) const;
130 
135  unsigned int GetToolCount() const override;
136 
138  itkSetMacro(Exp,int);
139 
141  itkGetMacro(Exp,int);
142 
144  itkSetMacro(Led,int);
145 
147  itkGetMacro(Led,int);
148 
150  itkSetMacro(Thr,int);
151 
153  itkGetMacro(Thr,int);
154 
156  void SetCalibrationPath(std::string calibrationPath);
157 
159  itkGetMacro(calibrationPath,std::string);
160 
165  static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void* data);
166 
171  void TrackTools();
172 
178  bool LoadCalibration();
179 
191  bool SetCameraParams(int exposure, int threshold, int intensity, int videoType = 4);
192 
198  bool InitializeCameras();
199 
213  bool AddToolByDefinitionFile(std::string fileName); // ^????? We should give an example of defined tool
214 
220 // bool AddToolByConfigurationFil(std::string fileName); // For next release....
221 
222  protected:
228 
229 
230  private:
235  std::string m_calibrationPath;
236 
240  int m_Exp;
241 
245  int m_Led;
246 
250  int m_Thr;
251 
256  bool m_initialized;
257 
261  std::vector<mitk::OptitrackTrackingTool::Pointer> m_AllTools;
262 
266  itk::FastMutexLock::Pointer m_ToolsMutex;
267 
271  itk::MultiThreader::Pointer m_MultiThreader;
272 
276  int m_ThreadID;
277 
278 
279 /* TODO:
280 
281 // For Tracking
282 -bool AddToolByConfigurationFil(std::string fileName);
283 TTAPI NPRESULT TT_LoadTrackables (const char *filename); //== Load Trackables ======----
284 TTAPI NPRESULT TT_SaveTrackables (const char *filename); //== Save Trackables ======----
285 TTAPI NPRESULT TT_AddTrackables (const char *filename); //== Add Trackables ======----
286 TTAPI void TT_ClearTrackableList(); //== Clear all trackables =====---
287 TTAPI NPRESULT TT_RemoveTrackable(int Index); //== Remove single trackable ====---
288 TTAPI void TT_SetTrackableEnabled(int index, bool enabled); //== Set Tracking ====---
289 TTAPI bool TT_TrackableEnabled(int index); //== Get Tracking ====---
290 TTAPI int TT_TrackableMarkerCount(int index); //== Get marker count ====---
291 TTAPI void TT_TrackableMarker(int RigidIndex, //== Get Trackable mrkr ====---
292  int MarkerIndex, float *x, float *y, float *z);
293 
294 //For projects
295 TTAPI NPRESULT TT_LoadProject(const char *filename); //== Load Project File ==========--
296 TTAPI NPRESULT TT_SaveProject(const char *filename); //== Save Project File ==========--
297 
298 // For VRPN connection
299 TTAPI NPRESULT TT_StreamVRPN(bool enabled, int port);//== Start/stop VRPN Stream ===----
300 
301 // For frame testing
302 TTAPI int TT_FrameMarkerCount(); //== Returns Frame Markers Count ---
303 TTAPI float TT_FrameMarkerX(int index); //== Returns X Coord of Marker -----
304 TTAPI float TT_FrameMarkerY(int index); //== Returns Y Coord of Marker -----
305 TTAPI float TT_FrameMarkerZ(int index); //== Returns Z Coord of Marker -----
306 TTAPI int TT_FrameMarkerLabel(int index); //== Returns Label of Marker -------
307 TTAPI double TT_FrameTimeStamp(); //== Time Stamp of Frame (seconds) -
308 
309 // For cameras handling
310 TTAPI int TT_CameraCount(); //== Returns Camera Count =====-----
311 TTAPI float TT_CameraXLocation(int index); //== Returns Camera's X Coord =-----
312 TTAPI float TT_CameraYLocation(int index); //== Returns Camera's Y Coord =-----
313 TTAPI float TT_CameraZLocation(int index); //== Returns Camera's Z Coord =-----
314 TTAPI float TT_CameraOrientationMatrix(int camera, int index); //== Orientation -----
315 
316 
317 */
318 
319 
320 };
321 
322 
323 }
324 #endif
Interface for all Tracking Tools.
itk::SmartPointer< Self > Pointer
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 mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
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