-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo_handler.h
More file actions
83 lines (61 loc) · 2.07 KB
/
video_handler.h
File metadata and controls
83 lines (61 loc) · 2.07 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
#ifndef VIDEO_HANDLER_H
#define VIDEO_HANDLER_H
#include "all_headers.h"
#include "img_handler.h"
#define MIN_CURSOR_AREA 250//300
#define VIDEO_PATCH "/home/dupeljan/Projects/webinar_analisator/webinar.mp4"
#define PIC_A "/home/dupeljan/Projects/webinar_analisator/web_analis_opencv/slides/6.png"
#define PIC_B "/home/dupeljan/Projects/webinar_analisator/web_analis_opencv/slides/c.png"
#define CURSOR "/home/dupeljan/Projects/webinar_analisator/web_analis_opencv/cursor1.png"
#define SLIDE_PATH "/home/dupeljan/Projects/webinar_analisator/web_analis_opencv/gen_slides_shorter/"
#define FRAME_EACH_MSECOND 50 * 10e3
#define DEBUG_VIDEO 2
using namespace cv;
using namespace std;
struct Diff_dict{
Mat first;
Mat second;
Mat diff;
void operator ()(Rect rect){
first = first(rect);
second = second(rect);
diff = diff(rect);
}
};
class Cursor {
Mat img;
Diff_dict diff;
vector<Rect> b_rects;
VideoCapture cap;
float accuracy = 0.95;
void filter_rects();
void threshold_diff();
void find_bound_rects_diff();
public:
Cursor(VideoCapture cap){this->cap = cap;};
void find_cursor(int hit_lim, int shift);
size_t patch_length(size_t begin_shift, size_t shift);
Mat get(){ return img;}
void set(Mat img){ this->img = img; }
};
class Presentation {
Mat cursor;
Mat cursor_mask;
Mat cursor_covering_mask; // For error reduction
Rect area;
vector<Mat> slides;
void get_cursor_mask(Mat src, Mat& dst);
void shift_video_get_difference_local(VideoCapture cap, int shift, Diff_dict &dst);
public:
Presentation(Mat cursor,Rect area);
void generate(VideoCapture cap, int shift);
void write_slides(string patch);
vector<Mat> get_slides(){ return slides; }
};
int video_main();
size_t get_duradion(VideoCapture src);
VideoWriter get_VideoWriter(VideoCapture cap);
// Return abs_diff form current time + shift img and current time img
// Change VideoCapture posintion
void shift_video_get_difference(VideoCapture src, int shift, Diff_dict &dst);
#endif // VIDEO_HANDLER_H