-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitkVideoFileReader.txx
More file actions
165 lines (143 loc) · 4.34 KB
/
itkVideoFileReader.txx
File metadata and controls
165 lines (143 loc) · 4.34 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkFaceDetectionFilter.txx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkVideoFileReader_txx
#define __itkVideoFileReader_txx
#include "itkVideoFileReader.h"
#include "itkExceptionObject.h"
namespace itk
{
template< typename TOutputImage >
VideoFileReader< TOutputImage >
::VideoFileReader()
{
this->InitializeProperties();
}
template< typename TOutputImage >
void VideoFileReader< TOutputImage >
::InitializeProperties()
{
this->m_FrameRequested = 0;
this->m_PositionInMSec = 0;
this->m_Ratio = 0;
this->m_FrameWidth = 0;
this->m_FrameHeight = 0;
this->m_FpS = 25;
this->m_NextFrameIsFrameRequested = false;
}
/*
* PrintSelf
*/
template< typename TOutputImage >
void
VideoFileReader< TOutputImage >
::PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Frame requested : "<<this->m_FrameRequested<< std::endl;
os << indent << "Position in milliseconds : "<<this->m_PositionInMSec<< std::endl;
os << indent << "Ratio of video elapsed : "<<this->m_Ratio<< std::endl;
os << indent << "Frame width : "<<this->m_FrameWidth<< std::endl;
os << indent << "Frame Height : "<<this->m_FrameHeight<< std::endl;
os << indent << "Number of frame per second : "<<this->m_FpS<< std::endl;
} // end PrintSelf
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::GenerateData()
{
if (Superclass::m_VideoLoaded == false )
{
this->LoadVideo();
}
if ( this->m_NextFrameIsFrameRequested == true )
{
if ( Superclass::m_VideoReader->SetNextFrameToRead(this->m_FrameRequested) == false )
{
//Means that hte video is non-seekable or out of boundaries
itk::ExceptionObject exception;
exception.SetDescription("Error, Either the video is non-seekable"
"or you're out of boundaries");
exception.SetLocation("VideoFileReader");
throw exception;
}
}
this->UpdateProperties();
Superclass::GenerateData();
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::SetFileName(const char *filename)
{
this->InitializeProperties();
Superclass::SetFileName(filename);
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::LoadVideo()
{
Superclass::LoadVideo();
this->UpdateProperties();
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::PlayInput(unsigned long frame)
{
this->SetFrameRequested(frame);
this->PlayInput();
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::PlayInput()
{
/*int result;
cvShowImage("Reader Input",cvQueryFrame(Superclass::m_Capture));
result=cvWaitKey(1000/this->m_FpS);*/
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::PlayOutput (unsigned long frame)
{/*
this->SetFrameRequested(frame);
this->PlayOutput();*/
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::PlayOutput ()
{/*
int result;
cvShowImage("Reader output",Superclass::m_CVImage);
result=cvWaitKey(1000/this->m_FpS);*/
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::SetFrameRequested(unsigned long frame)
{
this->m_FrameRequested = frame;
this->Modified();
}
template< typename TOutputImage >
void VideoFileReader<TOutputImage>
::UpdateProperties()
{
if ( Superclass::m_VideoLoaded == true )
{
this->m_FrameHeight = Superclass::m_VideoReader->GetHeight() ;
this->m_FrameWidth = Superclass::m_VideoReader->GetWidth();
this->m_FrameRequested = Superclass::m_VideoReader->GetHeight();
this->m_PositionInMSec = Superclass::m_VideoReader->GetPositionInMSec();
this->m_Ratio = Superclass::m_VideoReader->GetRatio();
this->m_FpS = Superclass::m_VideoReader->GetFpS();
//this->m_FourCC = Superclass::m_VideoReader->GetFourCC();
}
}
} // end namespace itk
#endif