Fixed wrong detector index chosen when reading ini if index is over 9.

This commit is contained in:
matlabbe 2020-01-08 17:41:24 -05:00
parent 5489d5f4c4
commit aefb42dc57

View File

@ -123,54 +123,51 @@ ParametersMap Settings::loadSettings(const QString & fileName)
if(str.size() != getParameter(key).toString().size()) if(str.size() != getParameter(key).toString().size())
{ {
// If a string list is modified, update the value // If a string list is modified, update the value
// (assuming that index < 10... one character for index) // Assuming format ##:VA;VB;VC
QChar index = str.at(0); int index = str.split(':').first().toInt();
str = getParameter(key).toString(); str = getParameter(key).toString();
str[0] = index.toLatin1(); str = QString::number(index)+":"+ str.split(':').back();
value = QVariant(str); value = QVariant(str);
UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str()); UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str());
} }
#if FINDOBJECT_NONFREE == 0 #if FINDOBJECT_NONFREE == 0
QChar index = str.at(0); int index = str.split(':').first().toInt();
if(key.compare(Settings::kFeature2D_1Detector()) == 0) if(key.compare(Settings::kFeature2D_1Detector()) == 0)
{ {
if(index == '5' || index == '7') if(index == 5 || index == 7)
{ {
index = Settings::defaultFeature2D_1Detector().at(0); index = Settings::defaultFeature2D_1Detector().split(':').first().toInt();
int indexInt = Settings::defaultFeature2D_1Detector().split(':').first().toInt();
UWARN("Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built " UWARN("Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built "
"with the nonfree module from OpenCV. Keeping default combo value: %s.", "with the nonfree module from OpenCV. Keeping default combo value: %s.",
Settings::kFeature2D_1Detector().toStdString().c_str(), Settings::kFeature2D_1Detector().toStdString().c_str(),
Settings::defaultFeature2D_1Detector().split(':').last().split(";").at(indexInt).toStdString().c_str()); Settings::defaultFeature2D_1Detector().split(':').last().split(";").at(index).toStdString().c_str());
} }
} }
else if(key.compare(Settings::kFeature2D_2Descriptor()) == 0) else if(key.compare(Settings::kFeature2D_2Descriptor()) == 0)
{ {
if(index == '2' || index == '3') if(index == 2 || index == 3)
{ {
index = Settings::defaultFeature2D_2Descriptor().at(0); index = Settings::defaultFeature2D_2Descriptor().split(':').first().toInt();
int indexInt = Settings::defaultFeature2D_2Descriptor().split(':').first().toInt();
UWARN("Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built " UWARN("Trying to set \"%s\" to SIFT/SURF but Find-Object isn't built "
"with the nonfree module from OpenCV. Keeping default combo value: %s.", "with the nonfree module from OpenCV. Keeping default combo value: %s.",
Settings::kFeature2D_2Descriptor().toStdString().c_str(), Settings::kFeature2D_2Descriptor().toStdString().c_str(),
Settings::defaultFeature2D_2Descriptor().split(':').last().split(";").at(indexInt).toStdString().c_str()); Settings::defaultFeature2D_2Descriptor().split(':').last().split(";").at(index).toStdString().c_str());
} }
} }
else if(key.compare(Settings::kNearestNeighbor_1Strategy()) == 0) else if(key.compare(Settings::kNearestNeighbor_1Strategy()) == 0)
{ {
if(index <= '4') if(index <= 4)
{ {
index = Settings::defaultNearestNeighbor_1Strategy().at(0); index = Settings::defaultNearestNeighbor_1Strategy().split(':').first().toInt();
int indexInt = Settings::defaultNearestNeighbor_1Strategy().split(':').first().toInt();
UWARN("Trying to set \"%s\" to one FLANN approach but Find-Object isn't built " UWARN("Trying to set \"%s\" to one FLANN approach but Find-Object isn't built "
"with the nonfree module from OpenCV and FLANN cannot be used " "with the nonfree module from OpenCV and FLANN cannot be used "
"with binary descriptors. Keeping default combo value: %s.", "with binary descriptors. Keeping default combo value: %s.",
Settings::kNearestNeighbor_1Strategy().toStdString().c_str(), Settings::kNearestNeighbor_1Strategy().toStdString().c_str(),
Settings::defaultNearestNeighbor_1Strategy().split(':').last().split(";").at(indexInt).toStdString().c_str()); Settings::defaultNearestNeighbor_1Strategy().split(':').last().split(";").at(index).toStdString().c_str());
} }
} }
str = getParameter(key).toString(); str = getParameter(key).toString();
str[0] = index.toLatin1(); str = QString::number(index)+":"+ str.split(':').back();
value = QVariant(str); value = QVariant(str);
#endif #endif
} }