PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
AtracsysTracker.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef __AtracsysTracker_h
8 #define __AtracsysTracker_h
9 
10 #include <string>
11 #include <vector>
12 #include <vtkNew.h>
13 #include <vtkMatrix4x4.h>
14 #include <map>
15 
16 struct ftkOptionsInfo;
17 
18 // Functions to safely convert string to int32 or float
19 bool strToInt32(const std::string& str, int& var);
20 bool strToFloat32(const std::string& str, float& var);
21 
23 {
24 public:
25  /* Constructor & destructor */
27  virtual ~AtracsysTracker();
28 
30  {
31  SUCCESS = 0,
61  };
62 
64  {
70  };
71 
73  {
76  };
77 
78  // Class to hold the 3D and 2D coordinates in mm and pixel respectively of
79  // a single fiducial in the view of the camera
80  class Fiducial
81  {
82  public:
83  Fiducial() {};
84  // override equality operator to make fids less than EQUALITY_DISTANCE_MM considered equal
85  bool operator==(const Fiducial& f);
86  bool operator<(const Fiducial& f) const;
87  uint32_t id = 0;
88  // 3D
89  uint32_t Fid3dStatus = 0;
90  float xMm = 0;
91  float yMm = 0;
92  float zMm = 0;
93  float epipolarErrorPx = 0;
94  float probability = -1;
95  float triangulErrorMm = 0;
96  // 2D left
97  uint32_t Fid2dLeftStatus = 0;
98  float xLeftPx = 0;
99  float yLeftPx = 0;
100  uint16_t heightLeftPx = 0;
101  uint16_t widthLeftPx = 0;
102  uint32_t pixCountLeft = 0;
103  // 2D right
104  uint32_t Fid2dRightStatus = 0;
105  float xRightPx = 0;
106  float yRightPx = 0;
107  uint16_t heightRightPx = 0;
108  uint16_t widthRightPx = 0;
109  uint32_t pixCountRight = 0;
110  };
111 
112  typedef std::vector<Fiducial> Fiducials;
113 
114  // Class to hold position and metadata of a marker in the camera's field of view
115  class Marker
116  {
117  public:
118  Marker();
119  // toolToTracker is deep copied in this constructor
120  Marker(int status, int trackingId, int geometryId,
121  vtkMatrix4x4* toolToTracker, int geometryPresenceMask, float registrationErrorMM);
122  Marker(const Marker&);
123  bool AddFiducial(Fiducial fid);
124  uint32_t GetMarkerStatus() { return MarkerStatus; }
125  uint32_t GetTrackingID() { return TrackingId; }
126  uint32_t GetGeometryID() { return GeometryId; }
127  vtkMatrix4x4* GetTransformToTracker() { return this->ToolToTracker.GetPointer(); }
128  uint32_t GetGeometryPresenceMask() { return GeometryPresenceMask; }
129  float GetFiducialRegistrationErrorMm() { return RegistrationErrorMm; }
130  const Fiducials& GetFiducials() { return fiducials; }
131 
132  private:
133  uint32_t MarkerStatus;
134  uint32_t TrackingId;
135  uint32_t GeometryId;
136  vtkNew<vtkMatrix4x4> ToolToTracker;
137  uint32_t GeometryPresenceMask; // presence mask of fiducials expressed as their numerical indices
138  float RegistrationErrorMm; // mean fiducial registration error (unit mm)
139  Fiducials fiducials; // fiducial coordinates
140  };
141 
142  /* Is onboard/embedded processing on ?*/
143  bool IsOnboardProcessing();
144 
146  bool IsVirtual();
147 
149  void Pause(bool tof);
150 
153 
156 
158  ATRACSYS_RESULT GetSDKversion(std::string& version);
159 
162 
165 
167  ATRACSYS_RESULT GetDeviceId(uint64_t& id);
168 
175  ATRACSYS_RESULT GetCamerasCalibration(std::array<float,10>& leftIntrinsic, std::array<float, 10>& rightIntrinsic,
176  std::array<float, 3>& rightPosition, std::array<float, 3>& rightOrientation);
177 
179  ATRACSYS_RESULT LoadMarkerGeometryFromFile(std::string filePath, int& geometryId);
180 
182  ATRACSYS_RESULT LoadMarkerGeometryFromString(std::string filePath, int& geometryId);
183 
185  ATRACSYS_RESULT GetMarkerInfo(std::string& markerInfo);
186 
188  ATRACSYS_RESULT GetLoadedGeometries(std::map<int, std::vector<std::array<float,3>>>& geometries);
189 
191  std::string ResultToString(ATRACSYS_RESULT result);
192 
194  ATRACSYS_RESULT GetMarkersInFrame(std::vector<Marker>& markers,
195  std::map<std::string, std::string>& events, uint64_t& sdkTimestamp);
196 
198  ATRACSYS_RESULT SetUserLEDState(int red, int green, int blue, int frequency, bool enabled = true);
199 
202 
205 
208 
211 
214 
215  // ------------------------------------------
216  // frame options
217  // ------------------------------------------
221  int GetMaxAdditionalEventsNumber() { return MaxAdditionalEventsNumber; }
222 
225  int GetMax2dFiducialsNumber() { return Max2dFiducialsNumber; }
226 
229  int GetMax3dFiducialsNumber() { return Max3dFiducialsNumber; }
230 
233  int GetMaxMarkersNumber() { return MaxMarkersNumber; }
234 
235  // ------------------------------------------
236  // spryTrack only options
237  // ------------------------------------------
238 
241 
244 
247 
248  // ------------------------------------------
249  // fusionTrack only options
250  // ------------------------------------------
251 
253  ATRACSYS_RESULT GetDroppedFrameCount(int& droppedFrameCount);
254 
257 
258  ATRACSYS_RESULT SetOption(const std::string&, const std::string&);
259 
260 protected:
261  bool GetOptionInfo(const std::string&, const ftkOptionsInfo*&);
262 
263 private:
264  DEVICE_TYPE DeviceType = UNKNOWN_DEVICE;
265 
266  int MaxAdditionalEventsNumber = 0; // beyond the default allocation of 20 events
267  int Max2dFiducialsNumber = 256;
268  int Max3dFiducialsNumber = 256;
269  int MaxMarkersNumber = 16;
270 
271  bool isOnboardProcessing = false;
272 
273  class AtracsysInternal;
274  AtracsysInternal* Internal;
275 };
276 #endif
ATRACSYS_RESULT SetUserLEDState(int red, int green, int blue, int frequency, bool enabled=true)
ATRACSYS_RESULT GetCalibrationDate(std::string &date)
ATRACSYS_RESULT GetDeviceId(uint64_t &id)
bool strToFloat32(const std::string &str, float &var)
void Pause(bool tof)
ATRACSYS_RESULT GetLoadedGeometries(std::map< int, std::vector< std::array< float, 3 >>> &geometries)
ATRACSYS_RESULT EnableUserLED(bool enabled)
ATRACSYS_RESULT SetMax3dFiducialsNumber(int n)
ATRACSYS_RESULT GetDeviceType(DEVICE_TYPE &deviceType)
int GetMaxAdditionalEventsNumber()
int GetMax3dFiducialsNumber()
ATRACSYS_RESULT Disconnect()
ATRACSYS_RESULT SetOption(const std::string &, const std::string &)
ATRACSYS_RESULT EnableWirelessMarkerBatteryStreaming(bool enabled)
ATRACSYS_RESULT EnableWirelessMarkerStatusStreaming(bool enabled)
ATRACSYS_RESULT EnableOnboardProcessing(bool enabled)
ATRACSYS_RESULT GetDroppedFrameCount(int &droppedFrameCount)
ATRACSYS_RESULT SetMaxMarkersNumber(int n)
ATRACSYS_RESULT LoadMarkerGeometryFromFile(std::string filePath, int &geometryId)
ATRACSYS_RESULT GetMarkersInFrame(std::vector< Marker > &markers, std::map< std::string, std::string > &events, uint64_t &sdkTimestamp)
std::string ResultToString(ATRACSYS_RESULT result)
bool GetOptionInfo(const std::string &, const ftkOptionsInfo *&)
ATRACSYS_RESULT LoadMarkerGeometryFromString(std::string filePath, int &geometryId)
int enabled
Definition: phidget22.h:3369
ATRACSYS_RESULT ResetLostFrameCount()
bool operator==(const Fiducial &f)
ATRACSYS_RESULT SetMaxAdditionalEventsNumber(int n)
ATRACSYS_RESULT GetMarkerInfo(std::string &markerInfo)
ATRACSYS_RESULT EnableImageStreaming(bool enabled)
ATRACSYS_RESULT GetSDKversion(std::string &version)
ATRACSYS_RESULT GetCamerasCalibration(std::array< float, 10 > &leftIntrinsic, std::array< float, 10 > &rightIntrinsic, std::array< float, 3 > &rightPosition, std::array< float, 3 > &rightOrientation)
bool operator<(const Fiducial &f) const
std::vector< Fiducial > Fiducials
PhidgetGPS_Date * date
Definition: phidget22.h:3617
ATRACSYS_RESULT SetSpryTrackProcessingType(SPRYTRACK_IMAGE_PROCESSING_TYPE processingType)
vtkMatrix4x4 * GetTransformToTracker()
ATRACSYS_RESULT SetLaserEnabled(bool enabled)
virtual ~AtracsysTracker()
ATRACSYS_RESULT SetMax2dFiducialsNumber(int n)
bool strToInt32(const std::string &str, int &var)
double frequency
Definition: phidget22.h:3246
ATRACSYS_RESULT EnableWirelessMarkerPairing(bool enabled)
uint32_t GetGeometryPresenceMask()
ATRACSYS_RESULT Connect()
int GetMax2dFiducialsNumber()
bool AddFiducial(Fiducial fid)
const Fiducials & GetFiducials()