Skip to content

Commit

Permalink
add goto next instance of class (inefficient)
Browse files Browse the repository at this point in the history
  • Loading branch information
jveitchmichaelis committed Jun 4, 2019
1 parent 33950ae commit 94aca98
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
24 changes: 24 additions & 0 deletions src/labelproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,30 @@ int LabelProject::getNextUnlabelled(QString fileName){
return -1;
}

int LabelProject::getNextInstance(QString fileName, QString className){
/*!
* Returns the index of the next unlabelled image, after \a fileName
*/
QList<QString> images;
getImageList(images);

int i = images.indexOf(fileName);
QList<BoundingBox> bboxes;

for(i += 1; i < images.size(); i++){
bboxes.clear();
getLabels(images.at(i), bboxes);

for(auto bbox : bboxes){
if(bbox.classname == className){
return i;
}
}
}

return -1;
}

bool LabelProject::removeImage(QString fileName){

/*!
Expand Down
2 changes: 2 additions & 0 deletions src/labelproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class LabelProject : public QObject
bool setOccluded(QString fileName, BoundingBox bbox, int occluded);

int getNextUnlabelled(QString fileName);
int getNextInstance(QString fileName, QString className);

//QString getClassName(int classId);
int getImageId(QString fileName);
Expand All @@ -66,6 +67,7 @@ public slots:
int addImageFolder(QString path);
void cancelLoad();
void addFolderRecursive(QString path_filter);

private:
QSqlDatabase db;
QMutex mutex;
Expand Down
10 changes: 10 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->refineTrackingCheckbox, SIGNAL(clicked(bool)), this, SLOT(toggleRefineTracking(bool)));

connect(ui->nextUnlabelledButton, SIGNAL(clicked(bool)), this, SLOT(nextUnlabelled()));
connect(ui->nextInstanceButton, SIGNAL(clicked(bool)), this, SLOT(nextInstance()));

display = new ImageDisplay;
ui->imageDisplayLayout->addWidget(display);
Expand Down Expand Up @@ -462,6 +463,15 @@ void MainWindow::nextUnlabelled(){
}
}

void MainWindow::nextInstance(void){
int n = project->getNextInstance(current_imagepath, current_class);

if(n != -1){
ui->imageNumberSpinbox->setValue(n+1);
updateDisplay();
}
}

QRect MainWindow::refineBoundingBoxSimple(cv::Mat image, QRect bbox, int margin, bool debug_save){
QMargins margins(margin, margin, margin, margin);
bbox += margins;
Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ private slots:
void toggleAutoPropagate(bool state);
void toggleRefineTracking(bool state);
void nextUnlabelled();
void nextInstance();

QRect refineBoundingBox(cv::Mat image, QRect bbox, int margin=5, bool debug_save=false);
QRect refineBoundingBoxSimple(cv::Mat image, QRect bbox, int margin=5, bool debug_save=false);
void refineBoxes();
Expand All @@ -125,6 +127,7 @@ private slots:
void setConfidenceThreshold();
void setNMSThreshold();


signals:
void selectedClass(QString);

Expand Down
27 changes: 17 additions & 10 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QComboBox" name="classComboBox"/>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="removeClassButton">
<property name="text">
<string>Remove class</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLineEdit" name="newClassText">
<property name="text">
Expand All @@ -189,6 +179,23 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QComboBox" name="classComboBox"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="removeClassButton">
<property name="text">
<string>Remove class</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="nextInstanceButton">
<property name="text">
<string>Next instance</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 94aca98

Please sign in to comment.