Homography: added maxIterations and configences parameters (OpenCV3). Updated doubleSpinBox decimals/singleStep.

This commit is contained in:
matlabbe 2017-04-27 14:40:04 -04:00
parent 419a8a6f51
commit ca1e1dccde
5 changed files with 69 additions and 3 deletions

View File

@ -73,6 +73,7 @@ public:
protected:
virtual void closeEvent(QCloseEvent * event);
virtual void keyPressEvent(QKeyEvent *event);
public Q_SLOTS:
void startProcessing();

View File

@ -288,7 +288,11 @@ class FINDOBJECT_EXP Settings
PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected.");
PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC;RHO", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm.");
PARAMETER(Homography, ransacReprojThr, double, 5.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10.");
PARAMETER(Homography, ransacReprojThr, double, 3.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10.");
#if CV_MAJOR_VERSION >= 3
PARAMETER(Homography, maxIterations, int, 2000, "The maximum number of RANSAC iterations, 2000 is the maximum it can be.");
PARAMETER(Homography, confidence, double, 0.995, "Confidence level, between 0 and 1.");
#endif
PARAMETER(Homography, minimumInliers, int, 10, "Minimum inliers to accept the homography. Value must be >= 4.");
PARAMETER(Homography, ignoreWhenAllInliers, bool, false, "Ignore homography when all features are inliers (sometimes when the homography doesn't converge, it returns the best homography with all features as inliers).");
PARAMETER(Homography, rectBorderWidth, int, 4, "Homography rectangle border width.");

View File

@ -1251,11 +1251,21 @@ protected:
}
UDEBUG("Find homography... begin");
#if CV_MAJOR_VERSION < 3
h_ = findHomography(mpts_1,
mpts_2,
Settings::getHomographyMethod(),
Settings::getHomography_ransacReprojThr(),
outlierMask_);
#else
h_ = findHomography(mpts_1,
mpts_2,
Settings::getHomographyMethod(),
Settings::getHomography_ransacReprojThr(),
outlierMask_,
Settings::getHomography_maxIterations(),
Settings::getHomography_confidence());
#endif
UDEBUG("Find homography... end");
UASSERT(outlierMask_.size() == 0 || outlierMask_.size() == mpts_1.size());

View File

@ -272,6 +272,8 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren
//Setup drag and drop images
connect(ui_->imageDrop_objects, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(addObjectsFromFiles(const QStringList &)));
connect(ui_->imageDrop_scene, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(loadSceneFromFile(const QStringList &)));
ui_->imageView_source->setFocus();
}
MainWindow::~MainWindow()
@ -316,6 +318,22 @@ void MainWindow::closeEvent(QCloseEvent * event)
}
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
//catch ctrl-s to save settings
if(event->key() == Qt::Key_Space)
{
if(ui_->actionStart_camera->isEnabled())
{
startProcessing();
}
else if(ui_->actionPause_camera->isEnabled())
{
pauseProcessing();
}
}
}
void MainWindow::setupTCPServer()
{
if(tcpServer_)

View File

@ -420,14 +420,47 @@ void ParametersToolBox::addParameter(QVBoxLayout * layout,
const double & value)
{
QDoubleSpinBox * widget = new QDoubleSpinBox(this);
int decimals = 0;
int decimalValue = 0;
QString str = QString::number(Settings::getDefaultParameters().value(key).toDouble());
str.remove( QRegExp("0+$") );
if(!str.isEmpty())
{
str.replace(',', '.');
QStringList items = str.split('.');
if(items.size() == 2)
{
decimals = items.back().length();
decimalValue = items.back().toInt();
}
}
double def = Settings::getDefaultParameters().value(key).toDouble();
if(def<0.01)
if(def<0.001 || (decimals >= 4 && decimalValue>0))
{
widget->setDecimals(5);
widget->setSingleStep(0.0001);
}
else if(def<0.01 || (decimals >= 3 && decimalValue>0))
{
widget->setDecimals(4);
widget->setSingleStep(0.001);
}
else if(def<0.1)
else if(def<0.1 || (decimals >= 2 && decimalValue>0))
{
widget->setDecimals(3);
widget->setSingleStep(0.01);
}
else if(def<1.0 || (decimals >= 1 && decimalValue>0))
{
widget->setDecimals(2);
widget->setSingleStep(0.1);
}
else
{
widget->setDecimals(1);
}
if(def>0.0)