PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusOpenCVCaptureVideoSource.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 __vtkPlusOpenCVCaptureVideoSource_h
8 #define __vtkPlusOpenCVCaptureVideoSource_h
9 
10 #include "vtkPlusDataCollectionExport.h"
11 #include "vtkPlusDevice.h"
12 
13 // OpenCV includes
14 #include <opencv2/videoio.hpp>
15 
26 namespace cv
27 {
28  class VideoCapture;
29  class Mat;
30 }
31 
32 class vtkPlusDataCollectionExport vtkPlusOpenCVCaptureVideoSource : public vtkPlusDevice
33 {
34 public:
37  virtual void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
38 
40  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* config);
42  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* config);
43 
45  PlusStatus FreezeDevice(bool freeze);
46 
48  virtual bool IsTracker() const { return false; }
49 
51  virtual PlusStatus InternalUpdate();
52 
54  virtual PlusStatus NotifyConfigured();
55 
56  vtkGetStdStringMacro(VideoURL);
57  vtkSetStdStringMacro(VideoURL);
58 
59  vtkGetMacro(DeviceIndex, int);
60  vtkSetMacro(DeviceIndex, int);
61 
62  vtkGetMacro(AutofocusEnabled, bool);
63  vtkSetMacro(AutofocusEnabled, bool);
64 
65  vtkGetMacro(AutoexposureEnabled, bool);
66  vtkSetMacro(AutoexposureEnabled, bool);
67 
68  vtkGetMacro(FourCC, std::string);
69  vtkSetMacro(FourCC, std::string);
70 
71  static cv::VideoCaptureAPIs CaptureAPIFromString(const std::string& apiString);
72  static std::string StringFromCaptureAPI(cv::VideoCaptureAPIs api);
73 
74 protected:
77 
78  virtual PlusStatus InternalConnect();
80 
81 protected:
82  std::string VideoURL;
84  std::shared_ptr<cv::VideoCapture> Capture;
85  std::shared_ptr<cv::Mat> Frame;
86  std::shared_ptr<cv::Mat> UndistortedFrame;
87  cv::VideoCaptureAPIs RequestedCaptureAPI;
90  std::string FourCC;
91 
92  FrameSizeType FrameSize;
93 
94  std::shared_ptr<cv::Mat> CameraMatrix;
95  std::shared_ptr<cv::Mat> DistortionCoefficients;
96 };
97 
98 #endif // __vtkPlusOpenCVCaptureVideoSource_h
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
std::shared_ptr< cv::VideoCapture > Capture
virtual PlusStatus InternalConnect()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
Class for interfacing an OpenCVC capture device and recording frames into a Plus buffer.
#define VTK_OVERRIDE
Definition: PlusCommon.h:49
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
std::shared_ptr< cv::Mat > DistortionCoefficients
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
virtual PlusStatus NotifyConfigured()
virtual PlusStatus InternalDisconnect()
virtual PlusStatus InternalUpdate()
static vtkPlusDevice * New()