-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitkVideoFileWriter.h
More file actions
119 lines (94 loc) · 3.42 KB
/
itkVideoFileWriter.h
File metadata and controls
119 lines (94 loc) · 3.42 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
#include "itkMacro.h"
#include "itkProcessObject.h"
#include "itkVideoWriterBase.h"
#include "itkImageToImageFilter.h"
#ifndef __itkVideoFileWriter_h
#define __itkVideoFileWriter_h
namespace itk
{
/** \class VideoFileWriter
* \brief Write an Video File and stream it using OpenCV libs
* Enable you to write video.
*
* (Only ?) Supports .avi format. Thus, the file you are trying to write
* should have this extension.
* By default, the writer write a video with the codec PIM1 with 25 frame/s.
* Since it was made in concurrence with the VideoFileReader, it only
* supports grayscale images as an input.
* The output is fo now encoded with pixel having a size of 1 bytes and being
* unsigned.
*
* How to use : Exactly as the ImageFileWriter. Attention,t when an update is called,
* since itk only works with image, the VideoFileWriter only add one frame to
* the video (is current input).
*
* Attention, if you want to read the video, you should either :
* . Make sure the object VideoFileWriter is not referenced anymore
* ( see \sa SmartPointer )
* . Call the method EndVideo() on your writer.
*
* \sa VideoFileReader
* \sa LightVideoFileReader
*
* \ingroup OpenCVFilters
*/
template <class TInputImage >
class ITK_EXPORT VideoFileWriter : public ProcessObject
{
public:
/** Standard class typedefs. */
typedef VideoFileWriter Self;
typedef ProcessObject Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
/** Method for creation through the object factory. **/
itkNewMacro(Self);
/** Run-time type information (and related methods). **/
itkTypeMacro(VideoFileWriter, ProcessObject);
/** Set/Get method for the Filename (which really is his path) **/
void SetFileName (const char *filename);
itkGetStringMacro(FileName);
/** Set/Get method for the codec, by default IYUV**/
void SetFourCC (int fourcc);
int GetFourCC() {return this->m_VideoWriter->GetFourCC();}
/** Set/Get the FpS. 25 by default **/
void SetFpS(double framefrequency);
double GetFpS() {return this->m_VideoWriter->GetFpS();}
//itkGetMacro(FpS,double);
/** Set/Get the input **/
void SetInput(const TInputImage *input);
/** Set the use of openCV (or vxl) **/
/** Attention OpenCV only accepts char (or unsigned char) **/
/** OpenCv by default **/
void UseOpenCV ( bool useOpenCV );
virtual void Update()
{
this->GenerateData();
}
/** Play what is written in the file, very useful for debug **/
void Play();
/** Method for releasing the video. Also called by the destructor **/
void EndVideo();
protected:
void PrintSelf(std::ostream & os, Indent indent) const;
void GenerateData();
VideoFileWriter();
~VideoFileWriter()
{
this->EndVideo();
};
bool m_UseOpenCV;
bool m_WriterCreated;
std::string m_FileName;
typename itk::VideoWriterBase<TInputImage>::Pointer m_VideoWriter;
private:
VideoFileWriter(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
void TransformITKImageToCVImage();
void CreateVideo();
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkVideoFileWriter.txx"
#endif
#endif