PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusBkProFocusOemVideoSource.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 // GRAB_FRAME API was partly contributed by by Xin Kang at SZI, Children's National Medical Center
8 
9 #ifndef __vtkPlusBkProFocusOemVideoSource_h
10 #define __vtkPlusBkProFocusOemVideoSource_h
11 
12 #include "vtkPlusDataCollectionExport.h"
13 #include "vtkPlusUsDevice.h"
14 
23 class vtkPlusDataCollectionExport vtkPlusBkProFocusOemVideoSource : public vtkPlusUsDevice
24 {
25 public:
26 
29  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
30 
31  virtual bool IsTracker() const { return false; }
32 
34  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* config);
36  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* config);
37 
39  virtual PlusStatus NotifyConfigured();
40 
42  vtkSetMacro(ScannerAddress, std::string);
43 
45  vtkGetMacro(ScannerAddress, std::string);
46 
48  vtkSetMacro(OemPort, unsigned short);
49 
54  vtkSetMacro(ContinuousStreamingEnabled, bool);
55 
60  vtkGetMacro(ContinuousStreamingEnabled, bool);
61 
66  vtkBooleanMacro(ContinuousStreamingEnabled, bool);
67 
69  vtkSetMacro(ColorEnabled, bool);
70 
72  vtkGetMacro(ColorEnabled, bool);
73 
75  vtkBooleanMacro(ColorEnabled, bool);
76 
78  vtkSetMacro(OfflineTesting, bool);
79 
81  vtkGetMacro(OfflineTesting, bool);
82 
84  vtkBooleanMacro(OfflineTesting, bool);
85 
87  vtkSetStringMacro(OfflineTestingFilePath);
88 
90  vtkGetStringMacro(OfflineTestingFilePath);
91 
92 protected:
93 
94  static const char* KEY_DEPTH;
95  static const char* KEY_GAIN;
96 
97  // Size of the ultrasound image. Only used if ContinuousStreamingEnabled is true.
98  std::array<unsigned int, 2> UltrasoundWindowSize;
99 
100  //Parameter values recaived from the BK scanner.
101  double StartLineX_m, StartLineY_m, StartLineAngle_rad, StartDepth_m, StopLineX_m, StopLineY_m, StopLineAngle_rad, StopDepth_m;
102  int pixelLeft_pix, pixelTop_pix, pixelRight_pix, pixelBottom_pix;
103  int grabFramePixelLeft_pix, grabFramePixelTop_pix, grabFramePixelRight_pix, grabFramePixelBottom_pix;
104  double tissueLeft_m, tissueTop_m, tissueRight_m, tissueBottom_m;
106 
107  //Probe type of the connected probes
108  IGTLIO_PROBE_TYPE probeTypePortA, probeTypePortB, probeTypePortC, probeTypePortM;
109 
110  //The current probe port
111  std::string probePort;
112 
117 
119  virtual PlusStatus InternalConnect();
120 
122  virtual PlusStatus InternalDisconnect();
123 
125  PlusStatus StartContinuousDataStreaming();
126 
128  PlusStatus StopContinuousDataStreaming();
129 
132 
135 
138 
140  PlusStatus ProcessMessagesAndReadNextImage();
141 
143  PlusStatus ReadNextMessage();
144 
146  std::vector<char> removeSpecialCharacters(std::vector<char> inMessage);
147 
155  int addAdditionalBinaryDataToImageUntilEOTReached(char& character, std::vector<char>& rawMessage);
156 
158  PlusStatus SendQuery(std::string query);
159 
161  std::string AddSpecialCharacters(std::string query);
162 
164  PlusStatus RequestParametersFromScanner();
165 
167  PlusStatus QueryImageSize();
168  PlusStatus QueryGeometryScanarea();
169  PlusStatus QueryGeometryPixel();
170  PlusStatus QueryGeometryUsGrabFrame();
171  PlusStatus QueryGeometryTissue();
172  PlusStatus QueryGain();
173  PlusStatus QueryTransducerList();
174  PlusStatus QueryTransducer();
175 
177  PlusStatus SubscribeToParameterChanges();
178  PlusStatus ConfigEventsOn();
179  // PlusStatus CommandPowerDopplerOn();
180 
182  void ParseImageSize(std::istringstream& replyStream);
183  void ParseGeometryScanarea(std::istringstream& replyStream);
184  void ParseGeometryPixel(std::istringstream& replyStream);
185  void ParseGeometryUsGrabFrame(std::istringstream& replyStream);
186  void ParseGeometryTissue(std::istringstream& replyStream);
187  void ParseGain(std::istringstream& replyStream);
188  void ParseTransducerList(std::istringstream& replyStream);
189  void ParseTransducerData(std::istringstream& replyStream);
190 
191  PlusStatus DecodePngImage(unsigned char* pngBuffer, unsigned int pngBufferSize, vtkImageData* decodedImage);
192 
193  // Calculate values for the OpenIGTLinkIO standard.
194 
196  virtual std::vector<double> CalculateOrigin() override;
197 
201  virtual std::vector<double> CalculateAngles() override;
202 
205  virtual std::vector<double> CalculateBoundingBox() override;
206 
208  virtual std::vector<double> CalculateDepths() override;
209 
211  virtual double CalculateLinearWidth() override;
212 
213  //Utility functions
214 
216  bool IsSectorProbe();
217 
219  double CalculateWidthInRadians();
220 
222  double CalculateDepthMm();
223 
225  int CalculateGain();
226 
228  double GetStartDepth();
229 
231  double GetStopDepth();
232 
234  double GetStartLineX();
235 
237  double GetStartLineY();
238 
240  double GetStopLineX();
241 
243  double GetStopLineY();
244 
246  double GetStartLineAngle();
247 
249  double GetStopLineAngle();
250 
252  double GetSpacingX();
253 
255  double GetSpacingY();
256 
258  virtual IGTLIO_PROBE_TYPE GetProbeType() override;
259 
261  PlusStatus AddParametersToFrameFields();
262 
264  std::string ReadBufferIntoString();
265 
267  std::string RemoveQuotationMarks(std::string inString);
268 
269  void SetProbeTypeForPort(std::string port, std::string probeTypeString);
270 
271  //Values read from the xml config file
273  std::string ScannerAddress;
274 
276  unsigned short OemPort;
277 
280 
283 
286 
289 
290  // For internal storage of additional variables (to minimize the number of included headers)
291  class vtkInternal;
292  vtkInternal* Internal;
293 
295  igsioFieldMapType FrameFields;
296 
297 private:
299  void operator=(const vtkPlusBkProFocusOemVideoSource&); // Not implemented.
300 
301  //Special characters used in BK communication protocol
302  enum
303  {
304  SOH = 1,
305  EOT = 4,
306  ESC = 27,
307  };
308 };
309 
310 #endif
virtual PlusStatus InternalStopRecording()
PhidgetLCD_Font const char * character
Definition: phidget22.h:4250
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
Class for acquiring ultrasound images from BK ultrasound systems through the OEM interface.
virtual PlusStatus InternalConnect()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
int port
Definition: phidget22.h:2454
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
virtual std::vector< double > CalculateAngles()
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus InternalStartRecording()
virtual std::vector< double > CalculateOrigin()
static vtkPlusUsDevice * New()
virtual std::vector< double > CalculateBoundingBox()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
igsioFieldMapType FrameFields
Container to hold calculated field values.
std::array< unsigned int, 2 > UltrasoundWindowSize
virtual std::vector< double > CalculateDepths()
virtual double CalculateLinearWidth()
virtual PlusStatus NotifyConfigured()
virtual PlusStatus InternalDisconnect()
Abstract interface for ultrasound video devices.
virtual PlusStatus InternalUpdate()
virtual IGTLIO_PROBE_TYPE GetProbeType()