8 #include "PlusConfigure.h" 14 #include <vtkImageData.h> 15 #include <vtkObjectFactory.h> 16 #include <vtksys/SystemTools.hxx> 19 #include <opencv2/imgproc.hpp> 20 #include <opencv2/core/mat.hpp> 21 #if defined(PLUS_USE_OPENCL) 22 #include <opencv2/core/ocl.hpp> 34 : RequestedFormat(OVR::OV_CAM20VR_VGA)
35 , ProcessingMode(OVR::OV_CAMQT_NONE)
39 , LeftEyeDataSource(NULL)
40 , RightEyeDataSource(NULL)
41 , IsCapturingRGB(false)
64 os << indent <<
"Framerate: " <<
Framerate << std::endl;
65 os << indent <<
"CameraSync: " <<
CameraSync << std::endl;
69 os << indent <<
"Vendor: " <<
Vendor << std::endl;
75 LOG_TRACE(
"vtkPlusOvrvisionProVideoSource::InternalConnect");
77 #if defined(PLUS_USE_OPENCL) 78 cv::ocl::setUseOpenCL(
true);
83 LOG_ERROR(
"Unable to connect to OvrvisionPro device.");
116 #if defined(PLUS_USE_OPENCL) 118 cv::ocl::PlatformInfo info(&
id);
138 LOG_DEBUG(
"vtkPlusOvrvisionProVideoSource::InternalDisconnect");
156 #if defined(PLUS_USE_OPENCL) 162 cv::cvtColor(this->LeftImageCL, this->LeftImageCL, cv::COLOR_BGRA2RGB);
163 cv::cvtColor(this->RightImageCL, this->RightImageCL, cv::COLOR_BGRA2RGB);
184 this->LeftEyeDataSource->GetInputImageOrientation(),
192 LOG_ERROR(
"Unable to add left eye image to data source.");
197 this->RightEyeDataSource->GetInputImageOrientation(),
205 LOG_ERROR(
"Unable to add right eye image to data source.");
228 LOG_WARNING(
"Unrecognized processing mode detected. Defaulting to OVR::OV_CAMQT_NONE.");
237 case OVR::OV_CAM5MP_FULL:
238 return "OV_CAM5MP_FULL";
239 case OVR::OV_CAM5MP_FHD:
240 return "OV_CAM5MP_FHD";
241 case OVR::OV_CAMHD_FULL:
242 return "OV_CAMHD_FULL";
243 case OVR::OV_CAMVR_FULL:
244 return "OV_CAMVR_FULL";
245 case OVR::OV_CAMVR_WIDE:
246 return "OV_CAMVR_WIDE";
247 case OVR::OV_CAMVR_VGA:
248 return "OV_CAMVR_VGA";
249 case OVR::OV_CAMVR_QVGA:
250 return "OV_CAMVR_QVGA";
251 case OVR::OV_CAM20HD_FULL:
252 return "OV_CAM20HD_FULL";
253 case OVR::OV_CAM20VR_VGA:
255 return "OV_CAM20VR_VGA";
263 std::string nonConstFormat = format;
264 if (nonConstFormat.find(
"OV_") == std::string::npos)
266 nonConstFormat.insert(0,
"OV_");
269 if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAM5MP_FULL"))
271 return OVR::OV_CAM5MP_FULL;
273 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAM5MP_FHD"))
275 return OVR::OV_CAM5MP_FHD;
277 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAMHD_FULL"))
279 return OVR::OV_CAMHD_FULL;
281 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAMVR_FULL"))
283 return OVR::OV_CAMVR_FULL;
285 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAMVR_WIDE"))
287 return OVR::OV_CAMVR_WIDE;
289 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAMVR_VGA"))
291 return OVR::OV_CAMVR_VGA;
293 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAMVR_QVGA"))
295 return OVR::OV_CAMVR_QVGA;
297 else if (igsioCommon::IsEqualInsensitive(nonConstFormat,
"OV_CAM20HD_FULL"))
299 return OVR::OV_CAM20HD_FULL;
303 return OVR::OV_CAM20VR_VGA;
312 auto attr = deviceConfig->GetAttribute(
"RequestedFormat");
315 LOG_INFO(
"No requested format defined. Falling back to OV_CAM20VR_VGA (640x480@30fps).");
324 XML_READ_STRING_ATTRIBUTE_OPTIONAL(
Vendor, deviceConfig);
325 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
Exposure, deviceConfig);
326 XML_READ_BOOL_ATTRIBUTE_OPTIONAL(
CameraSync, deviceConfig);
345 rootConfigElement->SetAttribute(
"RequestedFormat", requestedFormat.c_str());
349 deviceConfig->SetAttribute(
"CameraSync",
"TRUE");
356 case OVR::OV_CAMQT_DMS:
357 deviceConfig->SetAttribute(
"ProcessingModeName",
"OV_CAMQT_DMS");
359 case OVR::OV_CAMQT_DMSRMP:
360 deviceConfig->SetAttribute(
"ProcessingModeName",
"OV_CAMQT_DMSRMP");
365 XML_WRITE_STRING_ATTRIBUTE_IF_NOT_EMPTY(
Vendor, deviceConfig);
388 LOG_ERROR(
"Mistmatch between left and right eye data source image types.");
403 LOG_ERROR(
"OvrvisionPro device requires exactly 2 output channels. One for each eye.");
PlusStatus GetDataSource(const char *aSourceId, vtkPlusDataSource *&aSource)
cv::Mat LeftImageColorConverted
std::array< unsigned int, 2 > Resolution
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus NotifyConfigured()
Perform any completion tasks once configured.
US_IMAGE_TYPE GetImageType()
cv::Mat RightImageColorConverted
vtkStandardNewMacro(vtkPlusOvrvisionProVideoSource)
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *config)
Write configuration to xml data.
static std::string CamPropToString(OVR::Camprop format)
virtual PlusStatus InternalDisconnect()
Device-specific disconnect.
OVR::Camprop RequestedFormat
PlusStatus SetInputFrameSize(unsigned int x, unsigned int y, unsigned int z)
~vtkPlusOvrvisionProVideoSource()
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)
vtkPlusOvrvisionProVideoSource()
std::array< unsigned int, 2 > GetResolution() const
bool RequireImageOrientationInConfiguration
void ConfigureProcessingMode()
vtkPlusDataSource * RightEyeDataSource
PlusStatus SetAcquisitionRate(double aRate)
OVR::ROI RegionOfInterest
virtual PlusStatus InternalUpdate()
Device-specific on-update function.
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *config)
Read configuration from xml data.
virtual PlusStatus Disconnect()
OVR::OvrvisionPro OvrvisionProHandle
unsigned long FrameNumber
OVR::Camqt ProcessingMode
std::string LeftEyeDataSourceName
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
static OVR::Camprop StringToCamProp(const std::string &format)
std::string RightEyeDataSourceName
bool StartThreadForInternalUpdates
std::string ProcessingModeName
void PrintSelf(ostream &os, vtkIndent indent)
virtual PlusStatus InternalConnect()
Device-specific connect.
ChannelContainer OutputChannels
PlusStatus SetNumberOfScalarComponents(unsigned int numberOfScalarComponents)
FrameSizeType GetInputFrameSize() const
vtkPlusDataSource * LeftEyeDataSource