Skip to content

Commit 4c50ace

Browse files
author
pipothebit
committed
A simple and dirty modification to launch the application with the directory and class file set and start working directly on image tagging.
Signed-off-by: pipothebit <[email protected]>
1 parent 62f22a6 commit 4c50ace

File tree

4 files changed

+53
-20
lines changed

4 files changed

+53
-20
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ To minimize wrist strain when labeling, I adopted the method **"twice left butto
139139

140140
![endimage](https://user-images.githubusercontent.com/35001605/47704336-a6528180-dc66-11e8-8551-3ecb612b7353.PNG)
141141

142+
## USAGE AND OPTIONS
143+
```
144+
./YoloLabel [dataset dir] [class file names]
145+
# Example
146+
./YoloLabel ../project/dataset/objects/frames ../project/dataset/objects/obj_names.txt
147+
148+
```
149+
150+
142151
## SHORTCUTS
143152

144153
| Key | Action |

main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ int main(int argc, char *argv[])
55
{
66
QApplication a(argc, argv);
77
MainWindow w;
8+
w.set_args(argc, argv);
89
w.show();
910
return a.exec();
1011
}

mainwindow.cpp

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ MainWindow::~MainWindow()
4141
delete ui;
4242
}
4343

44+
void MainWindow::set_args(int argc, char *argv[])
45+
{
46+
if (argc > 1) {
47+
QString dir = QString::fromLocal8Bit(argv[1]);
48+
get_files(dir);
49+
if (argc > 2) {
50+
QString obj_file = QString::fromLocal8Bit(argv[2]);
51+
load_label_list_data(obj_file);
52+
}
53+
init();
54+
}
55+
}
56+
57+
4458
void MainWindow::on_pushButton_open_files_clicked()
4559
{
4660
bool bRetImgDir = false;
@@ -295,20 +309,9 @@ void MainWindow::pjreddie_style_msgBox(QMessageBox::Icon icon, QString title, QS
295309
msgBox.exec();
296310
}
297311

298-
void MainWindow::open_img_dir(bool& ret)
312+
bool MainWindow::get_files(QString imgDir)
299313
{
300-
pjreddie_style_msgBox(QMessageBox::Information,"Help", "Step 1. Open Your Data Set Directory");
301-
302-
QString opened_dir;
303-
if(m_imgDir.size() > 0) opened_dir = m_imgDir;
304-
else opened_dir = QDir::currentPath();
305-
306-
QString imgDir = QFileDialog::getExistingDirectory(
307-
nullptr,
308-
tr("Open Dataset Directory"),
309-
opened_dir,
310-
QFileDialog::ShowDirsOnly);
311-
314+
bool value = false;
312315
QDir dir(imgDir);
313316
QCollator collator;
314317
collator.setNumericMode(true);
@@ -319,20 +322,36 @@ void MainWindow::open_img_dir(bool& ret)
319322

320323
std::sort(fileList.begin(), fileList.end(), collator);
321324

322-
if(fileList.empty())
323-
{
324-
ret = false;
325-
pjreddie_style_msgBox(QMessageBox::Critical,"Error", "This folder is empty");
326-
}
327-
else
325+
if(!fileList.empty())
328326
{
329-
ret = true;
327+
value = true;
330328
m_imgDir = imgDir;
331329
m_imgList = fileList;
332330

333331
for(QString& str: m_imgList)
334332
str = m_imgDir + "/" + str;
335333
}
334+
return value;
335+
}
336+
337+
void MainWindow::open_img_dir(bool& ret)
338+
{
339+
pjreddie_style_msgBox(QMessageBox::Information,"Help", "Step 1. Open Your Data Set Directory");
340+
341+
QString opened_dir;
342+
if(m_imgDir.size() > 0) opened_dir = m_imgDir;
343+
else opened_dir = QDir::currentPath();
344+
345+
QString imgDir = QFileDialog::getExistingDirectory(
346+
nullptr,
347+
tr("Open Dataset Directory"),
348+
opened_dir,
349+
QFileDialog::ShowDirsOnly);
350+
351+
352+
ret = get_files(imgDir);
353+
if (!ret)
354+
pjreddie_style_msgBox(QMessageBox::Critical,"Error", "This folder is empty");
336355
}
337356

338357
void MainWindow::open_obj_file(bool& ret)

mainwindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class MainWindow : public QMainWindow
2020
public:
2121
explicit MainWindow(QWidget *parent = nullptr);
2222
~MainWindow();
23+
void set_args(int argc, char *argv[]);
24+
2325

2426
private slots:
2527
void on_pushButton_open_files_clicked();
@@ -79,9 +81,11 @@ private slots:
7981
int m_objIndex;
8082
int m_lastDeletedImgIndex;
8183
int m_lastLabeledImgIndex;
84+
bool get_files(QString imgDir);
8285

8386
protected:
8487
void wheelEvent(QWheelEvent *);
88+
8589
};
8690

8791
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)