3 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
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.
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.
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
23 #include "pluginvclient.h"
24 #include "loadbalance.h"
25 #include "overlayframe.h"
27 #include "opencv2/core/types.hpp"
28 #include "opencv2/core/mat.hpp"
29 #include "opencv2/calib3d.hpp"
30 #include "opencv2/video/video.hpp"
39 #include <opencv2/videostab/motion_core.hpp>
40 #include <opencv2/videostab/global_motion.hpp>
42 using namespace videostab;
46 class FlowObjRemapPackage;
47 class FlowObjRemapEngine;
48 class FlowObjRemapUnit;
57 int equivalent(FlowObjConfig &that);
58 void copy_from(FlowObjConfig &that);
59 void interpolate(FlowObjConfig &prev, FlowObjConfig &next,
60 long prev_frame, long next_frame, long current_frame);
70 class FlowObjRemapPackage : public LoadPackage
73 FlowObjRemapPackage();
78 class FlowObjRemapEngine : public LoadServer
81 FlowObjRemapEngine(FlowObj *plugin, int cpus);
82 ~FlowObjRemapEngine();
85 LoadClient* new_client();
86 LoadPackage* new_package();
91 class FlowObjRemapUnit : public LoadClient
94 FlowObjRemapUnit(FlowObjRemapEngine *engine, FlowObj *plugin);
97 void process_package(LoadPackage *pkg);
98 void process_remap(FlowObjRemapPackage *pkg);
100 FlowObjRemapEngine *engine;
104 class FlowObj : public PluginVClient
107 FlowObj(PluginServer *server);
109 // required for all realtime plugins
110 PLUGIN_CLASS_MEMBERS2(FlowObjConfig)
113 void save_data(KeyFrame *keyframe);
114 void read_data(KeyFrame *keyframe);
115 int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
116 void to_mat(Mat &mat, int mcols, int mrows,
117 VFrame *inp, int ix,int iy, int mcolor_model);
118 void from_mat(VFrame *out, int ox, int oy, int ow, int oh,
119 Mat &mat, int mcolor_model);
121 long prev_position, next_position;
122 int width, height, color_model;
123 VFrame *input, *output, *accum;
126 FlowObjRemapEngine *flow_engine;
127 OverlayFrame *overlay;
130 typedef vector<Point2f> ptV;
134 double accum_matrix_mem[9];
135 double x_accum, y_accum, angle_accum;
136 Mat prev_mat, next_mat;
137 ptV *prev_corners, *next_corners;