PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusVirtualTextRecognizer.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 __vtkPlusVirtualTextRecognizer_h
8 #define __vtkPlusVirtualTextRecognizer_h
9 
10 #include "PlusConfigure.h"
11 #include "vtkPlusDataCollectionExport.h"
12 #include "vtkPlusChannel.h"
13 #include "vtkPlusDevice.h"
14 
15 namespace tesseract
16 {
17  class TessBaseAPI;
18 }
19 
20 typedef struct Pix PIX;
21 
28 class vtkPlusDataCollectionExport vtkPlusVirtualTextRecognizer : public vtkPlusDevice
29 {
30 #ifdef PLUS_TEST_TextRecognizer
31 public:
32 #endif
33  class TextFieldParameter
34  {
35  public:
36  TextFieldParameter()
37  {
38  this->Origin[0] = 0;
39  this->Origin[1] = 0;
40  this->Origin[2] = 0;
41  this->Size[0] = 0;
42  this->Size[1] = 0;
43  this->Size[2] = 1;
44  }
45 
46  public:
47  std::string LatestParameterValue;
48  PIX* ReceivedFrame;
49  vtkSmartPointer<vtkImageData> ScreenRegion;
50  vtkPlusChannel* SourceChannel;
51  std::string ParameterName;
53  std::array<int, 3> Origin;
55  std::array<int, 3> Size;
56  };
57 
58 public:
59  typedef std::vector<TextFieldParameter*> FieldList;
60  typedef FieldList::iterator FieldListIterator;
61  typedef std::map<vtkPlusChannel*, FieldList > ChannelFieldListMap;
62  typedef ChannelFieldListMap::iterator ChannelFieldListMapIterator;
63 
64 public:
67  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
68 
70  virtual PlusStatus InternalConnect();
71 
74 
76  virtual PlusStatus ReadConfiguration(vtkXMLDataElement*);
77 
79  virtual PlusStatus WriteConfiguration(vtkXMLDataElement*);
80 
82  virtual PlusStatus NotifyConfigured();
83 
84  virtual bool IsTracker() const {return false;}
85  virtual bool IsVirtual() const {return true;}
86 
87  vtkSetStdStringMacro(Language);
88  vtkGetStdStringMacro(Language);
89 
90  vtkSetObjectMacro(OutputChannel, vtkPlusChannel);
91  vtkGetObjectMacro(OutputChannel, vtkPlusChannel);
92 
93  vtkSetStdStringMacro(TessdataDirectory);
94  vtkGetStdStringMacro(TessdataDirectory);
95 
96 #ifdef PLUS_TEST_TextRecognizer
97  ChannelFieldListMap& GetRecognitionFields();
98 #endif
99 
100 protected:
101  virtual PlusStatus InternalUpdate();
102 
104  void ClearConfiguration();
105 
107  void vtkImageDataToPix(igsioTrackedFrame& frame, TextFieldParameter* parameter);
108 
110  PlusStatus FindOrQueryFrame(igsioTrackedFrame& frame, std::map<double, int>& queriedFramesIndexes, TextFieldParameter* parameter,
111  std::vector<igsioTrackedFrame*>& queriedFrames);
112 
114  std::string Language;
115 
116  std::string TessdataDirectory;
117 
119  tesseract::TessBaseAPI* TesseractAPI;
120 
121  vtkIGSIOTrackedFrameList* TrackedFrames;
122 
125 
128 
129 protected:
131  virtual ~vtkPlusVirtualTextRecognizer();
132 
133 private:
135  void operator=(const vtkPlusVirtualTextRecognizer&);
136 };
137 
138 #endif //__vtkPlusVirtualTextRecognizer_h
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
std::vector< TextFieldParameter * > FieldList
ChannelFieldListMap::iterator ChannelFieldListMapIterator
virtual PlusStatus InternalConnect()
vtkPlusChannel * OutputChannel
Optional output channel to store recognized fields for broadcasting.
igsioStatus PlusStatus
Definition: PlusCommon.h:40
vtkIGSIOTrackedFrameList * TrackedFrames
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
struct Pix PIX
Contains an optional timestamped circular buffer containing the video images and a number of timestam...
virtual PlusStatus NotifyConfigured()
ChannelFieldListMap RecognitionFields
Map of channels to fields so that we only have to grab an image once from the each source channel.
virtual PlusStatus InternalDisconnect()
tesseract::TessBaseAPI * TesseractAPI
Main entry point for the tesseract API.
std::map< vtkPlusChannel *, FieldList > ChannelFieldListMap
virtual PlusStatus InternalUpdate()
static vtkPlusDevice * New()
std::string Language
Language used for detection.