-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitkOpenCVReader.h
More file actions
107 lines (86 loc) · 3.39 KB
/
itkOpenCVReader.h
File metadata and controls
107 lines (86 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "itkVideoReaderBase.h"
#include "itkExceptionObject.h"
#include "itkImportImageFilter.h"
#include "cv.h"
#include "highgui.h"
#ifndef __itkOpenCVReader_h
#define __itkOpenCVReader_h
namespace itk
{
/** \class OpenCVReader
* \brief
*
*
* \sa VideoReaderBase
*
* \ingroup OpenCVFilters
*/
template <class TImage>
class ITK_EXPORT OpenCVReader : public VideoReaderBase < TImage >
{
public:
/** Standard class typedefs. **/
typedef OpenCVReader Self;
typedef VideoReaderBase<TImage> Superclass;
typedef SmartPointer< Self > Pointer;
typedef TImage ImageType;
typedef typename ImageType::PixelType PixelType;
/** Runtime type information (and related methods). **/
itkTypeMacro(OpenCVReader, Superclass);
/** Method for creation through the object factory. **/
itkNewMacro(Self);
/** Convinient typedef **/
typedef itk::ImportImageFilter<typename TImage::PixelType,2> ImportFilterType;
/** Try to open a video **/
/** Return true if in case of a success, false for a faillure **/
bool OpenReader (const char* filename);
/** Return the state of the video (opened or not) **/
bool IsReaderOpen () {return this->m_ReaderOpen;};
/** Return the image read form a video file **/
typename ImageType::Pointer Read();
/** Set the next frame to read and return ture if operation succesfull **/
bool SetNextFrameToRead( unsigned long frameNumber );
/** A bunch of accessor **/
int GetWidth() {return this->m_Width;};
int GetHeight() {return this->m_Height;};
double GetXOrigin() {return this->m_Origin[0];};
double GetYOrigin() {return this->m_Origin[1];};
double GetXSpacing() {return this->m_Spacing[0];};
double GetYSpacing() {return this->m_Spacing[1];};
double GetPositionInMSec () {return this->m_PositionInMSec;};
double GetRatio () {return this->m_Ratio;};
unsigned long GetFrameTotal () {return this->m_FrameTotal;};
double GetFpS() {return this->m_FpS;};
unsigned long GetCurrentFrame() {return this->m_CurrentFrame;}
protected:
OpenCVReader();
~OpenCVReader(){};
void PrintSelf(std::ostream & os, Indent indent) const;
private:
OpenCVReader(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
void UpdateProperties ();
IplImage *m_CVImage;
IplImage *m_Temp;
CvCapture *m_Capture;
bool m_ReaderOpen;
int m_FourCC;
double m_FpS;
unsigned long m_FrameTotal;
unsigned long m_CurrentFrame;
int m_Width;
int m_Height;
double m_Ratio;
double m_PositionInMSec;
double m_Origin[2];
double m_Spacing[2];
typename ImportFilterType::SizeType m_Size;
typename ImportFilterType::IndexType m_Start;
typename ImportFilterType::RegionType m_Region;
typename ImportFilterType::Pointer m_ImportFilter;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkOpenCVReader.txx"
#endif
#endif // __itkOpenCVReader_h