FindObjectWindow::FindObjectWindow(FindObjectMain *plugin)
- : PluginClientWindow(plugin,
- 300,
- 550,
- 300,
- 550,
- 0)
+ : PluginClientWindow(plugin, 340, 660, 340, 660, 0)
{
this->plugin = plugin;
}
void FindObjectWindow::create_objects()
{
- int x1 = 10, x = 10, y = 10;
- int x2 = 310;
- BC_Title *title;
-
+ int x = 10, y = 10, x1 = x, x2 = get_w()/2;
+ plugin->load_configuration();
- add_subwindow(title = new BC_Title(x1,
- y,
- _("Algorithm:")));
- add_subwindow(algorithm = new FindObjectAlgorithm(plugin,
- this,
- x1 + title->get_w() + 10,
- y));
+ BC_Title *title;
+ add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
+ add_subwindow(algorithm = new FindObjectAlgorithm(plugin, this,
+ x1 + title->get_w() + 10, y));
algorithm->create_objects();
y += algorithm->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(use_flann = new FindObjectUseFlann(plugin, this, x, y));
+ y += use_flann->get_h() + plugin->get_theme()->widget_border + 20;
- add_subwindow(title = new BC_Title(x1,
- y,
- _("Search radius:\n(W/H Percent of image)")));
- add_subwindow(global_range_w = new FindObjectGlobalRange(plugin,
- x1 + title->get_w() + 10,
- y,
- &plugin->config.global_range_w));
- add_subwindow(global_range_h = new FindObjectGlobalRange(plugin,
- x1 + title->get_w() + 10 + global_range_w->get_w(),
- y,
- &plugin->config.global_range_h));
-
- y += 50;
- add_subwindow(title = new BC_Title(x1,
- y,
- _("Object size:\n(W/H Percent of image)")));
- add_subwindow(global_block_w = new FindObjectBlockSize(plugin,
- x1 + title->get_w() + 10,
- y,
- &plugin->config.global_block_w));
- add_subwindow(global_block_h = new FindObjectBlockSize(plugin,
- x1 + title->get_w() + 10 + global_block_w->get_w(),
- y,
- &plugin->config.global_block_h));
-
- y += 40;
- add_subwindow(title = new BC_Title(x, y + 10, _("Block X:")));
- add_subwindow(block_x = new FindObjectBlockCenter(plugin,
- this,
- x + title->get_w() + 10,
- y,
- &plugin->config.block_x));
- add_subwindow(block_x_text = new FindObjectBlockCenterText(plugin,
- this,
- x + title->get_w() + 10 + block_x->get_w() + 10,
- y + 10,
- &plugin->config.block_x));
- block_x->center_text = block_x_text;
- block_x_text->center = block_x;
-
- y += 40;
- add_subwindow(title = new BC_Title(x, y + 10, _("Block Y:")));
- add_subwindow(block_y = new FindObjectBlockCenter(plugin,
- this,
- x + title->get_w() + 10,
- y,
- &plugin->config.block_y));
- add_subwindow(block_y_text = new FindObjectBlockCenterText(plugin,
- this,
- x + title->get_w() + 10 + block_y->get_w() + 10,
- y + 10,
- &plugin->config.block_y));
- block_y->center_text = block_y_text;
- block_y_text->center = block_y;
-
-
- y += 40;
- add_subwindow(draw_keypoints = new FindObjectDrawKeypoints(plugin,
- this,
- x,
- y));
-
- y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
- add_subwindow(draw_border = new FindObjectDrawBorder(plugin,
- this,
- x,
- y));
-
- y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
- add_subwindow(replace_object = new FindObjectReplace(plugin,
- this,
- x,
- y));
-
- y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
- add_subwindow(draw_object_border = new FindObjectDrawObjectBorder(plugin,
- this,
- x,
- y));
-
+ int x0 = x + 200;
+ add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
+ scene_layer = new FindObjectLayer(plugin, this, x0, y,
+ &plugin->config.scene_layer);
+ scene_layer->create_objects();
+ y += scene_layer->get_h() + plugin->get_theme()->widget_border;
- y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
add_subwindow(title = new BC_Title(x, y, _("Object layer:")));
- object_layer = new FindObjectLayer(plugin,
- this,
- x + title->get_w() + 10,
- y,
+ object_layer = new FindObjectLayer(plugin, this, x0, y,
&plugin->config.object_layer);
object_layer->create_objects();
y += object_layer->get_h() + plugin->get_theme()->widget_border;
add_subwindow(title = new BC_Title(x, y, _("Replacement object layer:")));
- replace_layer = new FindObjectLayer(plugin,
- this,
- x + title->get_w() + 10,
- y,
+ replace_layer = new FindObjectLayer(plugin, this, x0, y,
&plugin->config.replace_layer);
replace_layer->create_objects();
- y += replace_layer->get_h() + plugin->get_theme()->widget_border;
+ y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
- add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
- scene_layer = new FindObjectLayer(plugin,
- this,
- x + title->get_w() + 10,
- y,
- &plugin->config.scene_layer);
- scene_layer->create_objects();
- y += scene_layer->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
+ y += title->get_h();
+ int y1 = y;
+ add_subwindow(new BC_Title(x1, y + 10, _("Scene X:")));
+ y += title->get_h() + 15;
+ add_subwindow(scene_x = new FindObjectScanFloat(plugin, this,
+ x1, y, &plugin->config.scene_x));
+ add_subwindow(scene_x_text = new FindObjectScanFloatText(plugin, this,
+ x1 + scene_x->get_w() + 10, y + 10, &plugin->config.scene_x));
+ scene_x->center_text = scene_x_text;
+ scene_x_text->center = scene_x;
- add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:")));
- add_subwindow(blend = new FindObjectBlend(plugin,
- x + title->get_w() + plugin->get_theme()->widget_border,
- y,
- &plugin->config.blend));
- y += blend->get_h();
+ y += 40;
+ add_subwindow(title = new BC_Title(x1, y + 10, _("Scene Y:")));
+ y += title->get_h() + 15;
+ add_subwindow(scene_y = new FindObjectScanFloat(plugin, this,
+ x1, y, &plugin->config.scene_y));
+ add_subwindow(scene_y_text = new FindObjectScanFloatText(plugin, this,
+ x1 + scene_y->get_w() + 10, y + 10, &plugin->config.scene_y));
+ scene_y->center_text = scene_y_text;
+ scene_y_text->center = scene_y;
+ y += 40;
+ add_subwindow(new BC_Title(x1, y + 10, _("Scene W:")));
+ y += title->get_h() + 15;
+ add_subwindow(scene_w = new FindObjectScanFloat(plugin, this,
+ x1, y, &plugin->config.scene_w));
+ add_subwindow(scene_w_text = new FindObjectScanFloatText(plugin, this,
+ x1 + scene_w->get_w() + 10, y + 10, &plugin->config.scene_w));
+ scene_w->center_text = scene_w_text;
+ scene_w_text->center = scene_w;
- add_subwindow(title = new BC_Title(x, y + 10, _("Camshift VMIN:")));
- add_subwindow(vmin = new FindObjectCamParam(plugin,
- x + title->get_w() + plugin->get_theme()->widget_border,
- y,
- &plugin->config.vmin));
- y += vmin->get_h() * 2 / 3;
+ y += 40;
+ add_subwindow(title = new BC_Title(x1, y + 10, _("Scene H:")));
+ y += title->get_h() + 15;
+ add_subwindow(scene_h = new FindObjectScanFloat(plugin, this,
+ x1, y, &plugin->config.scene_h));
+ add_subwindow(scene_h_text = new FindObjectScanFloatText(plugin, this,
+ x1 + scene_h->get_w() + 10, y + 10,
+ &plugin->config.scene_h));
+ scene_h->center_text = scene_h_text;
+ scene_h_text->center = scene_h;
+
+ y = y1;
+ add_subwindow(new BC_Title(x2, y + 10, _("Object X:")));
+ y += title->get_h() + 15;
+ add_subwindow(object_x = new FindObjectScanFloat(plugin, this,
+ x2, y, &plugin->config.object_x));
+ add_subwindow(object_x_text = new FindObjectScanFloatText(plugin, this,
+ x2 + object_x->get_w() + 10, y + 10, &plugin->config.object_x));
+ object_x->center_text = object_x_text;
+ object_x_text->center = object_x;
- add_subwindow(title = new BC_Title(x, y + 10, _("Camshift VMAX:")));
- add_subwindow(vmax = new FindObjectCamParam(plugin,
- x + title->get_w() + vmin->get_w() + plugin->get_theme()->widget_border,
- y,
- &plugin->config.vmax));
- y += vmin->get_h() * 2 / 3;
+ y += 40;
+ add_subwindow(title = new BC_Title(x2, y + 10, _("Object Y:")));
+ y += title->get_h() + 15;
+ add_subwindow(object_y = new FindObjectScanFloat(plugin, this,
+ x2, y, &plugin->config.object_y));
+ add_subwindow(object_y_text = new FindObjectScanFloatText(plugin, this,
+ x2 + object_y->get_w() + 10, y + 10, &plugin->config.object_y));
+ object_y->center_text = object_y_text;
+ object_y_text->center = object_y;
- add_subwindow(title = new BC_Title(x, y + 10, _("Camshift SMIN:")));
- add_subwindow(smin = new FindObjectCamParam(plugin,
- x + title->get_w() + plugin->get_theme()->widget_border,
- y,
- &plugin->config.smin));
- y += vmin->get_h();
+ y += 40;
+ add_subwindow(new BC_Title(x2, y + 10, _("Object W:")));
+ y += title->get_h() + 15;
+ add_subwindow(object_w = new FindObjectScanFloat(plugin, this,
+ x2, y, &plugin->config.object_w));
+ add_subwindow(object_w_text = new FindObjectScanFloatText(plugin, this,
+ x2 + object_w->get_w() + 10, y + 10, &plugin->config.object_w));
+ object_w->center_text = object_w_text;
+ object_w_text->center = object_w;
+ y += 40;
+ add_subwindow(title = new BC_Title(x2, y + 10, _("Object H:")));
+ y += title->get_h() + 15;
+ add_subwindow(object_h = new FindObjectScanFloat(plugin, this,
+ x2, y, &plugin->config.object_h));
+ add_subwindow(object_h_text = new FindObjectScanFloatText(plugin, this,
+ x2 + object_h->get_w() + 10, y + 10,
+ &plugin->config.object_h));
+ object_h->center_text = object_h_text;
+ object_h_text->center = object_h;
+
+ y += 40 + 15;
+ add_subwindow(draw_keypoints = new FindObjectDrawKeypoints(plugin, this, x, y));
+ y += draw_keypoints->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(draw_border = new FindObjectDrawBorder(plugin, this, x, y));
+ y += draw_border->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(replace_object = new FindObjectReplace(plugin, this, x, y));
+ y += replace_object->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(draw_object_border = new FindObjectDrawObjectBorder(plugin, this, x, y));
+ y += draw_object_border->get_h() + plugin->get_theme()->widget_border;
+ add_subwindow(title = new BC_Title(x, y + 10, _("Object blend amount:")));
+ add_subwindow(blend = new FindObjectBlend(plugin,
+ x + title->get_w() + plugin->get_theme()->widget_border, y,
+ &plugin->config.blend));
+ y += blend->get_h();
show_window(1);
}
-
-
-
-
-
-FindObjectGlobalRange::FindObjectGlobalRange(FindObjectMain *plugin,
- int x,
- int y,
- int *value)
- : BC_IPot(x,
- y,
- (int64_t)*value,
- (int64_t)MIN_RADIUS,
- (int64_t)MAX_RADIUS)
-{
- this->plugin = plugin;
- this->value = value;
-}
-
-
-int FindObjectGlobalRange::handle_event()
-{
- *value = (int)get_value();
- plugin->send_configure_change();
- return 1;
-}
-
-
-
-
-
-FindObjectBlockSize::FindObjectBlockSize(FindObjectMain *plugin,
- int x,
- int y,
- float *value)
- : BC_FPot(x,
- y,
- (float)*value,
- (float)MIN_BLOCK,
- (float)MAX_BLOCK)
-{
- this->plugin = plugin;
- this->value = value;
- set_precision(0.1);
-}
-
-
-
-int FindObjectBlockSize::handle_event()
-{
- *value = get_value();
- plugin->send_configure_change();
- return 1;
-}
-
-
-
-
-
-
-
-FindObjectBlockCenter::FindObjectBlockCenter(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y,
- float *value)
- : BC_FPot(x,
- y,
- *value,
- (float)0,
- (float)100)
+FindObjectScanFloat::FindObjectScanFloat(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y, float *value)
+ : BC_FPot(x, y, *value, (float)0, (float)100)
{
this->plugin = plugin;
this->gui = gui;
this->value = value;
+ this->center_text = 0;
set_precision(0.1);
}
-int FindObjectBlockCenter::handle_event()
+int FindObjectScanFloat::handle_event()
{
*value = get_value();
center_text->update(*value);
}
-
-
-
-
-FindObjectBlockCenterText::FindObjectBlockCenterText(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y,
- float *value)
- : BC_TextBox(x,
- y,
- 75,
- 1,
- *value)
+FindObjectScanFloatText::FindObjectScanFloatText(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y, float *value)
+ : BC_TextBox(x, y, 75, 1, *value)
{
this->plugin = plugin;
this->gui = gui;
this->value = value;
+ this->center = 0;
set_precision(1);
}
-int FindObjectBlockCenterText::handle_event()
+int FindObjectScanFloatText::handle_event()
{
*value = atof(get_text());
center->update(*value);
}
-
-
-
-
-
-FindObjectDrawBorder::FindObjectDrawBorder(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y)
- : BC_CheckBox(x,
- y,
- plugin->config.draw_border,
- _("Draw border"))
+FindObjectDrawBorder::FindObjectDrawBorder(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.draw_border, _("Draw border"))
{
this->gui = gui;
this->plugin = plugin;
}
-
-
-
-
-FindObjectDrawKeypoints::FindObjectDrawKeypoints(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y)
- : BC_CheckBox(x,
- y,
- plugin->config.draw_keypoints,
- _("Draw keypoints"))
+FindObjectDrawKeypoints::FindObjectDrawKeypoints(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.draw_keypoints, _("Draw keypoints"))
{
this->gui = gui;
this->plugin = plugin;
}
-
-
-FindObjectReplace::FindObjectReplace(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y)
- : BC_CheckBox(x,
- y,
- plugin->config.replace_object,
- _("Replace object"))
+FindObjectReplace::FindObjectReplace(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.replace_object, _("Replace object"))
{
this->gui = gui;
this->plugin = plugin;
}
-
-
-
-
-FindObjectDrawObjectBorder::FindObjectDrawObjectBorder(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y)
- : BC_CheckBox(x,
- y,
- plugin->config.draw_object_border,
- _("Draw object border"))
+FindObjectDrawObjectBorder::FindObjectDrawObjectBorder(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.draw_object_border, _("Draw object border"))
{
this->gui = gui;
this->plugin = plugin;
}
-
-
-
-
-FindObjectLayer::FindObjectLayer(FindObjectMain *plugin,
- FindObjectWindow *gui,
- int x,
- int y,
- int *value)
- : BC_TumbleTextBox(gui,
- *value,
- MIN_LAYER,
- MAX_LAYER,
- x,
- y,
- calculate_w(gui))
-{
- this->plugin = plugin;
- this->gui = gui;
- this->value = value;
-}
-
-int FindObjectLayer::handle_event()
-{
- *value = atoi(get_text());
- plugin->send_configure_change();
- return 1;
-}
-
-int FindObjectLayer::calculate_w(FindObjectWindow *gui)
-{
- int result = 0;
- result = gui->get_text_width(MEDIUMFONT, "000");
- return result + 50;
-}
-
-
-
-
-
-
-
-
FindObjectAlgorithm::FindObjectAlgorithm(FindObjectMain *plugin, FindObjectWindow *gui, int x, int y)
- : BC_PopupMenu(x,
- y,
- calculate_w(gui),
- to_text(plugin->config.algorithm))
+ : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.algorithm))
{
this->plugin = plugin;
this->gui = gui;
void FindObjectAlgorithm::create_objects()
{
add_item(new BC_MenuItem(to_text(NO_ALGORITHM)));
-#if HAVE_OPENCV_SURF
+#ifdef _SIFT
+ add_item(new BC_MenuItem(to_text(ALGORITHM_SIFT)));
+#endif
+#ifdef _SURF
add_item(new BC_MenuItem(to_text(ALGORITHM_SURF)));
#endif
- add_item(new BC_MenuItem(to_text(ALGORITHM_CAMSHIFT)));
- add_item(new BC_MenuItem(to_text(ALGORITHM_BLOB)));
+#ifdef _ORB
+ add_item(new BC_MenuItem(to_text(ALGORITHM_ORB)));
+#endif
+#ifdef _AKAZE
+ add_item(new BC_MenuItem(to_text(ALGORITHM_AKAZE)));
+#endif
+#ifdef _BRISK
+ add_item(new BC_MenuItem(to_text(ALGORITHM_BRISK)));
+#endif
}
int FindObjectAlgorithm::from_text(char *text)
{
- if(!strcmp(text, _("Don't Calculate"))) return NO_ALGORITHM;
-#if HAVE_OPENCV_SURF
+#ifdef _SIFT
+ if(!strcmp(text, _("SIFT"))) return ALGORITHM_SIFT;
+#endif
+#ifdef _SURF
if(!strcmp(text, _("SURF"))) return ALGORITHM_SURF;
#endif
- if(!strcmp(text, _("CAMSHIFT"))) return ALGORITHM_CAMSHIFT;
- if(!strcmp(text, _("Blob"))) return ALGORITHM_BLOB;
- return ALGORITHM_CAMSHIFT;
+#ifdef _ORB
+ if(!strcmp(text, _("ORB"))) return ALGORITHM_ORB;
+#endif
+#ifdef _AKAZE
+ if(!strcmp(text, _("AKAZE"))) return ALGORITHM_AKAZE;
+#endif
+#ifdef _BRISK
+ if(!strcmp(text, _("BRISK"))) return ALGORITHM_BRISK;
+#endif
+ return NO_ALGORITHM;
}
char* FindObjectAlgorithm::to_text(int mode)
{
- switch(mode)
- {
- case NO_ALGORITHM:
- return _("Don't Calculate");
-#if HAVE_OPENCV_SURF
- case ALGORITHM_SURF:
- return _("SURF");
+ switch( mode ) {
+#ifdef _SIFT
+ case ALGORITHM_SIFT: return _("SIFT");
+#endif
+#ifdef _SURF
+ case ALGORITHM_SURF: return _("SURF");
+#endif
+#ifdef _ORB
+ case ALGORITHM_ORB: return _("ORB");
+#endif
+#ifdef _AKAZE
+ case ALGORITHM_AKAZE: return _("AKAZE");
+#endif
+#ifdef _BRISK
+ case ALGORITHM_BRISK: return _("BRISK");
#endif
- case ALGORITHM_BLOB:
- return _("Blob");
- case ALGORITHM_CAMSHIFT:
- break;
}
- return _("CAMSHIFT");
+ return _("Don't Calculate");
}
int FindObjectAlgorithm::calculate_w(FindObjectWindow *gui)
{
int result = 0;
result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(NO_ALGORITHM)));
-#if HAVE_OPENCV_SURF
+#ifdef _SIFT
+ result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SIFT)));
+#endif
+#ifdef _SURF
result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_SURF)));
#endif
- result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_CAMSHIFT)));
- result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BLOB)));
+#ifdef _ORB
+ result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_ORB)));
+#endif
+#ifdef _AKAZE
+ result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_AKAZE)));
+#endif
+#ifdef _BRISK
+ result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(ALGORITHM_BRISK)));
+#endif
return result + 50;
}
+FindObjectUseFlann::FindObjectUseFlann(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.use_flann, _("Use FLANN"))
+{
+ this->gui = gui;
+ this->plugin = plugin;
+}
+int FindObjectUseFlann::handle_event()
+{
+ plugin->config.use_flann = get_value();
+ plugin->send_configure_change();
+ return 1;
+}
-
-
-
-FindObjectCamParam::FindObjectCamParam(FindObjectMain *plugin,
- int x,
- int y,
- int *value)
- : BC_IPot(x,
- y,
- (int64_t)*value,
- (int64_t)MIN_CAMSHIFT,
- (int64_t)MAX_CAMSHIFT)
+FindObjectLayer::FindObjectLayer(FindObjectMain *plugin, FindObjectWindow *gui,
+ int x, int y, int *value)
+ : BC_TumbleTextBox(gui, *value, MIN_LAYER, MAX_LAYER, x, y, calculate_w(gui))
{
this->plugin = plugin;
+ this->gui = gui;
this->value = value;
}
-
-int FindObjectCamParam::handle_event()
+int FindObjectLayer::handle_event()
{
- *value = (int)get_value();
+ *value = atoi(get_text());
plugin->send_configure_change();
return 1;
}
-
-
-
-
-
+int FindObjectLayer::calculate_w(FindObjectWindow *gui)
+{
+ int result = 0;
+ result = gui->get_text_width(MEDIUMFONT, "000");
+ return result + 50;
+}
FindObjectBlend::FindObjectBlend(FindObjectMain *plugin,
this->value = value;
}
-
int FindObjectBlend::handle_event()
{
*value = (int)get_value();
return 1;
}
-
-
-
-
-
-
-
-
-
-
-
-