|
@@ -12,6 +12,8 @@
|
|
|
#include "ImageLabeler.h"
|
|
|
#include "functions.h"
|
|
|
|
|
|
+#include "ui_ImageLabeler.h"
|
|
|
+
|
|
|
#include <QApplication>
|
|
|
#include <QFrame>
|
|
|
#include <QMenuBar>
|
|
@@ -50,10 +52,11 @@
|
|
|
* A constructor is responsible for allocating memory for all the
|
|
|
* GUI objects, arranging and connecting them in the right order.
|
|
|
*/
|
|
|
-ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
- QMainWindow(aParent)
|
|
|
+ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath)
|
|
|
+ : QMainWindow( aParent)
|
|
|
{
|
|
|
- setFocusPolicy(Qt::StrongFocus);
|
|
|
+
|
|
|
+ this->setupUi( this );
|
|
|
|
|
|
/*
|
|
|
* Variables
|
|
@@ -71,135 +74,11 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
interrupt_search_ = 0;
|
|
|
unsaved_data_ = 0;
|
|
|
|
|
|
- /*
|
|
|
- * menu bar part begins
|
|
|
- */
|
|
|
-
|
|
|
- menu_bar_ = new QMenuBar(this);
|
|
|
- setMenuBar(menu_bar_);
|
|
|
-
|
|
|
- menu_file_ = new QMenu(menu_bar_);
|
|
|
- menu_file_->setTitle(tr("&File"));
|
|
|
-
|
|
|
- menu_save_ = new QMenu(menu_bar_);
|
|
|
- menu_save_->setTitle(tr("&Save"));
|
|
|
- menu_load_ = new QMenu(menu_bar_);
|
|
|
- menu_load_->setTitle(tr("&Load"));
|
|
|
-
|
|
|
- menu_pascal_ = new QMenu(menu_bar_);
|
|
|
- menu_pascal_->setTitle(tr("&Pascal"));
|
|
|
- menu_view_ = new QMenu(menu_bar_);
|
|
|
- menu_view_->setTitle(tr("&View"));
|
|
|
- menu_edit_ = new QMenu(menu_bar_);
|
|
|
- menu_edit_->setTitle(tr("&Edit"));
|
|
|
- menu_help_ = new QMenu(menu_bar_);
|
|
|
- menu_help_->setTitle(tr("&Help"));
|
|
|
-
|
|
|
- /* menu file */
|
|
|
- action_open_image_ = new QAction(this);
|
|
|
- action_open_image_->setText(tr("&Load image"));
|
|
|
- action_open_images_ = new QAction(this);
|
|
|
- action_open_images_->setText(tr("&Load images (recursively)"));
|
|
|
- action_open_labeled_image_ = new QAction(this);
|
|
|
- action_open_labeled_image_->setText(tr("&Load labeled image"));
|
|
|
- action_load_legend_ = new QAction(this);
|
|
|
- action_load_legend_->setText(tr("&Load legend"));
|
|
|
- action_save_all_ = new QAction(this);
|
|
|
- action_save_all_->setText(tr("&Save all info"));
|
|
|
- action_save_all_->setEnabled(false);
|
|
|
- action_save_segmented_ = new QAction(this);
|
|
|
- action_save_segmented_->setText(tr("Save segmented &picture"));
|
|
|
- action_save_segmented_->setEnabled(false);
|
|
|
- action_save_legend_ = new QAction(this);
|
|
|
- action_save_legend_->setText(tr("Save &legend"));
|
|
|
- action_save_legend_->setEnabled(false);
|
|
|
- action_quit_ = new QAction(this);
|
|
|
- action_quit_->setText(tr("&Quit"));
|
|
|
- /* menu pascal */
|
|
|
- action_load_pascal_file_ = new QAction(this);
|
|
|
- action_load_pascal_file_->setText(tr("&Load pascal file"));
|
|
|
- action_load_pascal_poly_ = new QAction(this);
|
|
|
- action_load_pascal_poly_->setText(tr("&Load poly info"));
|
|
|
- /* menu view */
|
|
|
- action_view_normal_ = new QAction(this);
|
|
|
- action_view_normal_->setText(tr("&Normal"));
|
|
|
- action_view_normal_->setEnabled(false);
|
|
|
- action_view_segmented_ = new QAction(this);
|
|
|
- action_view_segmented_->setText(tr("&Segmented"));
|
|
|
- action_view_segmented_->setEnabled(false);
|
|
|
- /* menu edit */
|
|
|
- action_undo_ = new QAction(this);
|
|
|
- action_undo_->setText(tr("&Undo"));
|
|
|
- action_undo_->setEnabled(false);
|
|
|
- action_redo_ = new QAction(this);
|
|
|
- action_redo_->setText(tr("&Redo"));
|
|
|
- action_redo_->setEnabled(false);
|
|
|
- action_bound_box_tool_ = new QAction(this);
|
|
|
- action_bound_box_tool_->setText(tr("Bounding box tool"));
|
|
|
- action_bound_box_tool_->setEnabled(false);
|
|
|
- action_polygon_tool_ = new QAction(this);
|
|
|
- action_polygon_tool_->setText(tr("&Polygon tool"));
|
|
|
- action_polygon_tool_->setEnabled(false);
|
|
|
- action_tagging_tool_ = new QAction(this);
|
|
|
- action_tagging_tool_->setText(tr("&Tagging tool"));
|
|
|
- action_tagging_tool_->setEnabled(false);
|
|
|
- action_add_description_ = new QAction(this);
|
|
|
- action_add_description_->setText(tr("&Add image description"));
|
|
|
- action_add_description_->setEnabled(false);
|
|
|
- action_options_ = new QAction(this);
|
|
|
- action_options_->setText(tr("&Options"));
|
|
|
- /* menu help */
|
|
|
- action_help_content_ = new QAction(this);
|
|
|
- action_help_content_->setText(tr("&Help content"));
|
|
|
- action_help_content_->setEnabled(false);
|
|
|
- action_about_ = new QAction(this);
|
|
|
- action_about_->setText(tr("&About"));
|
|
|
- action_about_->setEnabled(false);
|
|
|
- /* ------------------ */
|
|
|
-
|
|
|
- menu_load_->addAction(action_open_image_);
|
|
|
- menu_load_->addAction(action_open_images_);
|
|
|
- menu_load_->addAction(action_open_labeled_image_);
|
|
|
- menu_load_->addAction(action_load_legend_);
|
|
|
- menu_save_->addAction(action_save_segmented_);
|
|
|
- menu_save_->addAction(action_save_legend_);
|
|
|
- menu_save_->addAction(action_save_all_);
|
|
|
- menu_file_->addAction(menu_load_->menuAction());
|
|
|
- menu_file_->addAction(menu_save_->menuAction());
|
|
|
- menu_file_->addAction(menu_pascal_->menuAction());
|
|
|
- //menu_file_->addSeparator();
|
|
|
-
|
|
|
- menu_file_->addSeparator();
|
|
|
- menu_file_->addAction(action_quit_);
|
|
|
-
|
|
|
- menu_pascal_->addAction(action_load_pascal_file_);
|
|
|
- menu_pascal_->addAction(action_load_pascal_poly_);
|
|
|
-
|
|
|
- menu_view_->addAction(action_view_normal_);
|
|
|
- menu_view_->addAction(action_view_segmented_);
|
|
|
-
|
|
|
- menu_edit_->addAction(action_undo_);
|
|
|
- menu_edit_->addAction(action_redo_);
|
|
|
- menu_edit_->addSeparator();
|
|
|
- menu_edit_->addAction(action_bound_box_tool_);
|
|
|
- menu_edit_->addAction(action_polygon_tool_);
|
|
|
- menu_edit_->addAction(action_tagging_tool_);
|
|
|
- menu_edit_->addSeparator();
|
|
|
- menu_edit_->addAction(action_add_description_);
|
|
|
- menu_edit_->addAction(action_options_);
|
|
|
-
|
|
|
- menu_help_->addAction(action_help_content_);
|
|
|
- menu_help_->addAction(action_about_);
|
|
|
-
|
|
|
- menu_bar_->addAction(menu_file_->menuAction());
|
|
|
- menu_bar_->addAction(menu_view_->menuAction());
|
|
|
- menu_bar_->addAction(menu_edit_->menuAction());
|
|
|
- menu_bar_->addAction(menu_help_->menuAction());
|
|
|
|
|
|
/*
|
|
|
* popup menu part begins
|
|
|
*/
|
|
|
- popup_area_list_ = new QMenu;
|
|
|
+ popup_area_list_ = new QMenu(this);
|
|
|
|
|
|
action_delete_area_ = new QAction(this);
|
|
|
action_delete_area_->setText(tr("&Delete area"));
|
|
@@ -209,7 +88,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
popup_area_list_->addAction(action_delete_area_);
|
|
|
popup_area_list_->addAction(action_edit_area_);
|
|
|
|
|
|
- popup_label_list_ = new QMenu;
|
|
|
+ popup_label_list_ = new QMenu(this);
|
|
|
|
|
|
action_set_color_ = new QAction(this);
|
|
|
action_set_color_->setText(tr("Set &color"));
|
|
@@ -222,7 +101,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
popup_label_list_->addAction(action_toggle_priority_);
|
|
|
popup_label_list_->addAction(action_delete_label_);
|
|
|
|
|
|
- popup_images_list_ = new QMenu;
|
|
|
+ popup_images_list_ = new QMenu(this);
|
|
|
|
|
|
action_remove_image_ = new QAction(this);
|
|
|
action_remove_image_->setText(tr("&remove image"));
|
|
@@ -232,31 +111,12 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
/*
|
|
|
* widgets part begins
|
|
|
*/
|
|
|
- central_widget_ = new QWidget(this);
|
|
|
- setCentralWidget(central_widget_);
|
|
|
-
|
|
|
- frame_toolbox_ = new QFrame(central_widget_);
|
|
|
- frame_toolbox_->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
|
|
|
- frame_toolbox_->setLineWidth(0);
|
|
|
- frame_toolbox_->setMidLineWidth(0);
|
|
|
- frame_center_ = new QFrame(central_widget_);
|
|
|
- frame_image_ = new QScrollArea(frame_center_);
|
|
|
- frame_image_->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
|
|
|
- frame_image_->setLineWidth(0);
|
|
|
- frame_image_->setMidLineWidth(0);
|
|
|
- frame_image_->setWidgetResizable(false);
|
|
|
- frame_image_->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
|
|
- frame_image_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
- frame_labelbox_ = new QFrame(central_widget_);
|
|
|
- frame_labelbox_->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
|
|
|
- frame_labelbox_->setLineWidth(0);
|
|
|
- frame_labelbox_->setMidLineWidth(0);
|
|
|
|
|
|
/* just dummy */
|
|
|
image_ = new QPixmap(500, 500);
|
|
|
image_->fill(QColor(Qt::white));
|
|
|
|
|
|
- image_holder_ = new ImageHolder;
|
|
|
+ image_holder_ = new ImageHolder( frame_image_ );
|
|
|
image_holder_->setPixmap(*image_);
|
|
|
image_holder_->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
|
|
image_holder_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
@@ -267,163 +127,8 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
|
|
|
frame_image_->setWidget(image_holder_);
|
|
|
|
|
|
- list_label_ = new QListWidget(central_widget_);
|
|
|
- list_label_->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
- list_areas_ = new QListWidget(central_widget_);
|
|
|
- list_areas_->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
- list_images_widget_ = new QListWidget(central_widget_);
|
|
|
- list_images_widget_->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
-
|
|
|
- label_toolbox_ = new QLabel(tr("Tool box"), frame_toolbox_);
|
|
|
- label_list_label_ = new QLabel(tr("Object labels:"), central_widget_);
|
|
|
- label_list_areas_ = new QLabel(tr("Selected areas:"), central_widget_);
|
|
|
- label_list_images_ = new QLabel(tr("Loaded images:"), central_widget_);
|
|
|
-
|
|
|
- /* buttons */
|
|
|
- button_bound_box_tool_ = new QPushButton(frame_toolbox_);
|
|
|
- button_bound_box_tool_->setText(tr("bbox"));
|
|
|
- button_bound_box_tool_->setEnabled(false);
|
|
|
- button_bound_box_tool_->setCheckable(true);
|
|
|
- button_polygon_tool_ = new QPushButton(frame_toolbox_);
|
|
|
- button_polygon_tool_->setText(tr("poly tool"));
|
|
|
- button_polygon_tool_->setEnabled(false);
|
|
|
- button_polygon_tool_->setCheckable(true);
|
|
|
- button_tagging_tool_ = new QPushButton(frame_toolbox_);
|
|
|
- button_tagging_tool_->setText(tr("tagging"));
|
|
|
- button_tagging_tool_->setEnabled(false);
|
|
|
- button_clear_selection_tool_ = new QPushButton(frame_toolbox_);
|
|
|
- button_clear_selection_tool_->setText(tr("clear selection"));
|
|
|
- button_clear_selection_tool_->setEnabled(false);
|
|
|
- button_generate_colors_ = new QPushButton(frame_toolbox_);
|
|
|
- button_generate_colors_->setText(tr("generate label colors"));
|
|
|
- button_generate_colors_->setEnabled(false);
|
|
|
- button_delete_all_labels_ = new QPushButton(frame_toolbox_);
|
|
|
- button_delete_all_labels_->setText(tr("delete all labels"));
|
|
|
- button_delete_all_labels_->setEnabled(false);
|
|
|
-
|
|
|
- group_tools_ = new QButtonGroup;
|
|
|
- group_tools_->addButton(button_bound_box_tool_);
|
|
|
- group_tools_->addButton(button_polygon_tool_);
|
|
|
-
|
|
|
- button_confirm_selection_ = new QPushButton(central_widget_);
|
|
|
- button_confirm_selection_->setText(tr("Confirm selection"));
|
|
|
- button_confirm_selection_->setEnabled(false);
|
|
|
-
|
|
|
- button_add_label_ = new QPushButton(frame_labelbox_);
|
|
|
- button_add_label_->setText(tr("Add label"));
|
|
|
- button_add_label_->setEnabled(false);
|
|
|
- button_remove_label_ = new QPushButton(frame_labelbox_);
|
|
|
- button_remove_label_->setText(tr("Remove label"));
|
|
|
- button_remove_label_->setEnabled(false);
|
|
|
-
|
|
|
- button_delete_area_ = new QPushButton(frame_labelbox_);
|
|
|
- button_delete_area_->setText(tr("Delete area"));
|
|
|
- button_delete_area_->setEnabled(false);
|
|
|
- button_change_area_ = new QPushButton(frame_labelbox_);
|
|
|
- button_change_area_->setText(tr("Change area"));
|
|
|
- button_change_area_->setEnabled(false);
|
|
|
- button_change_area_text_ = new QPushButton(frame_labelbox_);
|
|
|
- button_change_area_text_->setText(tr("Change area text"));
|
|
|
- button_change_area_text_->setEnabled(false);
|
|
|
-
|
|
|
- button_add_image_ = new QPushButton(frame_toolbox_);
|
|
|
- button_add_image_->setText(tr("Add"));
|
|
|
- button_remove_image_ = new QPushButton(frame_toolbox_);
|
|
|
- button_remove_image_->setText(tr("Remove"));
|
|
|
- button_remove_image_->setEnabled(false);
|
|
|
-
|
|
|
- button_prev_image_ = new QPushButton(central_widget_);
|
|
|
- button_prev_image_->setText("←");
|
|
|
- button_prev_image_->setAutoRepeat(true);
|
|
|
-
|
|
|
- button_next_image_ = new QPushButton(central_widget_);
|
|
|
- button_next_image_->setText("→");
|
|
|
- button_next_image_->setAutoRepeat(true);
|
|
|
-
|
|
|
- /*
|
|
|
- * layouts part begins
|
|
|
- */
|
|
|
- layout_main_ = new QHBoxLayout(central_widget_);
|
|
|
- layout_left_ = new QVBoxLayout();
|
|
|
- layout_toolbox_ = new QVBoxLayout();
|
|
|
- layout_imagelist_buttons_ = new QHBoxLayout();
|
|
|
- layout_center_ = new QVBoxLayout();
|
|
|
- layout_frame_image_ = new QVBoxLayout();
|
|
|
- layout_image_widget_ = new QGridLayout();
|
|
|
- layout_center_buttons_ = new QHBoxLayout();
|
|
|
- layout_right_ = new QVBoxLayout();
|
|
|
- layout_labelbox_ = new QVBoxLayout();
|
|
|
- layout_labelbox_buttons_ = new QHBoxLayout();
|
|
|
- layout_areabox_buttons_ = new QVBoxLayout();
|
|
|
-
|
|
|
- layout_main_->addLayout(layout_left_);
|
|
|
- layout_main_->addLayout(layout_center_);
|
|
|
- layout_main_->addLayout(layout_right_);
|
|
|
-
|
|
|
- /* making the center part stretchable */
|
|
|
- layout_main_->setStretch(1, 1);
|
|
|
-
|
|
|
- /* left part */
|
|
|
- layout_left_->addWidget(frame_toolbox_);
|
|
|
- frame_toolbox_->setLayout(layout_toolbox_);
|
|
|
-
|
|
|
- layout_toolbox_->addWidget(label_toolbox_);
|
|
|
- layout_toolbox_->addWidget(button_bound_box_tool_);
|
|
|
- layout_toolbox_->addWidget(button_polygon_tool_);
|
|
|
- layout_toolbox_->addSpacing(10);
|
|
|
- layout_toolbox_->addWidget(button_tagging_tool_);
|
|
|
- layout_toolbox_->addSpacing(10);
|
|
|
- layout_toolbox_->addWidget(button_clear_selection_tool_);
|
|
|
- layout_toolbox_->addWidget(button_delete_all_labels_);
|
|
|
- layout_toolbox_->addSpacing(10);
|
|
|
- layout_toolbox_->addWidget(button_generate_colors_);
|
|
|
- /* stretch is for making toolbox as small as it can be */
|
|
|
- layout_toolbox_->addSpacing(10);
|
|
|
- layout_left_->addWidget(label_list_images_);
|
|
|
-
|
|
|
- layout_left_->addLayout(layout_imagelist_buttons_);
|
|
|
- layout_imagelist_buttons_->addWidget(button_add_image_);
|
|
|
- layout_imagelist_buttons_->addWidget(button_remove_image_);
|
|
|
-
|
|
|
- layout_left_->addWidget(list_images_widget_);
|
|
|
- list_images_widget_->setFixedWidth(200);
|
|
|
- layout_left_->addStretch(1);
|
|
|
- layout_left_->addWidget(button_confirm_selection_);
|
|
|
-
|
|
|
-
|
|
|
- /* central part */
|
|
|
- layout_center_->addWidget(frame_center_);
|
|
|
- frame_center_->setLayout(layout_frame_image_);
|
|
|
-
|
|
|
- layout_frame_image_->setContentsMargins(0, 0, 0, 0);
|
|
|
- layout_frame_image_->addWidget(frame_image_);
|
|
|
-
|
|
|
- layout_frame_image_->addLayout(layout_center_buttons_);
|
|
|
- layout_center_buttons_->addWidget(button_prev_image_);
|
|
|
- layout_center_buttons_->addWidget(button_next_image_);
|
|
|
-
|
|
|
- /* right part */
|
|
|
- layout_right_->addWidget(frame_labelbox_);
|
|
|
- frame_labelbox_->setFixedWidth(200);
|
|
|
- frame_labelbox_->setLayout(layout_labelbox_);
|
|
|
-
|
|
|
- layout_labelbox_->addWidget(label_list_label_);
|
|
|
-
|
|
|
- layout_labelbox_->addLayout(layout_labelbox_buttons_);
|
|
|
- layout_labelbox_buttons_->addWidget(button_add_label_);
|
|
|
- layout_labelbox_buttons_->addWidget(button_remove_label_);
|
|
|
-
|
|
|
- layout_labelbox_->addWidget(list_label_);
|
|
|
- layout_labelbox_->addWidget(label_list_areas_);
|
|
|
-
|
|
|
- layout_labelbox_->addLayout(layout_areabox_buttons_);
|
|
|
- layout_areabox_buttons_->addWidget(button_delete_area_);
|
|
|
- layout_areabox_buttons_->addWidget(button_change_area_);
|
|
|
- layout_areabox_buttons_->addWidget(button_change_area_text_);
|
|
|
- layout_areabox_buttons_->setSpacing(0);
|
|
|
-
|
|
|
- layout_labelbox_->addWidget(list_areas_);
|
|
|
|
|
|
+{
|
|
|
connect(
|
|
|
action_quit_,
|
|
|
SIGNAL(triggered()),
|
|
@@ -725,6 +430,8 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
SLOT(onAreaEdit())
|
|
|
);
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
QString settingsPath = aSettingsPath;
|
|
|
if (settingsPath.isEmpty())
|
|
|
settingsPath = QString("ImageLabeler.ini");
|
|
@@ -752,105 +459,20 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
*/
|
|
|
ImageLabeler::~ImageLabeler()
|
|
|
{
|
|
|
- delete action_quit_;
|
|
|
- delete action_open_labeled_image_;
|
|
|
- delete action_open_image_;
|
|
|
- delete action_open_images_;
|
|
|
- delete action_load_legend_;
|
|
|
- delete action_load_pascal_file_;
|
|
|
- delete action_load_pascal_poly_;
|
|
|
- delete action_save_legend_;
|
|
|
- delete action_save_segmented_;
|
|
|
- delete action_save_all_;
|
|
|
- delete action_view_normal_;
|
|
|
- delete action_view_segmented_;
|
|
|
- delete action_undo_;
|
|
|
- delete action_redo_;
|
|
|
- delete action_bound_box_tool_;
|
|
|
- delete action_polygon_tool_;
|
|
|
- delete action_tagging_tool_;
|
|
|
- delete action_add_description_;
|
|
|
- delete action_options_;
|
|
|
- delete action_about_;
|
|
|
- delete action_help_content_;
|
|
|
-
|
|
|
- delete menu_load_;
|
|
|
- delete menu_save_;
|
|
|
- delete menu_pascal_;
|
|
|
- delete menu_file_;
|
|
|
- delete menu_view_;
|
|
|
- delete menu_edit_;
|
|
|
- delete menu_help_;
|
|
|
-
|
|
|
- delete menu_bar_;
|
|
|
-
|
|
|
- delete action_delete_area_;
|
|
|
- delete action_edit_area_;
|
|
|
-
|
|
|
- delete popup_area_list_;
|
|
|
-
|
|
|
- delete action_toggle_priority_;
|
|
|
- delete action_set_color_;
|
|
|
- delete action_delete_label_;
|
|
|
-
|
|
|
- delete popup_label_list_;
|
|
|
-
|
|
|
- delete action_remove_image_;
|
|
|
-
|
|
|
- delete popup_images_list_;
|
|
|
+
|
|
|
+ if( list_images_ != NULL)
|
|
|
+ {
|
|
|
+ delete list_images_;
|
|
|
+ list_images_ = NULL;
|
|
|
+ }
|
|
|
|
|
|
delete image_;
|
|
|
- delete image_holder_;
|
|
|
-
|
|
|
- delete button_add_label_;
|
|
|
- delete button_remove_label_;
|
|
|
- delete button_bound_box_tool_;
|
|
|
- delete button_delete_area_;
|
|
|
- delete button_change_area_;
|
|
|
- delete button_change_area_text_;
|
|
|
- delete button_polygon_tool_;
|
|
|
- delete button_tagging_tool_;
|
|
|
- delete button_clear_selection_tool_;
|
|
|
- delete button_generate_colors_;
|
|
|
- delete button_delete_all_labels_;
|
|
|
- delete button_next_image_;
|
|
|
- delete button_prev_image_;
|
|
|
-
|
|
|
- delete button_confirm_selection_;
|
|
|
-
|
|
|
- delete label_list_label_;
|
|
|
- delete label_list_areas_;
|
|
|
- delete label_toolbox_;
|
|
|
- delete label_list_images_;
|
|
|
- delete list_areas_;
|
|
|
- delete list_label_;
|
|
|
- delete list_images_widget_;
|
|
|
-
|
|
|
- delete layout_imagelist_buttons_;
|
|
|
- delete layout_toolbox_;
|
|
|
- delete layout_right_;
|
|
|
- delete layout_center_buttons_;
|
|
|
- delete layout_frame_image_;
|
|
|
- delete layout_center_;
|
|
|
- delete layout_labelbox_buttons_;
|
|
|
- delete layout_areabox_buttons_;
|
|
|
- delete layout_labelbox_;
|
|
|
- delete layout_left_;
|
|
|
- delete layout_main_;
|
|
|
-
|
|
|
- delete frame_labelbox_;
|
|
|
- delete frame_toolbox_;
|
|
|
- delete frame_image_;
|
|
|
- delete frame_center_;
|
|
|
-
|
|
|
- delete central_widget_;
|
|
|
|
|
|
if (pure_data_) {
|
|
|
delete[] *pure_data_;
|
|
|
delete pure_data_;
|
|
|
}
|
|
|
|
|
|
- delete list_images_;
|
|
|
delete settings_;
|
|
|
}
|
|
|
|
|
@@ -1619,7 +1241,6 @@ ImageLabeler::nextImage(int iImageStep)
|
|
|
|
|
|
if (!askForUnsavedData()) {
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
list_bounding_box_.clear();
|
|
@@ -1639,14 +1260,12 @@ ImageLabeler::nextImage(int iImageStep)
|
|
|
if (!selectImage(image_ID_)) {
|
|
|
showWarning(tr("Next image is not available"));
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
list_images_widget_->setCurrentRow(image_ID_);
|
|
|
|
|
|
if (current_image_.isEmpty()) {
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
QString winTitle;
|
|
@@ -1672,12 +1291,10 @@ ImageLabeler::prevImage(int iImageStep)
|
|
|
{
|
|
|
if (!list_images_widget_->count()) {
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
if (!askForUnsavedData()) {
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
list_bounding_box_.clear();
|
|
@@ -1700,7 +1317,7 @@ ImageLabeler::prevImage(int iImageStep)
|
|
|
if (!selectImage(image_ID_)) {
|
|
|
showWarning(tr("Next image is not available"));
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
+/* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
QString winTitle;
|
|
@@ -3113,10 +2730,12 @@ ImageLabeler::addBBoxFromData(
|
|
|
)
|
|
|
{
|
|
|
BoundingBox *bbox = new BoundingBox;
|
|
|
- *bbox = BBoxFromData(aBBoxData);
|
|
|
- if (!bbox->rect.isValid() || !ID) {
|
|
|
+ if (!this->BBoxFromData(aBBoxData, *bbox) )
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (!bbox->rect.isValid() || !ID)
|
|
|
+ {
|
|
|
return;
|
|
|
- /* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
bbox->label_ID_ = *ID;
|
|
@@ -3130,14 +2749,10 @@ ImageLabeler::addBBoxFromData(
|
|
|
*
|
|
|
* format is x;y;w;h where w - width and h - height
|
|
|
*/
|
|
|
-BoundingBox
|
|
|
-ImageLabeler::BBoxFromData(
|
|
|
- QString *aBBoxData
|
|
|
-)
|
|
|
+bool ImageLabeler::BBoxFromData(const QString *aBBoxData, BoundingBox &p_BBox)
|
|
|
{
|
|
|
- BoundingBox bbox;
|
|
|
- QString buffer;
|
|
|
- bbox.rect.setRect(-1, -1, -1, -1);
|
|
|
+ QString buffer;
|
|
|
+ p_BBox.rect.setRect(-1, -1, -1, -1);
|
|
|
int startPos = 0;
|
|
|
bool ok = 1;
|
|
|
|
|
@@ -3155,35 +2770,37 @@ ImageLabeler::BBoxFromData(
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (-1 == bbox.rect.x()) {
|
|
|
- bbox.rect.setX(bboxData);
|
|
|
- bbox.rect.setWidth(-1);
|
|
|
+ if (-1 == p_BBox.rect.x()) {
|
|
|
+ p_BBox.rect.setX(bboxData);
|
|
|
+ p_BBox.rect.setWidth(-1);
|
|
|
}
|
|
|
- else if (-1 == bbox.rect.y()) {
|
|
|
- bbox.rect.setY(bboxData);
|
|
|
- bbox.rect.setHeight(-1);
|
|
|
+ else if (-1 == p_BBox.rect.y()) {
|
|
|
+ p_BBox.rect.setY(bboxData);
|
|
|
+ p_BBox.rect.setHeight(-1);
|
|
|
}
|
|
|
- else if (-1 == bbox.rect.width()) {
|
|
|
- bbox.rect.setWidth(bboxData);
|
|
|
+ else if (-1 == p_BBox.rect.width()) {
|
|
|
+ p_BBox.rect.setWidth(bboxData);
|
|
|
}
|
|
|
- else if (-1 == bbox.rect.height()) {
|
|
|
- bbox.rect.setHeight(bboxData);
|
|
|
+ else if (-1 == p_BBox.rect.height()) {
|
|
|
+ p_BBox.rect.setHeight(bboxData);
|
|
|
}
|
|
|
|
|
|
startPos = i + 1;
|
|
|
}
|
|
|
|
|
|
- if (!bbox.rect.isValid()) {
|
|
|
+ if (!p_BBox.rect.isValid()) {
|
|
|
qDebug() <<
|
|
|
"BBoxFromData: "
|
|
|
"bbox format is corrupted";
|
|
|
- bbox.rect.setRect(-1, -1, -1, -1);
|
|
|
+ p_BBox.rect.setRect(-1, -1, -1, -1);
|
|
|
+ return false;
|
|
|
}
|
|
|
else if (!ok) {
|
|
|
- bbox.rect.setRect(-1, -1, -1, -1);
|
|
|
+ p_BBox.rect.setRect(-1, -1, -1, -1);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- return bbox;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
//! A protected member getting a BoundaryBox from text of the list_areas_ item
|
|
@@ -3243,7 +2860,7 @@ ImageLabeler::BBoxFromListItemText(
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
|
QString pointsData = aString->mid(pointsPos, pointsLen);
|
|
|
- bbox = BBoxFromData(&pointsData);
|
|
|
+ BBoxFromData(&pointsData, bbox);
|
|
|
bbox.label_ID_ = labelID;
|
|
|
|
|
|
|