ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkOpenCVVideoIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkOpenCVVideoIO_h
19#define itkOpenCVVideoIO_h
20
21#include "itkVideoIOBase.h"
22
23#include "opencv2/videoio.hpp"
24
25#include "ITKVideoBridgeOpenCVExport.h"
26
27
28namespace itk
29{
37class ITKVideoBridgeOpenCV_EXPORT OpenCVVideoIO : public VideoIOBase
38{
39public:
40 ITK_DISALLOW_COPY_AND_MOVE(OpenCVVideoIO);
41
46
51
53 itkNewMacro(Self);
54
56 itkOverrideGetNameOfClassMacro(OpenCVVideoIO);
57
59 void
61
62 //
63 // Data reading-related methods
64 //
65
67 void
68 SetReadFromFile() override;
69
71 void
73
76 bool
77 CanReadFile(const char *) override;
78
80 bool
81 CanReadCamera(CameraIDType cameraID) const override;
82
84 void
86
88 void
89 Read(void * buffer) override;
90
93 bool
94 SetNextFrameToRead(FrameOffsetType frameNumber) override;
95
98 GetPositionInMSec() const override;
100 GetRatio() const override;
102 GetFrameTotal() const override;
104 GetFramesPerSecond() const override;
106 GetCurrentFrame() const override;
107 virtual FrameOffsetType
110 GetLastIFrame() const override;
111
112 //
113 // Data writing-related methods
114 //
115
117 virtual void
119 virtual CameraIDType
121
124 double
125 GetSpacing(unsigned int itkNotUsed(i)) const override
126 {
127 return 1.0;
128 }
129 double
130 GetOrigin(unsigned int itkNotUsed(i)) const override
131 {
132 return 0.0;
133 }
134 std::vector<double>
135 GetDirection(unsigned int i) const override
136 {
137 return this->GetDefaultDirection(i);
138 }
139
142 bool
143 CanWriteFile(const char *) override;
144
147 void
149
152 void
153 Write(const void * buffer) override;
154
156 void
158 const std::vector<SizeValueType> & dim,
159 const char * fourCC,
160 unsigned int nChannels,
161 IOComponentEnum componentType) override;
162
163protected:
165 ~OpenCVVideoIO() override;
166
167 void
168 PrintSelf(std::ostream & os, Indent indent) const override;
169
171 void
173
175 void
177
179 void
181
183 void
185
186private:
187 cv::Mat m_CVImage{};
188 cv::VideoCapture m_Capture{};
189 cv::VideoWriter m_Writer{};
190 int m_FourCC{};
191
193};
194} // end namespace itk
195
196#endif // itkOpenCVVideoIO_h
virtual std::vector< double > GetDefaultDirection(unsigned int k) const
Control indentation during Print() invocation.
Definition itkIndent.h:51
TemporalRatioType GetFramesPerSecond() const override
FrameOffsetType GetLastIFrame() const override
TemporalRatioType GetRatio() const override
bool CanReadCamera(CameraIDType cameraID) const override
void Read(void *buffer) override
void SetReadFromCamera() override
virtual void SetCameraIndex(CameraIDType idx)
cv::VideoCapture m_Capture
void FinishReadingOrWriting() override
void WriteImageInformation() override
void UpdateReaderProperties()
FrameOffsetType GetCurrentFrame() const override
virtual CameraIDType GetCameraIndex() const
Superclass::CameraIDType CameraIDType
virtual FrameOffsetType GetIFrameInterval() const
double GetOrigin(unsigned int i) const override
void SetWriterParameters(TemporalRatioType fps, const std::vector< SizeValueType > &dim, const char *fourCC, unsigned int nChannels, IOComponentEnum componentType) override
void ReadImageInformation() override
Superclass::TemporalRatioType TemporalRatioType
void SetReadFromFile() override
TemporalOffsetType GetPositionInMSec() const override
std::vector< double > GetDirection(unsigned int i) const override
cv::VideoWriter m_Writer
void Write(const void *buffer) override
Superclass::TemporalOffsetType TemporalOffsetType
Superclass::FrameOffsetType FrameOffsetType
bool CanReadFile(const char *) override
bool CanWriteFile(const char *) override
bool SetNextFrameToRead(FrameOffsetType frameNumber) override
double GetSpacing(unsigned int i) const override
SmartPointer< Self > Pointer
void PrintSelf(std::ostream &os, Indent indent) const override
FrameOffsetType GetFrameTotal() const override
~OpenCVVideoIO() override
Implements transparent reference counting.
SizeValueType CameraIDType
SizeValueType FrameOffsetType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
CommonEnums::IOComponent IOComponentEnum