|
@@ -1,8 +1,8 @@
|
|
|
-/*
|
|
|
+/*!
|
|
|
* \file ImageLabeler.cpp
|
|
|
* \brief implementation of the ImageLabeler class
|
|
|
*
|
|
|
- * ImageLabeler class is the main widget which contains all GUI elements
|
|
|
+ * Main widget which contains all GUI elements
|
|
|
* and connect them with each other.
|
|
|
*
|
|
|
* Created on: Oct 4, 2011
|
|
@@ -634,24 +634,12 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
this,
|
|
|
SLOT(setDataFromForm(QString))
|
|
|
);
|
|
|
- connect(
|
|
|
- image_holder_,
|
|
|
- SIGNAL(imageScaled()),
|
|
|
- this,
|
|
|
- SLOT(onImageScaled())
|
|
|
- );
|
|
|
connect(
|
|
|
image_holder_,
|
|
|
SIGNAL(areaEdited()),
|
|
|
this,
|
|
|
SLOT(onAreaEdit())
|
|
|
);
|
|
|
- connect(
|
|
|
- &options_form_,
|
|
|
- SIGNAL(optionsSet()),
|
|
|
- this,
|
|
|
- SLOT(onOptionsSet())
|
|
|
- );
|
|
|
|
|
|
QString settingsPath = aSettingsPath;
|
|
|
if (settingsPath.isEmpty())
|
|
@@ -670,6 +658,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
|
|
|
|
|
|
/* the same for options_form_ */
|
|
|
options_form_.setPASCALpath(&PASCALpath_);
|
|
|
+ options_form_.setAutoColorGeneration(&auto_color_generation_);
|
|
|
}
|
|
|
|
|
|
//! A destructor of the ImageLabeler class
|
|
@@ -775,6 +764,7 @@ ImageLabeler::~ImageLabeler()
|
|
|
|
|
|
//! A member which reads the settings from file to RAM
|
|
|
/*!
|
|
|
+ * \see writeSettings(QSettings *aSettings)
|
|
|
* \param[in] aSettings a pointer to the QSettings object
|
|
|
* which should be previously created and set to the right
|
|
|
* file with settings.
|
|
@@ -785,7 +775,7 @@ ImageLabeler::readSettings(QSettings *aSettings)
|
|
|
aSettings->beginGroup("/global");
|
|
|
auto_color_generation_ =
|
|
|
aSettings->value("/auto_label_color_generation", 0).toBool();
|
|
|
- options_form_.setAutoColorGeneration(auto_color_generation_);
|
|
|
+ options_form_.setAutoColorGeneration(&auto_color_generation_);
|
|
|
PASCALpath_ = aSettings->value("/PASCAL_root_path", "").toString();
|
|
|
aSettings->endGroup();
|
|
|
|
|
@@ -804,6 +794,7 @@ ImageLabeler::readSettings()
|
|
|
|
|
|
//! A member which writes settings from RAM to file
|
|
|
/*!
|
|
|
+ * \see readSettings(QSettings *aSettings)
|
|
|
* \param[in] aSettings a pointer to the QSettings object
|
|
|
* which should be previously created and set to the right
|
|
|
* file with settings
|
|
@@ -829,7 +820,7 @@ ImageLabeler::writeSettings()
|
|
|
writeSettings(settings_);
|
|
|
}
|
|
|
|
|
|
-//! A member taking a pointer to the Image struct and adding it to all necessary
|
|
|
+//! \brief A member taking a pointer to the Image struct and adding it to all necessary
|
|
|
//! containers and widgets
|
|
|
/*!
|
|
|
* \param[in] anImage a pointer to the Image struct which should contain path to
|
|
@@ -1039,7 +1030,7 @@ ImageLabeler::removeLabel(int aLabelID)
|
|
|
unsaved_data_ = 1;
|
|
|
}
|
|
|
|
|
|
-//! a slot Member setting label_ID_ variable according to the selected row
|
|
|
+//! \brief a slot Member setting label_ID_ variable according to the selected row
|
|
|
//! in the list_label_ widget
|
|
|
/*!
|
|
|
* \param[in] anItem a pointer to the QListWidgetItem object which can be
|
|
@@ -1170,9 +1161,11 @@ ImageLabeler::editArea()
|
|
|
list_areas_->blockSignals(oldState);
|
|
|
}
|
|
|
|
|
|
-//! A slot member parsing a text of the changed item and tries to edit
|
|
|
+//! \brief A slot member parsing a text of the changed item and tries to edit
|
|
|
//! the corresponding area
|
|
|
/*!
|
|
|
+ * \see polyFromListItemText(QString *aString,int *oldID)
|
|
|
+ * \see BBoxFromListItemText(QString *aString,int *oldID)
|
|
|
* \param[in] anItem a pointer to the QListWidgetItem object which contains
|
|
|
* area's changed data
|
|
|
*
|
|
@@ -1187,7 +1180,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
|
|
|
int oldID = -1;
|
|
|
if (-1 != areaString.indexOf("Poly")) {
|
|
|
Polygon *poly = new Polygon;
|
|
|
- *poly = polyFromString(&areaString, &oldID);
|
|
|
+ *poly = polyFromListItemText(&areaString, &oldID);
|
|
|
|
|
|
if (-1 < poly->label_ID_ && !poly->poly.isEmpty() &&
|
|
|
-1 < oldID) {
|
|
@@ -1199,7 +1192,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
|
|
|
}
|
|
|
else if (-1 != areaString.indexOf("BBox")) {
|
|
|
BoundingBox *bbox = new BoundingBox;
|
|
|
- *bbox = BBoxFromString(&areaString, &oldID);
|
|
|
+ *bbox = BBoxFromListItemText(&areaString, &oldID);
|
|
|
|
|
|
if (-1 < bbox->label_ID_ && -1 < oldID) {
|
|
|
list_bounding_box_.takeAt(oldID);
|
|
@@ -1220,7 +1213,7 @@ ImageLabeler::onAreaItemChange(QListWidgetItem *anItem)
|
|
|
unsaved_data_ = 1;
|
|
|
}
|
|
|
|
|
|
-//! A slot member changing the item in the list_areas_ to meet the changes
|
|
|
+//! \brief A slot member changing the item in the list_areas_ to meet the changes
|
|
|
//! being made during area editing(where editing means moving the points of
|
|
|
//! an area)
|
|
|
/*!
|
|
@@ -1266,7 +1259,7 @@ ImageLabeler::onAreaEdit()
|
|
|
unsaved_data_ = 1;
|
|
|
}
|
|
|
|
|
|
-//! A slot member deleting selected area in the list_areas_ widget
|
|
|
+//! \brief A slot member deleting selected area in the list_areas_ widget
|
|
|
//! and all other corresponding containers
|
|
|
/*!
|
|
|
* \see deleteArea(QListWidgetItem *anItem)
|
|
@@ -1360,7 +1353,7 @@ ImageLabeler::deleteArea(QListWidgetItem *anItem)
|
|
|
/*!
|
|
|
* \see toggleLabelPriority(QListWidgetItem *anItem)
|
|
|
* Slot not just only toggles current label priority but also checks other labels
|
|
|
- * if any of the are also main. If so it just makes them common(not main)
|
|
|
+ * if any of them are also main. If so it just makes them common(not main)
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::toggleLabelPriority()
|
|
@@ -1499,7 +1492,7 @@ ImageLabeler::getImagesFromDir(const QDir &dir)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//! A slot member changing current image to the next one
|
|
|
+//! \brief A slot member changing current image to the next one
|
|
|
//! and clearing all the data(except legend)
|
|
|
/*!
|
|
|
* Asks about unsaved data if there is any. If current picture was the
|
|
@@ -1555,7 +1548,7 @@ ImageLabeler::nextImage()
|
|
|
//clearLabelColorList();
|
|
|
}
|
|
|
|
|
|
-//! A slot member changing current image to the previous one
|
|
|
+//! \brief A slot member changing current image to the previous one
|
|
|
//! and clearing all the data(except legend)
|
|
|
/*!
|
|
|
* Asks about unsaved data if there is any. If current picture was the
|
|
@@ -2901,7 +2894,6 @@ ImageLabeler::generateColors()
|
|
|
}
|
|
|
|
|
|
int coeff = (0xff / labelCount) * 3;
|
|
|
- //QList< uint > colors;
|
|
|
list_label_colors_.clear();
|
|
|
list_label_colors_.append(0);
|
|
|
uchar red = 0xff;
|
|
@@ -2960,6 +2952,9 @@ ImageLabeler::generateColors()
|
|
|
//! A protected member creating new boundary box from text data
|
|
|
/*!
|
|
|
* \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
|
|
|
+ * \see BBoxFromData(QString *aBBoxData)
|
|
|
+ *
|
|
|
+ * It creates bbox both in the container and in the list widget
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::addBBoxFromData(
|
|
@@ -2979,9 +2974,11 @@ ImageLabeler::addBBoxFromData(
|
|
|
addBBoxArea(list_bounding_box_.count() - 1, *bbox);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member parsing string data and returning a BoundingBox from it
|
|
|
/*!
|
|
|
+ * \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
|
|
|
*
|
|
|
+ * format is x;y;w;h where w - width and h - height
|
|
|
*/
|
|
|
BoundingBox
|
|
|
ImageLabeler::BBoxFromData(
|
|
@@ -3039,12 +3036,14 @@ ImageLabeler::BBoxFromData(
|
|
|
return bbox;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member getting a BoundaryBox from text of the list_areas_ item
|
|
|
/*!
|
|
|
+ * \see BBoxFromData(QString *aBBoxData)
|
|
|
*
|
|
|
+ * Slot gets label ID an points from the string data. BBox ID can not be changed.
|
|
|
*/
|
|
|
BoundingBox
|
|
|
-ImageLabeler::BBoxFromString(
|
|
|
+ImageLabeler::BBoxFromListItemText(
|
|
|
QString *aString,
|
|
|
int *oldID
|
|
|
)
|
|
@@ -3068,7 +3067,7 @@ ImageLabeler::BBoxFromString(
|
|
|
int bboxID = getNumFromString(aString, "BBox #", ";", &ok);
|
|
|
if (!ok || bboxID <= -1) {
|
|
|
qDebug() <<
|
|
|
- "BBoxFromString: bboxID is corrupted";
|
|
|
+ "BBoxFromListItemText: bboxID is corrupted";
|
|
|
return bbox;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
@@ -3102,8 +3101,11 @@ ImageLabeler::BBoxFromString(
|
|
|
return bbox;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member adding poly to the list widget and to the list container
|
|
|
/*!
|
|
|
+ * \see addBBox(BoundingBox *bbox)
|
|
|
+ * \param[in] poly a pointer to the Polygon structure
|
|
|
+ * containing new poly information
|
|
|
*
|
|
|
*/
|
|
|
void
|
|
@@ -3119,6 +3121,14 @@ ImageLabeler::addPoly(Polygon *poly)
|
|
|
|
|
|
}
|
|
|
|
|
|
+//! A protected member adding bounding box to the list widget
|
|
|
+//! and to the list container
|
|
|
+/*!
|
|
|
+ * \see addPoly(Polygon *poly)
|
|
|
+ * \param[in] bbox a pointer to the BoundingBox structure
|
|
|
+ * containing new bounding box information
|
|
|
+ *
|
|
|
+ */
|
|
|
void
|
|
|
ImageLabeler::addBBox(BoundingBox *bbox)
|
|
|
{
|
|
@@ -3129,12 +3139,14 @@ ImageLabeler::addBBox(BoundingBox *bbox)
|
|
|
|
|
|
list_bounding_box_.append(bbox);
|
|
|
addBBoxArea(list_bounding_box_.count() - 1, *bbox);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member creating new polygon from text data
|
|
|
/*!
|
|
|
+ * \see addPolyArea(int anID, Polygon aPoly, int itemID)
|
|
|
+ * \see polyFromData(QString *aPolyData)
|
|
|
*
|
|
|
+ * It creates polygon both in the container and in the list widget
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::addPolyFromData(
|
|
@@ -3155,9 +3167,11 @@ ImageLabeler::addPolyFromData(
|
|
|
addPolyArea(list_polygon_.count() - 1, *poly);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member parsing string data and returning a Polygon from it
|
|
|
/*!
|
|
|
+ * \see addPolyArea(int anID, Polygon aPoly, int itemID)
|
|
|
*
|
|
|
+ * format is x0;y0;x1;y1;...
|
|
|
*/
|
|
|
Polygon
|
|
|
ImageLabeler::polyFromData(
|
|
@@ -3170,9 +3184,11 @@ ImageLabeler::polyFromData(
|
|
|
QString buffer;
|
|
|
int startPos = 0;
|
|
|
bool ok = 1;
|
|
|
+ /* indicates whether coordinate x or y */
|
|
|
bool evenFlag = 0;
|
|
|
|
|
|
for (int i = 0; i < aPolyData->size(); i++) {
|
|
|
+ /* ";" is a separator */
|
|
|
if (';' != aPolyData->at(i))
|
|
|
continue;
|
|
|
|
|
@@ -3198,12 +3214,14 @@ ImageLabeler::polyFromData(
|
|
|
startPos = i + 1;
|
|
|
}
|
|
|
|
|
|
+ /* last coordinate was Xi what means an error */
|
|
|
if (evenFlag) {
|
|
|
qDebug() <<
|
|
|
"polyFromData: "
|
|
|
"poly format is corrupted";
|
|
|
poly.poly.clear();
|
|
|
}
|
|
|
+ /* last converting from string was not successful */
|
|
|
else if (!ok) {
|
|
|
poly.poly.clear();
|
|
|
}
|
|
@@ -3211,12 +3229,14 @@ ImageLabeler::polyFromData(
|
|
|
return poly;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member getting a Polygon from text of the list_areas_ item
|
|
|
/*!
|
|
|
+ * \see polyFromData(QString *aPolyData)
|
|
|
*
|
|
|
+ * Slot gets label ID an points from the string data. Poly ID can not be changed.
|
|
|
*/
|
|
|
Polygon
|
|
|
-ImageLabeler::polyFromString(
|
|
|
+ImageLabeler::polyFromListItemText(
|
|
|
QString *aString,
|
|
|
int *oldID
|
|
|
)
|
|
@@ -3240,7 +3260,7 @@ ImageLabeler::polyFromString(
|
|
|
int polyID = getNumFromString(aString, "Poly #", ";", &ok);
|
|
|
if (!ok || polyID <= -1) {
|
|
|
qDebug() <<
|
|
|
- "polyFromString: poly ID is corrupted";
|
|
|
+ "polyFromListItemText: poly ID is corrupted";
|
|
|
return poly;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
@@ -3274,13 +3294,14 @@ ImageLabeler::polyFromString(
|
|
|
return poly;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member only for internal use. Showing a message box with warning
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \param[in] text a QString object containing message you want
|
|
|
+ * to deliver to the user
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::showWarning(
|
|
|
- const QString text
|
|
|
+ const QString &text
|
|
|
)
|
|
|
{
|
|
|
if (text.isEmpty()) {
|
|
@@ -3294,9 +3315,11 @@ ImageLabeler::showWarning(
|
|
|
msgBox.exec();
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member only for internal use.
|
|
|
+//! Shows a message box asking about unsaved progress
|
|
|
/*!
|
|
|
- *
|
|
|
+ * It depends on object containers(list_bounding_box_ and list_polygon_)
|
|
|
+ * and on unsaved_data_ flag which must be true to make this dialog appear
|
|
|
*/
|
|
|
bool
|
|
|
ImageLabeler::askForUnsavedData()
|
|
@@ -3319,12 +3342,12 @@ ImageLabeler::askForUnsavedData()
|
|
|
else if (QMessageBox::Cancel == ret)
|
|
|
return true;
|
|
|
}
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member setting bbox tool active
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \param[in] aButtonPressed is a bool flag which is needed for toggled buttons
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::setBoundingBoxTool(bool aButtonPressed)
|
|
@@ -3337,9 +3360,9 @@ ImageLabeler::setBoundingBoxTool(bool aButtonPressed)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member setting polygon tool active
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \param[in] aButtonPressed is a bool flag which is needed for toggled buttons
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::setPolygonTool(bool aButtonPressed)
|
|
@@ -3354,30 +3377,22 @@ ImageLabeler::setPolygonTool(bool aButtonPressed)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
-/*!
|
|
|
- *
|
|
|
- */
|
|
|
+//! A slot member enables button_confirm_selection_ button
|
|
|
void
|
|
|
ImageLabeler::onSelectionStarted()
|
|
|
{
|
|
|
button_confirm_selection_->setEnabled(true);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
-/*!
|
|
|
- *
|
|
|
- */
|
|
|
-void
|
|
|
-ImageLabeler::onImageScaled()
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-//!
|
|
|
+//! A slot member adding information about new selected area
|
|
|
/*!
|
|
|
+ * \see addBBoxArea(int anID, BoundingBox aBBox, int itemID)
|
|
|
+ * \see addPolyArea(int aPolyID, Polygon aPoly, int itemID)
|
|
|
*
|
|
|
+ * After user has created a new selection area it should be confirmed or else it
|
|
|
+ * wouldn't be added to the item list and containers. This slot takes all data from
|
|
|
+ * unconfirmed selection and places it into list widget and corresponding container
|
|
|
+ * (list_bounding_box_ or list_polygon_)
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::confirmSelection()
|
|
@@ -3417,9 +3432,12 @@ ImageLabeler::confirmSelection()
|
|
|
unsaved_data_ = 1;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member clears all widgets and containers
|
|
|
+//! (not recommended to use without necessity)
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see clearAllTool()
|
|
|
+ * \see clearLabelList()
|
|
|
+ * \see clearLabelColorList()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::clearAll()
|
|
@@ -3437,9 +3455,11 @@ ImageLabeler::clearAll()
|
|
|
action_view_segmented_->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member clears only selections made by user
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see clearAll()
|
|
|
+ * \see clearLabelList()
|
|
|
+ * \see clearLabelColorList()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::clearAllTool()
|
|
@@ -3451,9 +3471,14 @@ ImageLabeler::clearAllTool()
|
|
|
image_holder_->clearAll();
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member clears label list
|
|
|
/*!
|
|
|
+ * \see clearAll()
|
|
|
+ * \see clearAllTool()
|
|
|
+ * \see clearLabelColorList()
|
|
|
*
|
|
|
+ * As far as BACKGROUND label should always be present slot adds
|
|
|
+ * it after clearing all the label list
|
|
|
*/
|
|
|
void ImageLabeler::clearLabelList()
|
|
|
{
|
|
@@ -3465,9 +3490,14 @@ void ImageLabeler::clearLabelList()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member clears the list of label colors
|
|
|
/*!
|
|
|
+ * \see clearAll()
|
|
|
+ * \see clearAllTool()
|
|
|
+ * \see clearLabelList()
|
|
|
*
|
|
|
+ * As far as BACKGROUND label should always be present slot adds
|
|
|
+ * it's color(black by default) after clearing all the label color list
|
|
|
*/
|
|
|
void ImageLabeler::clearLabelColorList()
|
|
|
{
|
|
@@ -3475,9 +3505,13 @@ void ImageLabeler::clearLabelColorList()
|
|
|
list_label_colors_.append(0x0);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member enabling all the tools
|
|
|
/*!
|
|
|
+ * \see disableTools()
|
|
|
*
|
|
|
+ * By default the initial state of all tools is disabled
|
|
|
+ * so this slot is recommended to use when at least one image
|
|
|
+ * has been loaded
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::enableTools()
|
|
@@ -3502,9 +3536,9 @@ ImageLabeler::enableTools()
|
|
|
button_delete_all_labels_->setEnabled(true);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member disabling all the tools
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see enableTools()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::disableTools()
|
|
@@ -3529,9 +3563,11 @@ ImageLabeler::disableTools()
|
|
|
button_delete_all_labels_->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member triggering popup_area_list_ menu with the coordinates
|
|
|
+//! of the mouse pointer
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see deleteArea()
|
|
|
+ * \see editArea()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::areaListPopupMenu(const QPoint &aPos)
|
|
@@ -3549,9 +3585,12 @@ ImageLabeler::areaListPopupMenu(const QPoint &aPos)
|
|
|
popup_area_list_->exec(globalPos);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member triggering popup_label_list_ menu width the coordinates
|
|
|
+//! of the mouse pointer
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see setLabelColor()
|
|
|
+ * \see toggleLabelPriority()
|
|
|
+ * \see removeLabel()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::labelListPopupMenu(const QPoint &aPos)
|
|
@@ -3569,6 +3608,32 @@ ImageLabeler::labelListPopupMenu(const QPoint &aPos)
|
|
|
popup_label_list_->exec(globalPos);
|
|
|
}
|
|
|
|
|
|
+//! \brief A slot member triggering popup_images_list_ menu width the coordinates
|
|
|
+//! of the mouse pointer
|
|
|
+/*!
|
|
|
+ * \see removeImage()
|
|
|
+ */
|
|
|
+void
|
|
|
+ImageLabeler::imageListPopupMenu(const QPoint &aPos)
|
|
|
+{
|
|
|
+ QPoint globalPos = list_images_widget_->mapToGlobal(aPos);
|
|
|
+ QModelIndex index = list_images_widget_->indexAt(aPos);
|
|
|
+
|
|
|
+ if (-1 == index.row()) {
|
|
|
+ return;
|
|
|
+ /* NOTREACHED */
|
|
|
+ }
|
|
|
+
|
|
|
+ list_images_widget_->item(index.row())->setSelected(true);
|
|
|
+
|
|
|
+ popup_images_list_->exec(globalPos);
|
|
|
+}
|
|
|
+
|
|
|
+//! \brief A slot member gets image description or tags from line_edit_form_
|
|
|
+//! depends on line_edit_form_.purpose()
|
|
|
+/*!
|
|
|
+ * \see LineEditForm
|
|
|
+ */
|
|
|
void
|
|
|
ImageLabeler::setDataFromForm(QString aData)
|
|
|
{
|
|
@@ -3581,9 +3646,11 @@ ImageLabeler::setDataFromForm(QString aData)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member creating 2-dimensional array for the segmented image
|
|
|
/*!
|
|
|
- *
|
|
|
+ * Array size is equal to a size of the current image loaded
|
|
|
+ * and each pixel has the label id which corresponds to the objects in
|
|
|
+ * list_bounding_box_ and list_polygon_.
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::setPureData()
|
|
@@ -3594,12 +3661,14 @@ ImageLabeler::setPureData()
|
|
|
delete pure_data_;
|
|
|
}
|
|
|
|
|
|
+ /* getting image size */
|
|
|
QSize imageSize = image_->size();
|
|
|
pure_data_ = new int *[imageSize.height()];
|
|
|
if (!pure_data_) {
|
|
|
return;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
|
+ /* allocating memory */
|
|
|
for (int i = 0; i < imageSize.height(); i++) {
|
|
|
pure_data_[i] = new int[imageSize.width()];
|
|
|
if (!pure_data_[i]) {
|
|
@@ -3608,8 +3677,10 @@ ImageLabeler::setPureData()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* getting the number of all selections */
|
|
|
int bboxCnt = list_bounding_box_.count();
|
|
|
int polyCnt = list_polygon_.count();
|
|
|
+ /* checking if each coordinate(pixel) belongs to any object */
|
|
|
for (int i = 0; i < imageSize.height(); i++)
|
|
|
for (int j = 0; j < imageSize.width(); j++) {
|
|
|
pure_data_[i][j] = 0;
|
|
@@ -3628,13 +3699,12 @@ ImageLabeler::setPureData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member setting new color for
|
|
|
+//! the current label from QColorDialog
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see setLabelColor(int anID, QColor aColor)
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::setLabelColor()
|
|
@@ -3643,6 +3713,7 @@ ImageLabeler::setLabelColor()
|
|
|
generateColors();
|
|
|
}
|
|
|
|
|
|
+ /* getting current item */
|
|
|
QListWidgetItem *current = list_label_->currentItem();
|
|
|
|
|
|
int labelID = list_label_->row(current);
|
|
@@ -3669,14 +3740,15 @@ ImageLabeler::setLabelColor()
|
|
|
image_holder_->update();
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member setting color aColor for the label number anID
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \param[in] anID an integer indicating label number in the list_label_ widget
|
|
|
+ * \param[in] aColor a QColor object contains color you want to set for the label
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::setLabelColor(int anID, QColor aColor)
|
|
|
{
|
|
|
- if (anID < 0) {
|
|
|
+ if (anID < 0 || list_label_->count() < anID) {
|
|
|
return;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
@@ -3698,19 +3770,9 @@ ImageLabeler::setLabelColor(int anID, QColor aColor)
|
|
|
image_holder_->update();
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member loading normal image which path is in the current_image_
|
|
|
/*!
|
|
|
- *
|
|
|
- */
|
|
|
-void
|
|
|
-ImageLabeler::onOptionsSet()
|
|
|
-{
|
|
|
- auto_color_generation_ = options_form_.autoColorGeneration();
|
|
|
-}
|
|
|
-
|
|
|
-//!
|
|
|
-/*!
|
|
|
- *
|
|
|
+ * \see viewSegmented()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::viewNormal()
|
|
@@ -3727,9 +3789,9 @@ ImageLabeler::viewNormal()
|
|
|
action_view_normal_->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A slot member loading segmented image which path is in the segmented_image_
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see viewNormal()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::viewSegmented()
|
|
@@ -3746,9 +3808,11 @@ ImageLabeler::viewSegmented()
|
|
|
action_view_normal_->setEnabled(true);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member setting interrupt_search_ to true for interrupting
|
|
|
+//! the recursive search
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see loadImages()
|
|
|
+ * \see getImagesFromDir(const QDir &dir)
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::interruptSearch()
|
|
@@ -3756,9 +3820,12 @@ ImageLabeler::interruptSearch()
|
|
|
interrupt_search_ = 1;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! \brief A slot member selecting image corresponding to the item
|
|
|
+//! in the list_images_widget_
|
|
|
/*!
|
|
|
- *
|
|
|
+ * \see selectImage(int anImageID)
|
|
|
+ * \param[in] anItem a pointer to the QListWidgetItem object which indicates
|
|
|
+ * certain image in the image_list_
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::selectImage(QListWidgetItem *anItem)
|
|
@@ -3778,9 +3845,14 @@ ImageLabeler::selectImage(QListWidgetItem *anItem)
|
|
|
selectImage(image_ID_);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member loading image from list_images_
|
|
|
/*!
|
|
|
+ * \see loadInfo(QString filename)
|
|
|
+ * \param[in] anImageID an integer indicates certain
|
|
|
+ * image in the image_list_
|
|
|
*
|
|
|
+ * if that image was labeled before, selectImage(int anImageID)
|
|
|
+ * will try to load all info
|
|
|
*/
|
|
|
bool
|
|
|
ImageLabeler::selectImage(int anImageID)
|
|
@@ -3792,6 +3864,7 @@ ImageLabeler::selectImage(int anImageID)
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
|
|
|
|
+ /* checking if it was labeled before */
|
|
|
if (list_images_->at(anImageID).labeled_ &&
|
|
|
!list_images_->at(anImageID).pas_)
|
|
|
{
|
|
@@ -3801,12 +3874,14 @@ ImageLabeler::selectImage(int anImageID)
|
|
|
labeled.append(".dat");
|
|
|
loadInfo(labeled);
|
|
|
}
|
|
|
+ /* if it was loaded from PASCAL file then we're in trouble */
|
|
|
else if (list_images_->at(anImageID).labeled_ &&
|
|
|
list_images_->at(anImageID).pas_)
|
|
|
{
|
|
|
/* TODO: do the pascal file selecting */
|
|
|
showWarning("this function doesn't work at the moment, sorry.");
|
|
|
}
|
|
|
+ /* loading clean unlabeled image */
|
|
|
else {
|
|
|
current_image_ = list_images_->at(anImageID).image_;
|
|
|
image_->load(current_image_);
|
|
@@ -3817,29 +3892,13 @@ ImageLabeler::selectImage(int anImageID)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
-/*!
|
|
|
- *
|
|
|
- */
|
|
|
-void
|
|
|
-ImageLabeler::imageListPopupMenu(const QPoint &aPos)
|
|
|
-{
|
|
|
- QPoint globalPos = list_images_widget_->mapToGlobal(aPos);
|
|
|
- QModelIndex index = list_images_widget_->indexAt(aPos);
|
|
|
-
|
|
|
- if (-1 == index.row()) {
|
|
|
- return;
|
|
|
- /* NOTREACHED */
|
|
|
- }
|
|
|
-
|
|
|
- list_images_widget_->item(index.row())->setSelected(true);
|
|
|
-
|
|
|
- popup_images_list_->exec(globalPos);
|
|
|
-}
|
|
|
-
|
|
|
-//!
|
|
|
+//! \brief A slot member removing selected image from list
|
|
|
+//! (image will still be loaded in the image_holder_)
|
|
|
/*!
|
|
|
- *
|
|
|
+ * Image will be removed from list so it will not be possible to load
|
|
|
+ * it again without using loadImage() or other slots for image loading.
|
|
|
+ * if you want to remove image from image_holder_ just call
|
|
|
+ * image_holder_->clear()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::removeImage()
|
|
@@ -3855,7 +3914,7 @@ ImageLabeler::removeImage()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member which is being automatically called on every image resize
|
|
|
/*!
|
|
|
*
|
|
|
*/
|
|
@@ -3865,7 +3924,7 @@ ImageLabeler::resizeEvent (QResizeEvent *anEvent)
|
|
|
QWidget::resizeEvent(anEvent);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member which is being automatically called on every mouse press
|
|
|
/*!
|
|
|
*
|
|
|
*/
|
|
@@ -3875,9 +3934,14 @@ ImageLabeler::mousePressEvent(QMouseEvent *anEvent)
|
|
|
QWidget::mousePressEvent(anEvent);
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member which is being automatically called on every key press
|
|
|
/*!
|
|
|
- *
|
|
|
+ * current list of available commands:
|
|
|
+ * - key left\right - prevImage() \ nextImage()
|
|
|
+ * - enter\return - confirmSelection()
|
|
|
+ * - esc - clear current selection
|
|
|
+ * - ctrl+z - image_holder_->undo()
|
|
|
+ * - ctrl+y - iamge_holder_->redo()
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::keyPressEvent(QKeyEvent *anEvent)
|
|
@@ -3906,14 +3970,14 @@ ImageLabeler::keyPressEvent(QKeyEvent *anEvent)
|
|
|
// Qt::NoModifier == anEvent->modifiers() &&
|
|
|
-1 != image_holder_->focusedSelection()) {
|
|
|
image_holder_->clearFocusOnArea();
|
|
|
- image_holder_->clearEdition();
|
|
|
+ image_holder_->clearHoveredPoint();
|
|
|
image_holder_->update();
|
|
|
}
|
|
|
|
|
|
if (Qt::Key_Escape == anEvent->key()) {
|
|
|
image_holder_->clearLast();
|
|
|
image_holder_->clearFocusOnArea();
|
|
|
- image_holder_->clearEdition();
|
|
|
+ image_holder_->clearHoveredPoint();
|
|
|
image_holder_->update();
|
|
|
}
|
|
|
|
|
@@ -3940,9 +4004,9 @@ ImageLabeler::keyReleaseEvent(QKeyEvent *anEvent)
|
|
|
keyboard_modifier_ = anEvent->modifiers();
|
|
|
}
|
|
|
|
|
|
-//!
|
|
|
+//! A protected member which is being automatically called on every mouse wheel turn
|
|
|
/*!
|
|
|
- *
|
|
|
+ * implements zooming in and out on ctrl+wheel
|
|
|
*/
|
|
|
void
|
|
|
ImageLabeler::wheelEvent(QWheelEvent *anEvent)
|