Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ To minimize wrist strain when labeling, I adopted the method **"twice left butto

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

## USAGE AND OPTIONS
```
./YoloLabel [dataset dir] [class file names]
# Example
./YoloLabel ../project/dataset/objects/frames ../project/dataset/objects/obj_names.txt

```


## SHORTCUTS

| Key | Action |
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.set_args(argc, argv);
w.show();
return a.exec();
}
Expand Down
59 changes: 39 additions & 20 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ MainWindow::~MainWindow()
delete ui;
}

void MainWindow::set_args(int argc, char *argv[])
{
if (argc > 1) {
QString dir = QString::fromLocal8Bit(argv[1]);
get_files(dir);
if (argc > 2) {
QString obj_file = QString::fromLocal8Bit(argv[2]);
load_label_list_data(obj_file);
}
init();
}
}


void MainWindow::on_pushButton_open_files_clicked()
{
bool bRetImgDir = false;
Expand Down Expand Up @@ -295,20 +309,9 @@ void MainWindow::pjreddie_style_msgBox(QMessageBox::Icon icon, QString title, QS
msgBox.exec();
}

void MainWindow::open_img_dir(bool& ret)
bool MainWindow::get_files(QString imgDir)
{
pjreddie_style_msgBox(QMessageBox::Information,"Help", "Step 1. Open Your Data Set Directory");

QString opened_dir;
if(m_imgDir.size() > 0) opened_dir = m_imgDir;
else opened_dir = QDir::currentPath();

QString imgDir = QFileDialog::getExistingDirectory(
nullptr,
tr("Open Dataset Directory"),
opened_dir,
QFileDialog::ShowDirsOnly);

bool value = false;
QDir dir(imgDir);
QCollator collator;
collator.setNumericMode(true);
Expand All @@ -319,20 +322,36 @@ void MainWindow::open_img_dir(bool& ret)

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

if(fileList.empty())
{
ret = false;
pjreddie_style_msgBox(QMessageBox::Critical,"Error", "This folder is empty");
}
else
if(!fileList.empty())
{
ret = true;
value = true;
m_imgDir = imgDir;
m_imgList = fileList;

for(QString& str: m_imgList)
str = m_imgDir + "/" + str;
}
return value;
}

void MainWindow::open_img_dir(bool& ret)
{
pjreddie_style_msgBox(QMessageBox::Information,"Help", "Step 1. Open Your Data Set Directory");

QString opened_dir;
if(m_imgDir.size() > 0) opened_dir = m_imgDir;
else opened_dir = QDir::currentPath();

QString imgDir = QFileDialog::getExistingDirectory(
nullptr,
tr("Open Dataset Directory"),
opened_dir,
QFileDialog::ShowDirsOnly);


ret = get_files(imgDir);
if (!ret)
pjreddie_style_msgBox(QMessageBox::Critical,"Error", "This folder is empty");
}

void MainWindow::open_obj_file(bool& ret)
Expand Down
4 changes: 4 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
void set_args(int argc, char *argv[]);


private slots:
void on_pushButton_open_files_clicked();
Expand Down Expand Up @@ -79,9 +81,11 @@ private slots:
int m_objIndex;
int m_lastDeletedImgIndex;
int m_lastLabeledImgIndex;
bool get_files(QString imgDir);

protected:
void wheelEvent(QWheelEvent *);

};

#endif // MAINWINDOW_H