Medical Imaging Interaction Toolkit  2023.04.00
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 mitkOptitrackTrackingDevice_h
14 #define mitkOptitrackTrackingDevice_h
15 
16 #include <MitkIGTExports.h>
17 #include <mitkTrackingDevice.h>
18 #include <mitkTrackingTypes.h>
19 #include <mitkIGTTimeStamp.h>
20 #include <itksys/SystemTools.hxx>
21 #include <string>
22 #include <cstdlib>
23 #include <cstdio>
24 #include <ctime>
25 #include <thread>
26 #include <mutex>
27 
31 #include "mitkIGTIOException.h"
32 #include "mitkIGTTimeStamp.h"
33 #include "mitkIGTException.h"
34 
39 
40 
41 namespace mitk
42 {
52  class MITKIGT_EXPORT OptitrackTrackingDevice : public mitk::TrackingDevice
53  {
54 
55  friend class OptitrackTrackingTool;
56 
57  public:
59  itkNewMacro(Self);
60 
64  bool IsDeviceInstalled() override;
65 
66  // Define the Type of Tracker as DefinitionOfTool (MITK)
68 
75  bool OpenConnection() override;
76 
83  bool CloseConnection() override;
84 
91  bool StartTracking() override;
92 
98  bool StopTracking() override;
99 
106  TrackingTool* GetTool(unsigned int toolNumber) const override;
107 
115  OptitrackTrackingTool* GetOptitrackTool(unsigned int toolNumber) const;
116 
121  unsigned int GetToolCount() const override;
122 
124  itkSetMacro(Exp,int);
125 
127  itkGetMacro(Exp,int);
128 
130  itkSetMacro(Led,int);
131 
133  itkGetMacro(Led,int);
134 
136  itkSetMacro(Thr,int);
137 
139  itkGetMacro(Thr,int);
140 
142  void SetCalibrationPath(std::string calibrationPath);
143 
145  itkGetMacro(calibrationPath,std::string);
146 
150  void ThreadStartTracking();
151 
156  void TrackTools();
157 
163  bool LoadCalibration();
164 
176  bool SetCameraParams(int exposure, int threshold, int intensity, int videoType = 4);
177 
183  bool InitializeCameras();
184 
198  bool AddToolByDefinitionFile(std::string fileName); // ^????? We should give an example of defined tool
199 
205 // bool AddToolByConfigurationFil(std::string fileName); // For next release....
206 
207  protected:
212  ~OptitrackTrackingDevice() override;
213 
214 
215  private:
220  std::string m_calibrationPath;
221 
225  int m_Exp;
226 
230  int m_Led;
231 
235  int m_Thr;
236 
241  bool m_initialized;
242 
246  std::vector<mitk::OptitrackTrackingTool::Pointer> m_AllTools;
247 
251  mutable std::mutex m_ToolsMutex;
252 
253  std::thread m_Thread;
254 
255 
256 /* TODO:
257 
258 // For Tracking
259 -bool AddToolByConfigurationFil(std::string fileName);
260 TTAPI NPRESULT TT_LoadTrackables (const char *filename); //== Load Trackables ======----
261 TTAPI NPRESULT TT_SaveTrackables (const char *filename); //== Save Trackables ======----
262 TTAPI NPRESULT TT_AddTrackables (const char *filename); //== Add Trackables ======----
263 TTAPI void TT_ClearTrackableList(); //== Clear all trackables =====---
264 TTAPI NPRESULT TT_RemoveTrackable(int Index); //== Remove single trackable ====---
265 TTAPI void TT_SetTrackableEnabled(int index, bool enabled); //== Set Tracking ====---
266 TTAPI bool TT_TrackableEnabled(int index); //== Get Tracking ====---
267 TTAPI int TT_TrackableMarkerCount(int index); //== Get marker count ====---
268 TTAPI void TT_TrackableMarker(int RigidIndex, //== Get Trackable mrkr ====---
269  int MarkerIndex, float *x, float *y, float *z);
270 
271 //For projects
272 TTAPI NPRESULT TT_LoadProject(const char *filename); //== Load Project File ==========--
273 TTAPI NPRESULT TT_SaveProject(const char *filename); //== Save Project File ==========--
274 
275 // For VRPN connection
276 TTAPI NPRESULT TT_StreamVRPN(bool enabled, int port);//== Start/stop VRPN Stream ===----
277 
278 // For frame testing
279 TTAPI int TT_FrameMarkerCount(); //== Returns Frame Markers Count ---
280 TTAPI float TT_FrameMarkerX(int index); //== Returns X Coord of Marker -----
281 TTAPI float TT_FrameMarkerY(int index); //== Returns Y Coord of Marker -----
282 TTAPI float TT_FrameMarkerZ(int index); //== Returns Z Coord of Marker -----
283 TTAPI int TT_FrameMarkerLabel(int index); //== Returns Label of Marker -------
284 TTAPI double TT_FrameTimeStamp(); //== Time Stamp of Frame (seconds) -
285 
286 // For cameras handling
287 TTAPI int TT_CameraCount(); //== Returns Camera Count =====-----
288 TTAPI float TT_CameraXLocation(int index); //== Returns Camera's X Coord =-----
289 TTAPI float TT_CameraYLocation(int index); //== Returns Camera's Y Coord =-----
290 TTAPI float TT_CameraZLocation(int index); //== Returns Camera's Z Coord =-----
291 TTAPI float TT_CameraOrientationMatrix(int camera, int index); //== Orientation -----
292 
293 
294 */
295 
296 
297 };
298 
299 
300 }
301 #endif
mitk::OptitrackTrackingDevice::OptiTrackTrackingDeviceType
mitk::TrackingDeviceType OptiTrackTrackingDeviceType
Definition: mitkOptitrackTrackingDevice.h:67
mitkIGTTimeStamp.h
mitkOptitrackTrackingTool.h
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::TrackingDevice
Interface for all Tracking Devices.
Definition: mitkTrackingDevice.h:34
mitk::TrackingTool
Interface for all Tracking Tools.
Definition: mitkTrackingTool.h:42
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::OptitrackTrackingTool
An object of this class represents the a Tool tracked by Optitrack System. You can define the tool by...
Definition: mitkOptitrackTrackingTool.h:50
mitkTrackingDevice.h
mitk::TrackingDeviceType
std::string TrackingDeviceType
Definition: mitkTrackingTypes.h:22
mitkTrackingTypes.h
mitk::OptitrackTrackingDevice
An object of this class represents the Optitrack device. You can add tools to this device,...
Definition: mitkOptitrackTrackingDevice.h:52