If a config file is set on arguments (or if there are custom parameters), parameters overwrite those in a loaded session.
This commit is contained in:
+10
-2
@@ -74,7 +74,7 @@ FindObject::~FindObject() {
|
||||
objectsDescriptors_.clear();
|
||||
}
|
||||
|
||||
bool FindObject::loadSession(const QString & path)
|
||||
bool FindObject::loadSession(const QString & path, const ParametersMap & customParameters)
|
||||
{
|
||||
if(QFile::exists(path) && !path.isEmpty() && QFileInfo(path).suffix().compare("bin") == 0)
|
||||
{
|
||||
@@ -88,7 +88,15 @@ bool FindObject::loadSession(const QString & path)
|
||||
in >> parameters;
|
||||
for(QMap<QString, QVariant>::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
|
||||
{
|
||||
Settings::setParameter(iter.key(), iter.value());
|
||||
QMap<QString, QVariant>::const_iterator cter = customParameters.find(iter.key());
|
||||
if(cter != customParameters.constEnd())
|
||||
{
|
||||
Settings::setParameter(cter.key(), cter.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings::setParameter(iter.key(), iter.value());
|
||||
}
|
||||
}
|
||||
|
||||
// load vocabulary
|
||||
|
||||
+6
-3
@@ -94,14 +94,15 @@ QString Settings::iniPath()
|
||||
return iniDefaultPath();
|
||||
}
|
||||
|
||||
void Settings::init(const QString & fileName)
|
||||
ParametersMap Settings::init(const QString & fileName)
|
||||
{
|
||||
iniPath_ = fileName;
|
||||
loadSettings(iniPath_);
|
||||
return loadSettings(iniPath_);
|
||||
}
|
||||
|
||||
void Settings::loadSettings(const QString & fileName)
|
||||
ParametersMap Settings::loadSettings(const QString & fileName)
|
||||
{
|
||||
ParametersMap loadedParameters;
|
||||
QString path = fileName;
|
||||
if(fileName.isEmpty())
|
||||
{
|
||||
@@ -173,6 +174,7 @@ void Settings::loadSettings(const QString & fileName)
|
||||
value = QVariant(str);
|
||||
#endif
|
||||
}
|
||||
loadedParameters.insert(key, value);
|
||||
setParameter(key, value);
|
||||
}
|
||||
}
|
||||
@@ -193,6 +195,7 @@ void Settings::loadSettings(const QString & fileName)
|
||||
Settings::setFeature2D_ORB_gpu(false);
|
||||
Settings::setNearestNeighbor_BruteForce_gpu(false);
|
||||
}
|
||||
return loadedParameters;
|
||||
}
|
||||
|
||||
void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & windowState, const QString & fileName)
|
||||
|
||||
Reference in New Issue
Block a user