00001 #ifndef CHROMAKEY_H
00002 #define CHROMAKEY_H
00003
00004
00005
00006
00007 #include "colorpicker.h"
00008 #include "guicast.h"
00009 #include "loadbalance.h"
00010 #include "pluginvclient.h"
00011
00012
00013 class ChromaKeyHSV;
00014 class ChromaKeyHSV;
00015 class ChromaKeyWindow;
00016
00017 enum {
00018 CHROMAKEY_POSTPROCESS_NONE,
00019 CHROMAKEY_POSTPROCESS_BLUR,
00020 CHROMAKEY_POSTPROCESS_DILATE
00021 };
00022
00023 class ChromaKeyConfig
00024 {
00025 public:
00026 ChromaKeyConfig();
00027
00028 void copy_from(ChromaKeyConfig &src);
00029 int equivalent(ChromaKeyConfig &src);
00030 void interpolate(ChromaKeyConfig &prev,
00031 ChromaKeyConfig &next,
00032 int64_t prev_frame,
00033 int64_t next_frame,
00034 int64_t current_frame);
00035 int get_color();
00036
00037
00038 bool show_mask;
00039
00040 float red;
00041 float green;
00042 float blue;
00043
00044 float min_brightness;
00045 float max_brightness;
00046 float saturation;
00047 float min_saturation;
00048 float tolerance;
00049
00050 float in_slope;
00051 float out_slope;
00052 float alpha_offset;
00053
00054 float spill_threshold;
00055 float spill_amount;
00056 };
00057
00058 class ChromaKeyColor : public BC_GenericButton
00059 {
00060 public:
00061 ChromaKeyColor(ChromaKeyHSV *plugin,
00062 ChromaKeyWindow *gui,
00063 int x,
00064 int y);
00065
00066 int handle_event();
00067
00068 ChromaKeyHSV *plugin;
00069 ChromaKeyWindow *gui;
00070 };
00071
00072
00073 class ChromaKeyMinBrightness : public BC_FSlider
00074 {
00075 public:
00076 ChromaKeyMinBrightness(ChromaKeyHSV *plugin, int x, int y);
00077 int handle_event();
00078 ChromaKeyHSV *plugin;
00079 };
00080
00081 class ChromaKeyMaxBrightness : public BC_FSlider
00082 {
00083 public:
00084 ChromaKeyMaxBrightness(ChromaKeyHSV *plugin, int x, int y);
00085 int handle_event();
00086 ChromaKeyHSV *plugin;
00087 };
00088
00089 class ChromaKeySaturation : public BC_FSlider
00090 {
00091 public:
00092 ChromaKeySaturation(ChromaKeyHSV *plugin, int x, int y);
00093 int handle_event();
00094 ChromaKeyHSV *plugin;
00095 };
00096
00097 class ChromaKeyMinSaturation : public BC_FSlider
00098 {
00099 public:
00100 ChromaKeyMinSaturation(ChromaKeyHSV *plugin, int x, int y);
00101 int handle_event();
00102 ChromaKeyHSV *plugin;
00103 };
00104
00105
00106
00107 class ChromaKeyTolerance : public BC_FSlider
00108 {
00109 public:
00110 ChromaKeyTolerance(ChromaKeyHSV *plugin, int x, int y);
00111 int handle_event();
00112 ChromaKeyHSV *plugin;
00113 };
00114
00115 class ChromaKeyInSlope : public BC_FSlider
00116 {
00117 public:
00118 ChromaKeyInSlope(ChromaKeyHSV *plugin, int x, int y);
00119 int handle_event();
00120 ChromaKeyHSV *plugin;
00121 };
00122
00123 class ChromaKeyOutSlope : public BC_FSlider
00124 {
00125 public:
00126 ChromaKeyOutSlope(ChromaKeyHSV *plugin, int x, int y);
00127 int handle_event();
00128 ChromaKeyHSV *plugin;
00129 };
00130
00131 class ChromaKeyAlphaOffset : public BC_FSlider
00132 {
00133 public:
00134 ChromaKeyAlphaOffset(ChromaKeyHSV *plugin, int x, int y);
00135 int handle_event();
00136 ChromaKeyHSV *plugin;
00137 };
00138
00139 class ChromaKeySpillThreshold : public BC_FSlider
00140 {
00141 public:
00142 ChromaKeySpillThreshold(ChromaKeyHSV *plugin, int x, int y);
00143 int handle_event();
00144 ChromaKeyHSV *plugin;
00145 };
00146 class ChromaKeySpillAmount : public BC_FSlider
00147 {
00148 public:
00149 ChromaKeySpillAmount(ChromaKeyHSV *plugin, int x, int y);
00150 int handle_event();
00151 ChromaKeyHSV *plugin;
00152 };
00153
00154 class ChromaKeyUseColorPicker : public BC_GenericButton
00155 {
00156 public:
00157 ChromaKeyUseColorPicker(ChromaKeyHSV *plugin, ChromaKeyWindow *gui, int x, int y);
00158 int handle_event();
00159 ChromaKeyHSV *plugin;
00160 ChromaKeyWindow *gui;
00161 };
00162
00163
00164 class ChromaKeyColorThread : public ColorThread
00165 {
00166 public:
00167 ChromaKeyColorThread(ChromaKeyHSV *plugin, ChromaKeyWindow *gui);
00168 int handle_new_color(int output, int alpha);
00169 ChromaKeyHSV *plugin;
00170 ChromaKeyWindow *gui;
00171 };
00172
00173 class ChromaKeyShowMask : public BC_CheckBox
00174 {
00175 public:
00176 ChromaKeyShowMask(ChromaKeyHSV *plugin, int x, int y);
00177 int handle_event();
00178 ChromaKeyHSV *plugin;
00179 };
00180
00181
00182
00183 class ChromaKeyWindow : public BC_Window
00184 {
00185 public:
00186 ChromaKeyWindow(ChromaKeyHSV *plugin, int x, int y);
00187 ~ChromaKeyWindow();
00188
00189 void create_objects();
00190 int close_event();
00191 void update_sample();
00192
00193 ChromaKeyColor *color;
00194 ChromaKeyUseColorPicker *use_colorpicker;
00195 ChromaKeyMinBrightness *min_brightness;
00196 ChromaKeyMaxBrightness *max_brightness;
00197 ChromaKeySaturation *saturation;
00198 ChromaKeyMinSaturation *min_saturation;
00199 ChromaKeyTolerance *tolerance;
00200 ChromaKeyInSlope *in_slope;
00201 ChromaKeyOutSlope *out_slope;
00202 ChromaKeyAlphaOffset *alpha_offset;
00203 ChromaKeySpillThreshold *spill_threshold;
00204 ChromaKeySpillAmount *spill_amount;
00205 ChromaKeyShowMask *show_mask;
00206 BC_SubWindow *sample;
00207 ChromaKeyHSV *plugin;
00208 ChromaKeyColorThread *color_thread;
00209 };
00210
00211
00212
00213
00214
00215 PLUGIN_THREAD_HEADER(ChromaKeyHSV, ChromaKeyThread, ChromaKeyWindow)
00216
00217
00218 class ChromaKeyServer : public LoadServer
00219 {
00220 public:
00221 ChromaKeyServer(ChromaKeyHSV *plugin);
00222 void init_packages();
00223 LoadClient* new_client();
00224 LoadPackage* new_package();
00225 ChromaKeyHSV *plugin;
00226 };
00227
00228 class ChromaKeyPackage : public LoadPackage
00229 {
00230 public:
00231 ChromaKeyPackage();
00232 int y1, y2;
00233 };
00234
00235 class ChromaKeyUnit : public LoadClient
00236 {
00237 public:
00238 ChromaKeyUnit(ChromaKeyHSV *plugin, ChromaKeyServer *server);
00239 void process_package(LoadPackage *package);
00240 template <typename component_type> void process_chromakey(int components, component_type max, bool use_yuv, ChromaKeyPackage *pkg);
00241 bool is_same_color(float r, float g, float b, float rk,float bk,float gk, float color_threshold, float light_threshold, int key_main_component);
00242
00243 ChromaKeyHSV *plugin;
00244
00245 };
00246
00247
00248
00249
00250 class ChromaKeyHSV : public PluginVClient
00251 {
00252 public:
00253 ChromaKeyHSV(PluginServer *server);
00254 ~ChromaKeyHSV();
00255
00256 int process_buffer(VFrame *frame,
00257 int64_t start_position,
00258 double frame_rate);
00259 int handle_opengl();
00260 int is_realtime();
00261 char* plugin_title();
00262 VFrame* new_picon();
00263 int load_configuration();
00264 int load_defaults();
00265 int save_defaults();
00266 void save_data(KeyFrame *keyframe);
00267 void read_data(KeyFrame *keyframe);
00268 int show_gui();
00269 int set_string();
00270 void raise_window();
00271 void update_gui();
00272
00273 ChromaKeyConfig config;
00274 VFrame *input, *output;
00275 ChromaKeyServer *engine;
00276 ChromaKeyThread *thread;
00277 BC_Hash *defaults;
00278 };
00279
00280
00281
00282
00283
00284
00285
00286
00287 #endif
00288
00289
00290
00291
00292
00293
00294