8 #include <boost/signals2.hpp>
9 #include <boost/bind.hpp>
30 const int InitialNumScanProcessors = 1;
31 const int MaxAScanSize = 8192;
32 const int MaxAScansPerBScan = 65000;
33 const int MaxNumScanProcessors = 8;
42 boost::signals2::signal<void(
const char* )> SignalCalibrationFileChanged;
81 bool GetUseContrast ()
const override {
return ScanProcessor::GetUseAutoContrast(); }
84 bool GetUseScaling ()
const override {
return ScanProcessor::GetUseScaling(); }
92 int GetAScanSize ()
const override {
return _scanProcessors[0]->GetHeight(); }
94 bool GetScanDimensions (
int* width,
int* height)
const override;
97 bool GetDispersionCoefficients(
float* coefficients,
int length)
const override;
100 bool GetNumberOfLinesToIgnore(
int* top,
int* bottom)
const override;
103 bool GetMinMaxScaling (
float* min,
float* max)
const override;
109 int GetAScanAverage ()
const override {
return _scanProcessors[0]->GetAScanAverage(); }
118 bool SetQualifiedInputFileName(
const char* name)
override;
121 bool SetOutputIntensityName (
const char* name)
override;
124 bool SetOutputPhaseName (
const char* name)
override;
127 bool SetOutputDirectory (
const char* name)
override;
130 bool SetCalibrationFringeFile(
const char* name)
override;
148 bool SetOutputLogOfData (
bool value)
override { ScanProcessor::SetOutputLogValues(value);
return true; }
156 ScanProcessor::SetUseAutoContrast(
false);
158 return ScanProcessor::SetUseScaling(value);
162 bool SetUseContrast (
bool value)
override {
return ScanProcessor::SetUseAutoContrast(value); }
168 bool SetDispersionCoefficients (
const float* dispersionCoeffients,
int length)
override;
170 bool SetDispersionOptimizationParameters(
int numCoefficients,
int maxIterations,
171 float* initialGuesses,
int startLine,
172 int stopLine,
int offset)
override;
174 bool CalcDispersionCoefficients(
const unsigned short* inData,
int width,
int height,
175 float* coefficients)
override;
178 bool SetNumberOfLinesToIgnore (
int top,
int bottom)
override;
183 if (min > max || min < 0 || max > 1)
185 _lastError = InvalidArgumentValue;
189 ScanProcessor::SetAutoScaleUserMin(min);
190 ScanProcessor::SetAutoScaleUserMax(max);
191 _lastError = NoError;
198 if (value <= 0 || value > MaxAScansPerBScan)
200 _lastError = InvalidArgumentValue;
205 _resizeDataContainers =
true;
206 for (
size_t i = 0; i < _scanProcessors.size(); i++)
208 _scanProcessors[i]->SetWidth(value);
210 _lastError = NoError;
217 if (value <= 0 || value > MaxAScanSize)
219 _lastError = InvalidArgumentValue;
224 _resizeDataContainers =
true;
226 for (
size_t i = 0; i < _scanProcessors.size(); i++)
228 _scanProcessors[i]->SetHeight(value);
230 _lastError = NoError;
237 if (aScansPerBScan <= 0 || aScansPerBScan > MaxAScansPerBScan ||
238 aScanSize <= 0 || aScanSize > MaxAScanSize)
240 _lastError = InvalidArgumentValue;
244 if (_scanWidth != aScansPerBScan || _scanHeight != aScanSize)
246 _scanWidth = aScansPerBScan;
247 _scanHeight = aScanSize;
248 _resizeDataContainers =
true;
250 for (
size_t i = 0; i < _scanProcessors.size(); i++)
252 _scanProcessors[i]->SetWidthAndHeight(aScansPerBScan, aScanSize);
255 _lastError = NoError;
261 {
return _scanProcessors[0]->SetAScanAverage(value); }
264 bool SetNumScanProcessors(
int value)
override;
268 {
return ScanProcessor::SetUseMovingAverage(value); }
270 {
return ScanProcessor::SetMovingAverageWindowSize(value); }
272 {
return ScanProcessor::ResetMovingAverage(); }
276 bool UpdateBackgroundImage ()
override;
278 bool GetBackgroundImage (
float* buffer,
int size)
override;
280 bool SetBackgroundImage (
float* buffer,
int size)
override;
285 bool ConvertSpectralDataToIntensity (
IWPOCTInOutData* inOutData)
override;
286 bool ConvertSpectralDataToIntensity (
const unsigned short* inData,
float* outIntensity)
override;
289 bool ConvertSpectralDataToPhaseIntensity (
IWPOCTInOutData* inOutData)
override;
290 bool ConvertSpectralDataToPhaseIntensity (
const unsigned short* inData,
float* outIntensity,
291 float* outPhase)
override;
295 bool ConvertSpectralFileToPhaseIntensity ()
override;
299 bool ConvertSpectralFileToPhaseIntensity (
const char* qualifiedFileName)
override;
303 bool ConvertSpectralDirToPhaseIntensity ()
override;
306 bool ConvertFloatToUnsignedChar (
const float* inData,
unsigned char* outData,
307 int size)
const override;
310 bool ConvertFloatToUnsignedShort (
const float* inData,
unsigned short* outData,
311 int size)
const override;
313 bool TransposeArray (
const float* src,
float* dst,
int inWidth,
int inHeight)
const override;
314 bool TransposeArray (
const unsigned short* src,
unsigned short* dst,
int inWidth,
int inHeight)
const override;
315 bool TransposeArray (
const unsigned char* src,
unsigned char* dst,
int inWidth,
int inHeight)
const override;
317 bool FlipVertical (
unsigned short* data,
int width,
int height)
const override;
318 bool FlipHorizontal (
unsigned short* data,
int width,
int height)
const override;
319 bool RotateImage (
const unsigned short* inData,
unsigned short* outData,
int width,
int height,
320 unsigned int cw90Multiplier)
const override;
325 void SignalProgress ();
327 bool ReadBinFileToMemory (
const char* qualifiedFileName,
unsigned short* outData);
328 bool WriteMemoryToFile (
const char* qualifiedFileName,
const U16* inData);
329 bool WriteMemoryToFile (
const char* qualifiedFileName,
const float* inData);
330 string GetFileName (
const string& fullName);
341 int _currScanProcessor;
344 string _qualifiedInputFileName;
347 string _outputPhaseName;
348 string _outputPhaseIndexedName;
351 string _outputIntensityName;
352 string _outputIntensityIndexedName;
355 string _outputDirectory;
358 string _calibrationFringeFile;
363 std::atomic<bool> _outputIntensity;
366 std::atomic<bool> _outputPhase;
369 std::atomic<bool> _useGPU;
372 std::atomic<bool> _deleteInputFile;
375 std::atomic<bool> _outputTiffFormat;
378 std::atomic<long> _dongleVal;
380 std::atomic<ErrorCode> _lastError;
383 std::vector<ScanProcessor*> _scanProcessors;
389 std::vector<U16> _shortData;
392 bool _resizeDataContainers;
395 std::vector<std::string> _filesInDir;
401 void OnCalibrationFileChanged(
const char* name);
404 void ResizeContainers ();
405 void ResizeShortData (
int size);
406 template <
typename T>
407 void ResizeData (std::vector<T>& vec,
int size);
409 std::vector<std::string> GetFilesInDir (std::string& myDir);
411 string FormOutputName (
string& path,
bool intensity);
412 string FormOutputName (
string& path,
string& name);
413 string GetBaseFileName (
string& inName,
bool& numsAtEnd);
414 string GetIndexFromFile (
string& currFile,
bool numsAtEnd);
418 void GenerateOutputIntensityIndexedName (
string& index,
bool numsAtEnd);
419 void GenerateOutputPhaseIndexedName (
string& index,
bool numsAtEnd);
423 bool ConvertSpectralFileToPhaseIntensity (std::string& qualifiedFileName);
427 template <
typename T>
428 void WPScanConverter::ResizeData(std::vector<T>& vec,
int size)
430 if (vec.size() != size)
Interface of the ConversionInOutData class.
Interface of the IWPOCTConverter struct.
typedefs used across UtensilConverter
Interface of the ScanProcessor class.
Class that processes scans.
Definition: ScanProcessor.h:32
Class that converts a scanned image from one format to another.
Definition: WPScanConverter.h:28
const char * GetOutputDirectory() const override
Get the output directory.
Definition: WPScanConverter.h:56
bool GetDeleteInputFileAfterConversion() const override
Get the flag that determines if the RAW input file is deleted after data is converted.
Definition: WPScanConverter.h:72
const char * GetOutputPhaseName() const override
Get the phase file name (no path).
Definition: WPScanConverter.h:53
bool SetMinMaxScaling(float min, float max) override
Set the min and max scaling values.
Definition: WPScanConverter.h:181
int GetAScansPerBScan() const override
Get the number of A-scans in a B-scan.
Definition: WPScanConverter.h:90
int GetAScanSize() const override
Get the size of an A-scan.
Definition: WPScanConverter.h:92
const char * GetCalibrationFringeFile() const override
Get the calibration fringe file name.
Definition: WPScanConverter.h:59
bool SetUseContrast(bool value) override
Set the flag that determines if contrast is used on the output.
Definition: WPScanConverter.h:162
bool SetOutputLogOfData(bool value) override
Set the flag that determines if the log of the output data is taken/used.
Definition: WPScanConverter.h:148
bool SetAScansPerBScan(int value) override
Get the number of A-scans in a B-scan.
Definition: WPScanConverter.h:196
bool GetOutputPhase() const override
Get the flag that determines if phase is output.
Definition: WPScanConverter.h:65
bool ResetMovingAverage() override
Resets the moving average by clearing the buffers.
Definition: WPScanConverter.h:271
const char * GetQualifiedInputFileName() const override
Get the fully qualified file name (includes path).
Definition: WPScanConverter.h:47
virtual bool GetUseMovingAverage() const override
Getters for displaying a moving average.
Definition: WPScanConverter.h:112
bool SetUseScaling(bool value) override
Set the flag that determines if scaling is used on the output.
Definition: WPScanConverter.h:152
int GetNumScanProcessors() const override
Get the number of scan processors currently in use.
Definition: WPScanConverter.h:106
virtual int GetMovingAverageWindowSize() const override
Gets the window size of the moving average.
Definition: WPScanConverter.h:113
int GetAScanAverage() const override
Get the number of A-scan averages.
Definition: WPScanConverter.h:109
bool SetAScanSize(int value) override
Set the size of an A-scan.
Definition: WPScanConverter.h:215
bool SetMovingAverageWindowSize(int value) override
Sets the window size of the moving average.
Definition: WPScanConverter.h:269
bool SetOutputIntensity(bool value) override
Set the flag that determines if intensity is output.
Definition: WPScanConverter.h:133
bool SetScanDimensions(int aScansPerBScan, int aScanSize) override
Set the width and height of a scan.
Definition: WPScanConverter.h:235
bool SetAScanAverage(int value) override
Set the A-scan average. Returns true if successful.
Definition: WPScanConverter.h:260
bool SetOutputTiffFormat(bool value) override
Get the flag that determines if the output files will be in Tiff format.
Definition: WPScanConverter.h:145
bool GetOutputLogOfData() const override
Get the flag that determines if the log of the output data is taken/used.
Definition: WPScanConverter.h:78
bool GetUseContrast() const override
Get the flag that determines if contrast is used on the output.
Definition: WPScanConverter.h:81
bool SetDeleteInputFileAfterConversion(bool value) override
Set the flag that determines if the RAW input file is deleted after data is converted.
Definition: WPScanConverter.h:142
bool SetUseMovingAverage(bool value) override
Setters for displaying a moving average.
Definition: WPScanConverter.h:267
const char * GetOutputIntensityName() const override
Get the intensity file name (no path).
Definition: WPScanConverter.h:50
bool GetOutputIntensity() const override
Get the flag that determines if intensity is output.
Definition: WPScanConverter.h:62
bool GetUseScaling() const override
Get the flag that determines if scaling is used on the output.
Definition: WPScanConverter.h:84
bool SetOutputPhase(bool value) override
Set the flag that determines if phase is output.
Definition: WPScanConverter.h:136
bool GetOutputTiffFormat() const override
Get the flag that determines if the output files will be in Tiff format.
Definition: WPScanConverter.h:75
Class to convert data obtained from a line scan camera into meaningful 2D OCT image data.
Definition: IWPOCTConverter.h:56
ErrorCode
The following are error codes that are used within the converter object.
Definition: IWPOCTConverter.h:61
The data object contains pointers to input and output data.
Definition: IWPOCTInOutData.h:14