ImageD  v2_7_5 (24.06.22)
ImageD is an image processing software designed for rapid prototyping and implementing algorithms and solutions for science, research and teaching.
d_videoslicer.h
Go to the documentation of this file.
1 /************************************
2  * added: ??.??.2019 *
3  * author: David Eilenstein *
4  * contact: D.Eilenstein@gsi.de *
5  * project: ImageD *
6  * facility: GSI Darmstadt, Ger *
7  ************************************/
8 
9 #ifndef D_VIDEOSLICER_H
10 #define D_VIDEOSLICER_H
11 
12 //own
13 #include <d_enum.h>
14 #include <d_stat.h>
15 #include <d_component.h>
16 #include <d_component_list.h>
19 
20 //general
21 #include <iostream>
22 #include <vector>
23 #include <fstream>
24 #include <sstream>
25 #include <iterator>
26 #include <thread>
27 
28 //Qt
29 #include <QObject>
30 #include <QImage>
31 #include <QPainter>
32 #include <QPen>
33 #include <QColor>
34 #include <QFileInfo>
35 #include <QDir>
36 #include <QString>
37 #include <QDebug>
38 
39 //openCV
40 #include <opencv2/core/core.hpp>
41 #include <opencv2/highgui/highgui.hpp>
42 #include <opencv2/imgproc/imgproc.hpp>
43 
44 //namespaces
45 using namespace std;
46 //using namespace cv; (prohibited because of abigous names with qtdatavisualization)
47 #include <d_opencv_typedefs.h>
48 
54 {
55 public:
56  D_VideoSlicer();
57  D_VideoSlicer(string S_VideoPath);
58  D_VideoSlicer(QString QS_VideoPath);
59  D_VideoSlicer(QFileInfo FI_VideoPath);
60 
61  //setter
62  int set_VideoPath(string S_VideoPath);
63  int set_VideoPath(QString QS_VideoPath);
64  int set_VideoPath(QFileInfo FI_VideoPath);
65 
66  //getter: frame
67  bool is_NextFrameExistent();
68  Mat get_FramePos(int frame_number);
69  int get_FramePos(Mat* MA_Frame, int frame_number);
70  Mat get_FrameNext();
71  int get_FrameNext(Mat* MA_Frame);
72 
73  //getter: information
74  double get_FrameRateHz() {return state_FileValid ? prop_Framerate : -1;}
75  double get_FrameRateFps() {return state_FileValid ? prop_Framerate : -1;}
76  double get_FrameRateFpm() {return state_FileValid ? prop_Framerate * 60.0 : -1;}
77  double get_FrameTimeSec() {return state_FileValid ? prop_FrameTime : -1;}
78  double get_FrameTimeMin() {return state_FileValid ? prop_FrameTime / 60.0 : -1;}
79  double get_DurationSec() {return state_FileValid ? prop_Duration : -1;}
80  double get_DurationMin() {return state_FileValid ? prop_Duration / 60.0 : -1;}
81  long int get_FrameCount() {return state_FileValid ? prop_FrameCount : -1;}
82  int get_Width() {return state_FileValid ? prop_Width : -1;}
83  int get_Height() {return state_FileValid ? prop_Height : -1;}
84  Size get_FrameSize() {return state_FileValid ? prop_FrameSize : Size(1, 1);}
85  QString get_Name() {return state_FileValid ? prop_Name : "not_set";}
86  QString get_Suffix() {return state_FileValid ? prop_Suffix : "not_set";}
87  QString get_PathSourceFull() {return state_FileValid ? FI_Source.absoluteFilePath() : "not_set";}
88  double get_timeSec_2_frame() {return state_FileValid ? prop_Framerate : -1;}
89  double get_frame_2_timeSec() {return state_FileValid ? prop_FrameTime : -1;}
90 
91 private:
92 
93  //File to process
94  QFileInfo FI_Source;
95  QDir DIR_Source;
96 
97  //read video
98  VideoCapture VC_Source;
99 
100  //Frame cursor
101  int cursor_FrameCurrent = 0;
102 
103  //File properties
104  double prop_Framerate = 24.0;
105  double prop_FrameTime = 1 / 24.0;
106  long int prop_FrameCount = 1;
107  int prop_Width = 1;
108  int prop_Height = 1;
109  Size prop_FrameSize = Size(1, 1);
110  double prop_Duration = 1 / 24.0;
111  QString prop_Name = "";
112  QString prop_Suffix = "";
113 
114  //States
115  bool state_FileValid = false;
116 };
117 
118 #endif // D_VIDEOSLICER_H
Mat
cv::Mat Mat
Definition: d_opencv_typedefs.h:28
ER_okay
@ ER_okay
Definition: d_enum.h:133
D_VideoSlicer::get_DurationMin
double get_DurationMin()
Definition: d_videoslicer.h:80
CAP_PROP_FRAME_COUNT
const int CAP_PROP_FRAME_COUNT
Definition: d_opencv_typedefs.h:105
CAP_PROP_FRAME_WIDTH
const int CAP_PROP_FRAME_WIDTH
Definition: d_opencv_typedefs.h:103
d_component.h
CAP_PROP_POS_FRAMES
const int CAP_PROP_POS_FRAMES
Definition: d_opencv_typedefs.h:106
CAP_PROP_FPS
const int CAP_PROP_FPS
Definition: d_opencv_typedefs.h:102
d_value_distribution_list.h
D_VideoSlicer::get_FramePos
Mat get_FramePos(int frame_number)
Definition: d_videoslicer.cpp:95
D_VideoSlicer::get_Height
int get_Height()
Definition: d_videoslicer.h:83
D_VideoSlicer
The D_VideoSlicer class Extracts frames from videos as images.
Definition: d_videoslicer.h:54
D_VideoSlicer::set_VideoPath
int set_VideoPath(string S_VideoPath)
Definition: d_videoslicer.cpp:31
D_VideoSlicer::get_Width
int get_Width()
Definition: d_videoslicer.h:82
VideoCapture
cv::VideoCapture VideoCapture
typdef all commonly used OpenCV types
Definition: d_opencv_typedefs.h:24
d_component_list_context.h
D_VideoSlicer::get_FrameRateFps
double get_FrameRateFps()
Definition: d_videoslicer.h:75
D_VideoSlicer::get_FrameRateHz
double get_FrameRateHz()
Definition: d_videoslicer.h:74
D_VideoSlicer::get_FrameTimeSec
double get_FrameTimeSec()
Definition: d_videoslicer.h:77
D_VideoSlicer::is_NextFrameExistent
bool is_NextFrameExistent()
Definition: d_videoslicer.cpp:69
CAP_PROP_FRAME_HEIGHT
const int CAP_PROP_FRAME_HEIGHT
Definition: d_opencv_typedefs.h:104
d_component_list.h
D_VideoSlicer::get_timeSec_2_frame
double get_timeSec_2_frame()
Definition: d_videoslicer.h:88
D_VideoSlicer::get_FrameTimeMin
double get_FrameTimeMin()
Definition: d_videoslicer.h:78
ER_VideoCaptureClosed
@ ER_VideoCaptureClosed
Definition: d_enum.h:166
D_VideoSlicer::get_DurationSec
double get_DurationSec()
Definition: d_videoslicer.h:79
d_videoslicer.h
D_VideoSlicer::get_Suffix
QString get_Suffix()
Definition: d_videoslicer.h:86
d_opencv_typedefs.h
D_VideoSlicer::get_FrameRateFpm
double get_FrameRateFpm()
Definition: d_videoslicer.h:76
D_VideoSlicer::get_frame_2_timeSec
double get_frame_2_timeSec()
Definition: d_videoslicer.h:89
D_VideoSlicer::D_VideoSlicer
D_VideoSlicer()
Definition: d_videoslicer.cpp:11
d_enum.h
D_VideoSlicer::get_PathSourceFull
QString get_PathSourceFull()
Definition: d_videoslicer.h:87
D_VideoSlicer::get_FrameSize
Size get_FrameSize()
Definition: d_videoslicer.h:84
D_VideoSlicer::get_FrameNext
Mat get_FrameNext()
Definition: d_videoslicer.cpp:77
Size
cv::Size Size
Definition: d_opencv_typedefs.h:31
ER_index_out_of_range
@ ER_index_out_of_range
Definition: d_enum.h:146
D_VideoSlicer::get_FrameCount
long int get_FrameCount()
Definition: d_videoslicer.h:81
d_stat.h
D_VideoSlicer::get_Name
QString get_Name()
Definition: d_videoslicer.h:85