Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
200  protected:
202  ~OptitrackTrackingDevice() override;
203 
204 
205  private:
210  std::string m_calibrationPath;
211 
215  int m_Exp;
216 
220  int m_Led;
221 
225  int m_Thr;
226 
231  bool m_initialized;
232 
236  std::vector<mitk::OptitrackTrackingTool::Pointer> m_AllTools;
237 
241  mutable std::mutex m_ToolsMutex;
242 
243  std::thread m_Thread;
244 
245 
246 /* TODO:
247 
248 // For Tracking
249 -bool AddToolByConfigurationFil(std::string fileName);
250 TTAPI NPRESULT TT_LoadTrackables (const char *filename); //== Load Trackables ======----
251 TTAPI NPRESULT TT_SaveTrackables (const char *filename); //== Save Trackables ======----
252 TTAPI NPRESULT TT_AddTrackables (const char *filename); //== Add Trackables ======----
253 TTAPI void TT_ClearTrackableList(); //== Clear all trackables =====---
254 TTAPI NPRESULT TT_RemoveTrackable(int Index); //== Remove single trackable ====---
255 TTAPI void TT_SetTrackableEnabled(int index, bool enabled); //== Set Tracking ====---
256 TTAPI bool TT_TrackableEnabled(int index); //== Get Tracking ====---
257 TTAPI int TT_TrackableMarkerCount(int index); //== Get marker count ====---
258 TTAPI void TT_TrackableMarker(int RigidIndex, //== Get Trackable mrkr ====---
259  int MarkerIndex, float *x, float *y, float *z);
260 
261 //For projects
262 TTAPI NPRESULT TT_LoadProject(const char *filename); //== Load Project File ==========--
263 TTAPI NPRESULT TT_SaveProject(const char *filename); //== Save Project File ==========--
264 
265 // For VRPN connection
266 TTAPI NPRESULT TT_StreamVRPN(bool enabled, int port);//== Start/stop VRPN Stream ===----
267 
268 // For frame testing
269 TTAPI int TT_FrameMarkerCount(); //== Returns Frame Markers Count ---
270 TTAPI float TT_FrameMarkerX(int index); //== Returns X Coord of Marker -----
271 TTAPI float TT_FrameMarkerY(int index); //== Returns Y Coord of Marker -----
272 TTAPI float TT_FrameMarkerZ(int index); //== Returns Z Coord of Marker -----
273 TTAPI int TT_FrameMarkerLabel(int index); //== Returns Label of Marker -------
274 TTAPI double TT_FrameTimeStamp(); //== Time Stamp of Frame (seconds) -
275 
276 // For cameras handling
277 TTAPI int TT_CameraCount(); //== Returns Camera Count =====-----
278 TTAPI float TT_CameraXLocation(int index); //== Returns Camera's X Coord =-----
279 TTAPI float TT_CameraYLocation(int index); //== Returns Camera's Y Coord =-----
280 TTAPI float TT_CameraZLocation(int index); //== Returns Camera's Z Coord =-----
281 TTAPI float TT_CameraOrientationMatrix(int camera, int index); //== Orientation -----
282 
283 
284 */
285 
286 
287 };
288 
289 
290 }
291 #endif
mitk::OptitrackTrackingDevice::OptiTrackTrackingDeviceType
mitk::TrackingDeviceType OptiTrackTrackingDeviceType
Definition: mitkOptitrackTrackingDevice.h:67
mitkIGTTimeStamp.h
mitkOptitrackTrackingTool.h
mitk
Find image slices visible on a given plane.
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