proxy bug fixes, add moveobj, sams icons, ladspa fixes, pot sigfpe
[goodguy/history.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 <vector>
32
33 using namespace std;
34 using namespace cv;
35
36 //#define _RANSAC
37 #ifdef _RANSAC
38 #include <opencv2/videostab/motion_core.hpp>
39 #include <opencv2/videostab/global_motion.hpp>
40
41 using namespace videostab;
42 #endif
43
44 class MoveObjConfig
45 {
46 public:
47         MoveObjConfig();
48
49         int equivalent(MoveObjConfig &that);
50         void copy_from(MoveObjConfig &that);
51         void interpolate(MoveObjConfig &prev, MoveObjConfig &next, 
52                 long prev_frame, long next_frame, long current_frame);
53         void limits();
54         int draw_vectors;
55         int do_stabilization;
56         int settling_speed;
57 // percent
58         int block_size;
59         int search_radius;
60 };
61
62 class MoveObj : public PluginVClient
63 {
64 public:
65         MoveObj(PluginServer *server);
66         ~MoveObj();
67 // required for all realtime plugins
68         PLUGIN_CLASS_MEMBERS2(MoveObjConfig)
69         int is_realtime();
70         void update_gui();
71         void save_data(KeyFrame *keyframe);
72         void read_data(KeyFrame *keyframe);
73         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
74         AffineEngine *affine;
75         void to_mat(Mat &mat, int mcols, int mrows,
76                 VFrame *inp, int ix,int iy, BC_CModel mcolor_model);
77
78         long prev_position, next_position;
79
80 //opencv
81         typedef vector<Point2f> ptV;
82
83         BC_CModel cvmodel;
84         Mat accum_matrix;
85         double accum_matrix_mem[9];
86         double x_accum, y_accum, angle_accum;
87         Mat prev_mat, next_mat;
88         ptV *prev_corners, *next_corners;
89 };
90
91 #endif