8 #include "PlusConfigure.h" 18 #include <vtkImageData.h> 19 #include <vtkObjectFactory.h> 20 #include <vtksys/SystemTools.hxx> 89 LOG_TRACE(
"vtkPlusEpiphanVideoSource::InternalConnect");
100 LOG_ERROR(
"Epiphan Device found");
103 const char UNKNOWN_DEVICE[] =
"UNKNOWN";
105 if (connectedTo == NULL)
107 connectedTo = UNKNOWN_DEVICE;
110 LOG_WARNING(
"Epiphan Device with the requested location '" << this->
GrabberLocation <<
"' not found. Connected to " << connectedTo <<
" device instead.");
115 LOG_DEBUG(
"Serial Number not specified. Looking for any available device");
118 LOG_ERROR(
"Epiphan Device Not found");
126 LOG_ERROR(
"No signal detected");
130 double maxPossibleAcquisitionRate = vm.
vfreq / 1000;
137 LOG_ERROR(
"No valid signal detected. Invalid frame size is received from the framegrabber: " << vm.
width <<
"x" << vm.
height);
147 LOG_WARNING(
"ClipRectangleSize[0] is not a multiple of 4. Acquired image may be skewed.");
164 LOG_ERROR(
"Unable to retrieve the video source in the Epiphan device on channel " << (*this->
OutputChannels.begin())->GetChannelId());
183 LOG_ERROR(
"Unable to retrieve the video source in the Epiphan device on channel " << (*this->
OutputChannels.begin())->GetChannelId());
200 LOG_DEBUG(
"vtkPlusEpiphanVideoSource::InternalDisconnect");
206 LOG_WARNING(this->
GetDeviceId() <<
": Unable to stop recording.");
224 LOG_ERROR(this->
GetDeviceId() <<
": Unable to frame grabber.");
260 LOG_WARNING(
"Frame not captured for video format: " << videoFormat);
264 if (frame->crop.width < 0 || frame->crop.height < 0)
266 LOG_ERROR(
"Negative cropping values passed in from epiphan.");
270 if (static_cast<unsigned int>(frame->crop.width) != this->FrameSize[0] || static_cast<unsigned int>(frame->crop.height) != this->FrameSize[1])
272 LOG_ERROR(
"Image size received from Epiphan (" << frame->crop.width <<
"x" << frame->crop.height <<
") does not match the clip rectangle size (" <<
273 this->FrameSize[0] <<
"x" << this->FrameSize[1] <<
")");
283 LOG_ERROR(
"Unable to retrieve the video source in the Epiphan device on channel " << (*this->
OutputChannels.begin())->GetChannelId());
286 int numberOfScalarComponents(1);
289 numberOfScalarComponents = 3;
293 LOG_ERROR(
"Error adding item to video source " << aSource->GetId() <<
" on channel " << (*this->
OutputChannels.begin())->GetChannelId());
316 const char* grabberLocation = deviceConfig->GetAttribute(
"GrabberLocation");
317 const char* serialNumber = deviceConfig->GetAttribute(
"SerialNumber");
318 if (grabberLocation != NULL)
320 SetGrabberLocation(grabberLocation);
322 else if (serialNumber != NULL)
324 std::string grabberLocationString = std::string(
"sn:") + serialNumber;
325 SetGrabberLocation(grabberLocationString);
326 LOG_WARNING(
"Epiphan SerialNumber is specified. This attribute is deprecated, please use GrabberLocation=\"sn:SERIAL\" attribute instead.");
330 LOG_DEBUG(
"Epiphan device location is not specified in the configuration");
333 XML_READ_STRING_ATTRIBUTE_OPTIONAL(
RotationMode, deviceConfig);
336 if (igsioCommon::IsEqualInsensitive(this->
RotationMode,
"Left90") == 0)
340 else if (igsioCommon::IsEqualInsensitive(this->
RotationMode,
"Right90") == 0)
344 else if (igsioCommon::IsEqualInsensitive(this->
RotationMode,
"180") == 0)
350 XML_READ_STRING_ATTRIBUTE_OPTIONAL(
ScaleMode, deviceConfig);
353 if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"NearestNeighbor") == 0)
357 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"WeightedAverage") == 0)
361 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"FastBilinear") == 0)
365 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Bilinear") == 0)
369 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Bicubic") == 0)
373 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Experimental") == 0)
377 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Point") == 0)
381 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Area") == 0)
385 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"BicubLin") == 0)
389 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Sinc") == 0)
393 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Lanczos") == 0)
397 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Spline") == 0)
401 else if (igsioCommon::IsEqualInsensitive(this->
ScaleMode,
"Hardware") == 0)
419 XML_WRITE_STRING_ATTRIBUTE_REMOVE_IF_EMPTY(
GrabberLocation, imageAcquisitionConfig);
422 XML_REMOVE_ATTRIBUTE(
"SerialNumber", imageAcquisitionConfig);
461 LOG_ERROR(
"Epiphan is incorrectly configured. Unable to access video data source.");
466 LOG_ERROR(
"Epiphan is incorrectly configured. Unable to access video data sources.");
475 LOG_ERROR(
"Unable to retrieve the video source in the Epiphan device on channel " << (*this->
OutputChannels.begin())->GetChannelId());
480 LOG_ERROR(
"Conflicting image types in data sources. Please confirm matching image types.");
void FrmGrab_Close(FrmGrabber *fg)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
PlusStatus InternalUpdate()
std::array< int, 3 > GetClipRectangleSize() const
US_IMAGE_TYPE GetImageType()
virtual int GetNumberOfVideoSources() const
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
void FrmGrab_Stop(FrmGrabber *fg)
std::array< int, 3 > ClipRectangleOrigin
virtual PlusStatus InternalDisconnect()
std::array< int, 3 > ClipRectangleSize
PlusStatus GetVideoSourceByIndex(const unsigned int index, vtkPlusDataSource *&aVideoSource)
virtual PlusStatus InternalStopRecording()
virtual std::string GetDeviceId() const
PlusStatus SetInputFrameSize(unsigned int x, unsigned int y, unsigned int z)
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)
bool RequireImageOrientationInConfiguration
PlusStatus SetAcquisitionRate(double aRate)
struct _FrmGrabber FrmGrabber
PlusStatus SetPixelType(igsioCommon::VTKScalarPixelType pixelType)
FrmGrabber * FrmGrabLocal_Open(void)
virtual PlusStatus NotifyConfigured()
virtual double GetAcquisitionRate() const
PlusStatus GetFirstVideoSource(vtkPlusDataSource *&anImage)
const char * FrmGrab_GetLocation(FrmGrabber *fg)
virtual PlusStatus Disconnect()
virtual bool IsTracker() const
unsigned long FrameNumber
virtual PlusStatus InternalConnect()
void FrmGrab_Deinit(void)
std::array< int, 3 > GetClipRectangleOrigin() const
V2U_BOOL FrmGrab_Start(FrmGrabber *fg)
~vtkPlusEpiphanVideoSource()
#define V2U_SCALE_MODE_TO_FLAGS(_m)
virtual PlusStatus StopRecording()
vtkStandardNewMacro(vtkPlusEpiphanVideoSource)
V2U_BOOL FrmGrab_DetectVideoMode(FrmGrabber *fg, V2U_VideoMode *vm)
#define V2U_ROTATION_MODE_TO_FLAGS(_m)
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
void FrmGrabNet_Init(void)
vtkPlusEpiphanVideoSource()
US_IMAGE_TYPE CaptureImageType
virtual US_IMAGE_ORIENTATION GetInputImageOrientation()
PlusStatus CropRectangle(vtkIGSIOTrackedFrameList *trackedFrameList, igsioVideoFrame::FlipInfoType &flipInfo, const std::vector< int > &cropRectOrigin, const std::vector< int > &cropRectSize)
std::string GrabberLocation
bool StartThreadForInternalUpdates
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *config)
void SetClipRectangleSize(const std::array< int, 3 > &size)
V2U_GrabFrame2 * FrmGrab_Frame(FrmGrabber *fg, V2U_UINT32 format, const V2URect *crop)
ChannelContainer OutputChannels
PlusStatus SetNumberOfScalarComponents(unsigned int numberOfScalarComponents)
#define V2U_GRABFRAME_FORMAT_RGB24
#define V2U_GRABFRAME_FORMAT_Y8
Class for providing video input interfaces between VTK and Epiphan frame grabber device.
void FrmGrab_Release(FrmGrabber *fg, V2U_GrabFrame2 *frame)
virtual PlusStatus InternalStartRecording()
FrmGrabber * FrmGrab_Open(const char *location)
void SetClipRectangleOrigin(const std::array< int, 3 > &origin)
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *config)
Interface to a 3D positioning tool, video source, or generalized data stream.