8 #include "PlusConfigure.h" 16 #include <vtkImageData.h> 17 #include <vtkImageImport.h> 18 #include <vtkObjectFactory.h> 32 , FocusDepthPercent(-1)
33 , ConnectedToDevice(false)
60 LOG_TRACE(
"vtkPlusTelemedVideoSource::ReadConfiguration");
62 XML_READ_STD_ARRAY_ATTRIBUTE_OPTIONAL(
int, 3,
FrameSize, deviceConfig);
64 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
ProbeId, deviceConfig);
65 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
double,
DepthMm, deviceConfig);
66 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
double,
FrequencyMhz, deviceConfig);
67 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
double,
DynRangeDb, deviceConfig);
68 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
double,
GainPercent, deviceConfig);
69 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
double,
PowerDb, deviceConfig);
81 deviceConfig->SetVectorAttribute(
"FrameSize", 3, frameSize);
83 deviceConfig->SetIntAttribute(
"ProbeId", this->
ProbeId);
84 deviceConfig->SetDoubleAttribute(
"DepthMm", this->
DepthMm);
85 deviceConfig->SetDoubleAttribute(
"FrequencyMhz", this->
FrequencyMhz);
86 deviceConfig->SetDoubleAttribute(
"DynRangeDb", this->
DynRangeDb);
87 deviceConfig->SetDoubleAttribute(
"GainPercent", this->
GainPercent);
88 deviceConfig->SetDoubleAttribute(
"PowerDb", this->
PowerDb);
110 LOG_ERROR(
"vtkPlusTelemedVideoSource device initialization failed");
147 double deviceFrequencyMhz;
153 double deviceDepthMM;
159 double deviceGainPercent;
165 double deviceDynRangeDb;
171 double devicePowerDb;
177 double deviceFocusDepthPercent;
191 LOG_DEBUG(
"Disconnect from Telemed");
202 LOG_TRACE(
"vtkPlusTelemedVideoSource::InternalUpdate");
211 if (bufferData == NULL)
213 LOG_ERROR(
"No frame received by the device");
219 FrameSizeType frameSizeInPix = { 0, 0, 1 };
222 if (frameSizeInPix[0] * frameSizeInPix[1] == 0)
224 LOG_ERROR(
"Failed to retrieve valid frame size (got " << frameSizeInPix[0] <<
"x" << frameSizeInPix[1]);
227 unsigned int numberOfScalarComponents = bufferSize / (frameSizeInPix[0] * frameSizeInPix[1]);
231 if (numberOfScalarComponents == 3)
236 else if (numberOfScalarComponents == 4)
243 LOG_ERROR(
"Unexpected number of scalar components: " << numberOfScalarComponents);
251 LOG_ERROR(
"Unable to retrieve the video source in the Telemed device.");
258 LOG_DEBUG(
"Set up image buffer for Telemed");
262 LOG_DEBUG(
"Frame size: " << frameSizeInPix[0] <<
"x" << frameSizeInPix[1]
263 <<
", pixel type: " << vtkImageScalarTypeNameMacro(aSource->
GetPixelType())
264 <<
", buffer image orientation: " << igsioCommon::GetStringFromUsImageOrientation(aSource->
GetInputImageOrientation()));
282 LOG_ERROR(
"Error while decoding the grabbed image");
296 #define IMAGING_PARAMETER_SET(parameterName) \ 297 PlusStatus vtkPlusTelemedVideoSource::Set##parameterName(double a##parameterName) \ 299 LOG_INFO("Setting US parameter "<<#parameterName<<"="<<a##parameterName); \ 300 if (this->Device==NULL) \ 303 this->parameterName=a##parameterName; \ 304 return PLUS_SUCCESS; \ 306 int oldParamValue = this->parameterName; \ 307 this->parameterName=a##parameterName; \ 308 if (this->Device->Set##parameterName(this->parameterName)!=PLUS_SUCCESS) \ 310 LOG_ERROR("vtkPlusTelemedVideoSource parameter setting failed: "<<#parameterName<<"="<<a##parameterName); \ 311 this->parameterName=oldParamValue; \ 314 return PLUS_SUCCESS; \ 317 #define IMAGING_PARAMETER_GET(parameterName) \ 318 PlusStatus vtkPlusTelemedVideoSource::Get##parameterName(double &a##parameterName) \ 320 if (this->Device==NULL) \ 323 a##parameterName=this->parameterName; \ 324 return PLUS_SUCCESS; \ 326 if (this->Device->Get##parameterName(this->parameterName)!=PLUS_SUCCESS) \ 328 LOG_ERROR("vtkPlusTelemedVideoSource parameter setting failed: "<<parameterName<<"="<<a##parameterName); \ 331 a##parameterName=this->parameterName; \ 332 return PLUS_SUCCESS; \ 354 LOG_WARNING(
"vtkPlusTelemedVideoSource is expecting one output channel and there are " << this->
OutputChannels.size() <<
" channels. First output channel will be used.");
359 LOG_ERROR(
"No output channels defined for vtkPlusTelemedVideoSource. Cannot proceed.");
370 std::ostringstream versionString;
371 versionString <<
"Telemed version unknown" << std::ends;
372 return versionString.str();
393 LOG_ERROR(
"Failed to set frequency imaging parameter");
404 LOG_ERROR(
"Failed to set depth imaging parameter");
415 LOG_ERROR(
"Failed to set gain imaging parameter");
426 LOG_ERROR(
"Failed to set dynamic range imaging parameter");
437 LOG_ERROR(
"Failed to set power imaging parameter");
448 LOG_ERROR(
"Failed to set focus depth percent imaging parameter");
static const char * KEY_DYNRANGE
vtkPlusTelemedVideoSource()
bool IsPending(const std::string ¶mName) const
PlusStatus SetGainPercent(double aGainPercent)
US_IMAGE_TYPE GetImageType()
PlusStatus GetFrequencyMhz(double &aFrequencyMhz)
static const char * KEY_DEPTH
~vtkPlusTelemedVideoSource()
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
igsioVideoFrame UncompressedVideoFrame
static const char * KEY_FOCUS_DEPTH
unsigned char * CaptureFrame()
vtkStandardNewMacro(vtkPlusTelemedVideoSource)
static const char * KEY_FREQUENCY
PlusStatus InternalConnect()
PlusStatus GetFocusDepthPercent(double &aFocusDepthPercent) const
PlusStatus GetDepthMm(double &aDepthMm) const
PlusStatus SetInputFrameSize(unsigned int x, unsigned int y, unsigned int z)
void FreezeDevice(bool freeze)
void GetFrameSize(FrameSizeType &frameSize)
virtual PlusStatus AddItem(vtkImageData *frame, US_IMAGE_ORIENTATION usImageOrientation, US_IMAGE_TYPE imageType, long frameNumber, double unfilteredTimestamp=UNDEFINED_TIMESTAMP, double filteredTimestamp=UNDEFINED_TIMESTAMP, const igsioFieldMapType *customFields=NULL)
static PlusStatus ConvertToBGR24(ComponentOrdering outputOrdering, PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
PlusStatus InternalDisconnect()
virtual std::string GetSdkVersion()
vtkPlusUsImagingParameters * ImagingParameters
Store the current imaging parameters.
bool RequireImageOrientationInConfiguration
PlusStatus SetImageType(US_IMAGE_TYPE imageType)
PlusStatus GetGainPercent(double &aGainPercent)
PlusStatus ReadConfiguration(vtkXMLDataElement *config)
static const char * KEY_GAIN
PlusStatus SetPixelType(igsioCommon::VTKScalarPixelType pixelType)
PlusStatus GetGainPercent(double aGainPercent) const
virtual igsioCommon::VTKScalarPixelType GetPixelType()
virtual PlusStatus SetFrameSize(const FrameSizeType &frameSize)
PlusStatus GetPowerDb(double &aPower) const
PlusStatus GetFirstActiveOutputVideoSource(vtkPlusDataSource *&aVideoSource)
PlusStatus SetPowerDb(double aPower)
PlusStatus WriteConfiguration(vtkXMLDataElement *config)
unsigned long FrameNumber
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
PlusStatus SetFrequencyMhz(double aFrequencyMhz)
void SetMaximumFrameSize(const FrameSizeType &maxFrameSize)
PlusStatus SetFocusDepthPercent(double aFocusDepthPercent)
TelemedUltrasound * Device
PlusStatus GetDynRangeDb(double &aDynRangeDb) const
PlusStatus SetGainPercent(double aGainPercent)
#define IMAGING_PARAMETER_SET(parameterName)
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
static const char * KEY_POWER
PlusStatus SetDynRangeDb(double aDynRangeDb)
virtual US_IMAGE_ORIENTATION GetInputImageOrientation()
PlusStatus Connect(int probeId=0)
bool StartThreadForInternalUpdates
PlusStatus GetFocusDepthPercent(double &aFocusDepthPercent)
static PlusStatus ConvertToGray(int inputCompression, int width, int height, unsigned char *s, unsigned char *d)
virtual PlusStatus NotifyConfigured()
PlusStatus SetFrequencyMhz(double aFrequencyMhz)
PlusStatus InternalUpdate()
ChannelContainer OutputChannels
#define IMAGING_PARAMETER_GET(parameterName)
PlusStatus GetDepthMm(double &aDepthMm)
PlusStatus SetDynRangeDb(double aDynamicRange)
PlusStatus GetFrequencyMhz(double &aFrequencyMhz) const
PlusStatus SetDepthMm(double aDepthMm)
PlusStatus SetFocusDepthPercent(double aFocusDepthPercent)
PlusStatus GetPowerDb(double &aPowerDb)
virtual PlusStatus InternalApplyImagingParameterChange()
PlusStatus SetPowerDb(double aPowerDb)
unsigned long GetBufferSize()
bool IsSet(const std::string ¶mName) const
PlusStatus FreezeDevice(bool freeze)
PlusStatus GetDynRangeDb(double &aDynamicRange)
PlusStatus SetDepthMm(double aDepthMm)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual int GetNumberOfItems()
Class for interfacing the device manager class, and the PLUS library. The devices are Telemed ultraso...
Interface to a 3D positioning tool, video source, or generalized data stream.