|
@@ -70,12 +70,14 @@ ImageLabeler::ImageLabeler(QWidget *aParent) :
|
|
|
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"));
|
|
|
+ action_open_images_->setText(tr("&Load images(recursively)"));
|
|
|
action_open_labeled_image_ = new QAction(this);
|
|
|
- action_open_labeled_image_->setText(tr("&Open labeled image"));
|
|
|
+ action_open_labeled_image_->setText(tr("&Load labeled image"));
|
|
|
action_load_legend_ = new QAction(this);
|
|
|
- action_load_legend_->setText(tr("Load &legend"));
|
|
|
+ action_load_legend_->setText(tr("&Load legend"));
|
|
|
action_save_labels_ = new QAction(this);
|
|
|
action_save_labels_->setText(tr("&Save all info"));
|
|
|
action_save_labels_->setEnabled(false);
|
|
@@ -124,6 +126,7 @@ ImageLabeler::ImageLabeler(QWidget *aParent) :
|
|
|
action_about_->setEnabled(false);
|
|
|
/* ------------------ */
|
|
|
|
|
|
+ menu_file_->addAction(action_open_image_);
|
|
|
menu_file_->addAction(action_open_images_);
|
|
|
menu_file_->addAction(action_open_labeled_image_);
|
|
|
menu_file_->addAction(action_load_legend_);
|
|
@@ -361,6 +364,12 @@ ImageLabeler::ImageLabeler(QWidget *aParent) :
|
|
|
this,
|
|
|
SLOT(loadImages())
|
|
|
);
|
|
|
+ connect(
|
|
|
+ action_open_image_,
|
|
|
+ SIGNAL(triggered()),
|
|
|
+ this,
|
|
|
+ SLOT(loadImage())
|
|
|
+ );
|
|
|
connect(
|
|
|
action_open_labeled_image_,
|
|
|
SIGNAL(triggered()),
|
|
@@ -595,6 +604,7 @@ ImageLabeler::~ImageLabeler()
|
|
|
{
|
|
|
delete action_quit_;
|
|
|
delete action_open_labeled_image_;
|
|
|
+ delete action_open_image_;
|
|
|
delete action_open_images_;
|
|
|
delete action_load_legend_;
|
|
|
delete action_save_legend_;
|
|
@@ -848,11 +858,11 @@ ImageLabeler::addBBoxArea(
|
|
|
label.append(QString("BBox #%1; ").arg(anID));
|
|
|
label.append(QString("LabelID: %1; ").arg(aBBox.label_ID_));
|
|
|
label.append(
|
|
|
- QString("points:%1;%2;%3;%4; ").
|
|
|
+ QString("data:%1;%2;%3;%4; ").
|
|
|
arg(aBBox.rect.topLeft().x()).
|
|
|
arg(aBBox.rect.topLeft().y()).
|
|
|
- arg(aBBox.rect.bottomRight().x()).
|
|
|
- arg(aBBox.rect.bottomRight().y())
|
|
|
+ arg(aBBox.rect.width()).
|
|
|
+ arg(aBBox.rect.height())
|
|
|
);
|
|
|
|
|
|
newItem->setText(label);
|
|
@@ -1436,12 +1446,15 @@ ImageLabeler::saveLegend()
|
|
|
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
fileDialog.setDefaultSuffix("dat");
|
|
|
fileDialog.setFileMode(QFileDialog::AnyFile);
|
|
|
+ QString dir = getDirFromPath(&(*current_image_));
|
|
|
|
|
|
/* altering the name of a new file */
|
|
|
QString newFileName = alterFileName(*current_image_, "_legend");
|
|
|
|
|
|
fileDialog.selectFile(newFileName);
|
|
|
|
|
|
+ fileDialog.setDirectory(dir);
|
|
|
+
|
|
|
QString filename;
|
|
|
if (fileDialog.exec()) {
|
|
|
filename = fileDialog.selectedFiles().last();
|
|
@@ -1583,7 +1596,7 @@ ImageLabeler::loadInfo()
|
|
|
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting poly: "
|
|
|
+ "loadInfo: "
|
|
|
"poly id format is corrupted";
|
|
|
subNode = subNode.nextSibling();
|
|
|
continue;
|
|
@@ -1606,6 +1619,57 @@ ImageLabeler::loadInfo()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+ImageLabeler::loadImage()
|
|
|
+{
|
|
|
+ if (askForUnsavedData()) {
|
|
|
+ return;
|
|
|
+ /* NOTREACHED */
|
|
|
+ }
|
|
|
+
|
|
|
+ QFileDialog fileDialog(0, tr("Load image"));
|
|
|
+ fileDialog.setFileMode(QFileDialog::AnyFile);
|
|
|
+ QString filename;
|
|
|
+
|
|
|
+ if (fileDialog.exec()) {
|
|
|
+ filename = fileDialog.selectedFiles().last();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //showWarning(tr("Could not open file dialog"));
|
|
|
+ return;
|
|
|
+ /* NOTREACHED */
|
|
|
+ }
|
|
|
+
|
|
|
+ if (filename.isEmpty()) {
|
|
|
+ return;
|
|
|
+ /* NOTREACHED */
|
|
|
+ }
|
|
|
+
|
|
|
+ clearAllTool();
|
|
|
+
|
|
|
+
|
|
|
+ list_images_->append(filename);
|
|
|
+
|
|
|
+ if (list_images_->isEmpty()) {
|
|
|
+ return;
|
|
|
+ /* NOTREACHED */
|
|
|
+ }
|
|
|
+
|
|
|
+ current_image_ = list_images_->end();
|
|
|
+ current_image_--;
|
|
|
+
|
|
|
+ QString winTitle;
|
|
|
+ winTitle.append("ImageLabeler - ");
|
|
|
+ winTitle.append(*current_image_);
|
|
|
+ setWindowTitle(winTitle);
|
|
|
+
|
|
|
+ image_->load(*current_image_);
|
|
|
+ image_holder_->resize(image_->size());
|
|
|
+ image_holder_->setPixmap(*image_);
|
|
|
+
|
|
|
+ enableTools();
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
ImageLabeler::loadImages()
|
|
|
{
|
|
@@ -1756,7 +1820,7 @@ ImageLabeler::loadLegendFromNode(QDomElement *anElement)
|
|
|
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting legend: "
|
|
|
+ "loadLegendFromNode: "
|
|
|
"label id format is corrupted";
|
|
|
subNode = subNode.nextSibling();
|
|
|
continue;
|
|
@@ -1767,7 +1831,7 @@ ImageLabeler::loadLegendFromNode(QDomElement *anElement)
|
|
|
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting legend: "
|
|
|
+ "loadLegendFromNode: "
|
|
|
"label isMain flag format is corrupted";
|
|
|
subNode = subNode.nextSibling();
|
|
|
continue;
|
|
@@ -1778,7 +1842,7 @@ ImageLabeler::loadLegendFromNode(QDomElement *anElement)
|
|
|
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting legend: "
|
|
|
+ "loadLegendFromNode: "
|
|
|
"label color format is corrupted";
|
|
|
subNode = subNode.nextSibling();
|
|
|
continue;
|
|
@@ -1972,6 +2036,7 @@ ImageLabeler::BBoxFromData(
|
|
|
QString *aBBoxData
|
|
|
)
|
|
|
{
|
|
|
+ qDebug() << *aBBoxData;
|
|
|
BoundingBox bbox;
|
|
|
QString buffer;
|
|
|
bbox.rect.setRect(-1, -1, -1, -1);
|
|
@@ -1987,8 +2052,8 @@ ImageLabeler::BBoxFromData(
|
|
|
int bboxData = buffer.toInt(&ok, 10);
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting objects: "
|
|
|
- "poly format is corrupted";
|
|
|
+ "BBoxFromData: "
|
|
|
+ "bbox format is corrupted";
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -2048,7 +2113,7 @@ ImageLabeler::BBoxFromString(
|
|
|
int bboxID = getNumFromString(aString, "BBox #", ";", &ok);
|
|
|
if (!ok || bboxID <= -1) {
|
|
|
qDebug() <<
|
|
|
- "BBoxFromString: poly ID is corrupted";
|
|
|
+ "BBoxFromString: bboxID is corrupted";
|
|
|
return bbox;
|
|
|
/* NOTREACHED */
|
|
|
}
|
|
@@ -2064,11 +2129,11 @@ ImageLabeler::BBoxFromString(
|
|
|
}
|
|
|
|
|
|
/* getting new points */
|
|
|
- int pointsPos = aString->indexOf("points:") + 7;
|
|
|
+ int pointsPos = aString->indexOf("data:") + 5;
|
|
|
int pointsLen = aString->size() - pointsPos;
|
|
|
if (pointsLen <= 0) {
|
|
|
showWarning(
|
|
|
- tr("new points data is wrong, area can not be changed")
|
|
|
+ tr("new data is wrong, area can not be changed")
|
|
|
);
|
|
|
return bbox;
|
|
|
/* NOTREACHED */
|
|
@@ -2123,7 +2188,7 @@ ImageLabeler::polyFromData(
|
|
|
int polyCoor = buffer.toInt(&ok, 10);
|
|
|
if (!ok) {
|
|
|
qDebug() <<
|
|
|
- "while getting objects: "
|
|
|
+ "polyFromData: "
|
|
|
"poly format is corrupted";
|
|
|
break;
|
|
|
}
|