no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / moveobj / moveobj.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef MOVEOBJ_H
21 #define MOVEOBJ_H
22
23 #include "affine.inc"
24 #include "pluginvclient.h"
25
26 #include "opencv2/core/types.hpp"
27 #include "opencv2/core/mat.hpp"
28 #include "opencv2/calib3d.hpp"
29 #include "opencv2/video/video.hpp"
30
31 #include "opencv2/core/types_c.h"
32 #include <opencv2/calib3d/calib3d_c.h>
33
34 #include <vector>
35
36 using namespace std;
37 using namespace cv;
38
39 //#define _RANSAC
40 #ifdef _RANSAC
41 #include <opencv2/videostab/motion_core.hpp>
42 #include <opencv2/videostab/global_motion.hpp>
43
44 using namespace videostab;
45 #endif
46
47 class MoveObjConfig
48 {
49 public:
50         MoveObjConfig();
51
52         int equivalent(MoveObjConfig &that);
53         void copy_from(MoveObjConfig &that);
54         void interpolate(MoveObjConfig &prev, MoveObjConfig &next, 
55                 long prev_frame, long next_frame, long current_frame);
56         void limits();
57         int draw_vectors;
58         int do_stabilization;
59         int settling_speed;
60 // percent
61         int block_size;
62         int search_radius;
63 };
64
65 class MoveObj : public PluginVClient
66 {
67 public:
68         MoveObj(PluginServer *server);
69         ~MoveObj();
70 // required for all realtime plugins
71         PLUGIN_CLASS_MEMBERS2(MoveObjConfig)
72         int is_realtime();
73         void update_gui();
74         void save_data(KeyFrame *keyframe);
75         void read_data(KeyFrame *keyframe);
76         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
77         AffineEngine *affine;
78         void to_mat(Mat &mat, int mcols, int mrows,
79                 VFrame *inp, int ix,int iy, int mcolor_model);
80
81         long prev_position, next_position;
82
83 //opencv
84         typedef vector<Point2f> ptV;
85
86         BC_CModel cvmodel;
87         Mat accum_matrix;
88         double accum_matrix_mem[9];
89         double x_accum, y_accum, angle_accum;
90         Mat prev_mat, next_mat;
91         ptV *prev_corners, *next_corners;
92 };
93
94 #endif