New minor enhancements:

-Added actions to show/hide all features of the objects
-Auto adjust size slider to widest added object
-Compare to both size of the scene and object to reject a too large homography
-Removed descriptor/detector label on objects
-Added Refresh GUI time statistic

git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@416 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
matlabbe 2014-12-23 21:22:18 +00:00
parent a96ea6c4f5
commit c879fae867
4 changed files with 93 additions and 32 deletions

View File

@ -98,6 +98,8 @@ private Q_SLOTS:
void updateObjectsSize();
void updateMirrorView();
void showHideControls();
void showObjectsFeatures();
void hideObjectsFeatures();
void updateObjects();
void notifyParametersChanged(const QStringList & param);
void moveCameraFrame(int frame);

View File

@ -1143,8 +1143,10 @@ bool FindObject::detect(const cv::Mat & image, find_object::DetectionInfo & info
// If a point is outside of 2x times the surface of the scene, homography is invalid.
for(int p=0; p<rectH.size(); ++p)
{
if(rectH.at(p).x() < -image.cols || rectH.at(p).x() > image.cols*2 ||
rectH.at(p).y() < -image.rows || rectH.at(p).y() > image.rows*2)
if((rectH.at(p).x() < -image.cols && rectH.at(p).x() < -objectRect.width()) ||
(rectH.at(p).x() > image.cols*2 && rectH.at(p).x() > objectRect.width()*2) ||
(rectH.at(p).y() < -image.rows && rectH.at(p).x() < -objectRect.height()) ||
(rectH.at(p).y() > image.rows*2 && rectH.at(p).x() > objectRect.height()*2))
{
code= DetectionInfo::kRejectedNotValid;
break;

View File

@ -160,7 +160,7 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren
connect(ui_->toolBox, SIGNAL(parametersChanged(const QStringList &)), this, SLOT(notifyParametersChanged(const QStringList &)));
ui_->imageView_source->setGraphicsViewMode(true);
ui_->imageView_source->setTextLabel(tr("Press \"space\" to start the camera..."));
ui_->imageView_source->setTextLabel(tr("Press \"space\" to start the camera or drop an image here..."));
ui_->imageView_source->setMirrorView(Settings::getGeneral_mirrorView());
connect((QCheckBox*)ui_->toolBox->getParameterWidget(Settings::kGeneral_mirrorView()),
SIGNAL(stateChanged(int)),
@ -200,6 +200,8 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
connect(ui_->actionSave_settings, SIGNAL(triggered()), this, SLOT(saveSettings()));
connect(ui_->actionLoad_settings, SIGNAL(triggered()), this, SLOT(loadSettings()));
connect(ui_->actionShow_objects_features, SIGNAL(triggered()), this, SLOT(showObjectsFeatures()));
connect(ui_->actionHide_objects_features, SIGNAL(triggered()), this, SLOT(hideObjectsFeatures()));
connect(ui_->pushButton_play, SIGNAL(clicked()), this, SLOT(startProcessing()));
connect(ui_->pushButton_stop, SIGNAL(clicked()), this, SLOT(stopProcessing()));
@ -528,6 +530,22 @@ void MainWindow::showHideControls()
ui_->widget_controls->setVisible(Settings::getGeneral_controlsShown());
}
void MainWindow::showObjectsFeatures()
{
for(QMap<int, ObjWidget*>::iterator iter=objWidgets_.begin(); iter!=objWidgets_.end(); ++iter)
{
iter.value()->setFeaturesShown(true);
}
}
void MainWindow::hideObjectsFeatures()
{
for(QMap<int, ObjWidget*>::iterator iter=objWidgets_.begin(); iter!=objWidgets_.end(); ++iter)
{
iter.value()->setFeaturesShown(false);
}
}
void MainWindow::addObjectFromScene()
{
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
@ -553,8 +571,6 @@ void MainWindow::addObjectFromScene()
objWidgets_.insert(obj->id(), obj);
ui_->actionSave_objects->setEnabled(true);
showObject(obj);
QLabel * detectorDescriptorType = qFindChild<QLabel*>(this, QString("%1type").arg(obj->id()));
detectorDescriptorType->setText(QString("%1/%2").arg(signature->detectorType()).arg(signature->descriptorType()));
updateVocabulary();
objectsModified_ = true;
}
@ -747,15 +763,12 @@ void MainWindow::showObject(ObjWidget * obj)
ui_->toolBox->updateParameter(Settings::kGeneral_nextObjID());
QLabel * title = new QLabel(QString("%1 (%2)").arg(obj->id()).arg(obj->keypoints().size()), this);
QLabel * detectorDescriptorType = new QLabel(QString("%1/%2").arg("detector").arg("descriptor"), this);
QLabel * detectedLabel = new QLabel(this);
title->setObjectName(QString("%1title").arg(obj->id()));
detectorDescriptorType->setObjectName(QString("%1type").arg(obj->id()));
detectedLabel->setObjectName(QString("%1detection").arg(obj->id()));
QHBoxLayout * hLayout = new QHBoxLayout();
hLayout->addWidget(title);
hLayout->addStretch(1);
hLayout->addWidget(detectorDescriptorType);
hLayout->addStretch(1);
hLayout->addWidget(detectedLabel);
vLayout->addLayout(hLayout);
@ -764,7 +777,6 @@ void MainWindow::showObject(ObjWidget * obj)
connect(obj, SIGNAL(removalTriggered(find_object::ObjWidget*)), this, SLOT(removeObject(find_object::ObjWidget*)));
connect(obj, SIGNAL(destroyed(QObject *)), title, SLOT(deleteLater()));
connect(obj, SIGNAL(destroyed(QObject *)), detectedLabel, SLOT(deleteLater()));
connect(obj, SIGNAL(destroyed(QObject *)), detectorDescriptorType, SLOT(deleteLater()));
connect(obj, SIGNAL(destroyed(QObject *)), vLayout, SLOT(deleteLater()));
ui_->verticalLayout_objects->insertLayout(ui_->verticalLayout_objects->count()-1, vLayout);
@ -774,7 +786,16 @@ void MainWindow::showObject(ObjWidget * obj)
obj->pixmap().scaledToWidth(128).save(&buffer, "JPEG"); // writes image into JPEG format
imagesMap_.insert(obj->id(), ba);
updateObjectSize(obj);
// update objects size slider
int objectsPanelWidth = ui_->dockWidget_objects->width();
if(objectsPanelWidth > 0 && (obj->pixmap().width()*ui_->horizontalSlider_objectsSize->value()) / 100 > objectsPanelWidth)
{
ui_->horizontalSlider_objectsSize->setValue((objectsPanelWidth * 100) / obj->pixmap().width());
}
else
{
updateObjectSize(obj);
}
}
}
@ -795,8 +816,6 @@ void MainWindow::updateObjects()
//update object labels
QLabel * title = qFindChild<QLabel*>(this, QString("%1title").arg(signatures[i]->id()));
title->setText(QString("%1 (%2)").arg(signatures[i]->id()).arg(QString::number(signatures[i]->keypoints().size())));
QLabel * detectorDescriptorType = qFindChild<QLabel*>(this, QString("%1type").arg(signatures[i]->id()));
detectorDescriptorType->setText(QString("%1/%2").arg(signatures[i]->detectorType()).arg(signatures[i]->descriptorType()));
}
if(!camera_->isRunning() && !sceneImage_.empty())
@ -969,9 +988,12 @@ void MainWindow::update(const cv::Mat & image)
iter.value()->resetKptsColor();
}
QTime guiRefreshTime;
DetectionInfo info;
if(findObject_->detect(sceneImage_, info))
{
guiRefreshTime.start();
ui_->label_timeDetection->setNum(info.timeStamps_.value(DetectionInfo::kTimeKeypointDetection, 0));
ui_->label_timeSkewAffine->setNum(info.timeStamps_.value(DetectionInfo::kTimeSkewAffine, 0));
ui_->label_timeExtraction->setNum(info.timeStamps_.value(DetectionInfo::kTimeDescriptorExtraction, 0));
@ -1166,6 +1188,8 @@ void MainWindow::update(const cv::Mat & image)
}
else
{
guiRefreshTime.start();
if(findObject_->vocabulary()->size())
{
this->statusBar()->showMessage(tr("Cannot search, objects must be updated!"));
@ -1217,6 +1241,8 @@ void MainWindow::update(const cv::Mat & image)
lowestRefreshRate_ = 99;
refreshStartTime_.start();
}
ui_->label_timeRefreshGUI->setNum(guiRefreshTime.elapsed());
}
void MainWindow::notifyParametersChanged(const QStringList & paramChanged)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>881</width>
<height>523</height>
<height>536</height>
</rect>
</property>
<property name="windowTitle">
@ -251,6 +251,9 @@
<property name="title">
<string>View</string>
</property>
<addaction name="actionHide_objects_features"/>
<addaction name="actionShow_objects_features"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu">
<property name="title">
@ -361,8 +364,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>206</width>
<height>396</height>
<width>222</width>
<height>409</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_objects">
@ -426,9 +429,6 @@
</layout>
</item>
</layout>
<zorder></zorder>
<zorder>verticalSpacer</zorder>
<zorder>objects_area</zorder>
</widget>
</item>
</layout>
@ -514,28 +514,28 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLabel" name="label_minMatchedDistance">
<property name="text">
<string>000</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Min matched distance</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Max matched distance</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLabel" name="label_maxMatchedDistance">
<property name="text">
<string>000</string>
@ -619,56 +619,56 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Vocabulary size</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLabel" name="label_vocabularySize">
<property name="text">
<string>000</string>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>IP address</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Output detection port</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QLabel" name="label_ipAddress">
<property name="text">
<string>0.0.0.0</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QLabel" name="label_port">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Objects detected</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QLabel" name="label_objectsDetected">
<property name="text">
<string>000</string>
@ -682,14 +682,14 @@
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Input image port</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QLabel" name="label_port_image">
<property name="text">
<string>-</string>
@ -717,6 +717,27 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Refresh GUI</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_timeRefreshGUI">
<property name="text">
<string>000</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_25">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -829,6 +850,16 @@
<string>Camera from TCP/IP...</string>
</property>
</action>
<action name="actionHide_objects_features">
<property name="text">
<string>Hide objects features</string>
</property>
</action>
<action name="actionShow_objects_features">
<property name="text">
<string>Show objects features</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>