Commit 56197f413d318dae75278c565962a8384df270ea

Authored by Josh Klontz
2 parents 0e3748c6 a7529302

Merge pull request #267 from biometrics/load_local

give precedence to loading local/relative files
Showing 1 changed file with 9 additions and 9 deletions
openbr/core/core.cpp
... ... @@ -513,15 +513,15 @@ private:
513 513 // Check if description is either an abbreviation or a model file, if so load it
514 514 bool loadOrExpand(const QString &description)
515 515 {
516   - // Check if a trained binary already exists for this algorithm
517   - QString file = Globals->sdkPath + "/share/openbr/models/algorithms/" + description;
518   - QFileInfo eFile(file);
519   - file = eFile.exists() && !eFile.isDir() ? file : description;
520   -
521   - QFileInfo dFile(file);
522   - if (dFile.exists() && !dFile.isDir()) {
523   - qDebug("Loading %s", qPrintable(dFile.canonicalFilePath()));
524   - load(file);
  516 + // Check if a trained binary already exists for this algorithm,
  517 + // giving priority to local files before defaulting to openbr/share/models/algorithms.
  518 + QFileInfo fileInfo(description);
  519 + if (!fileInfo.exists() || fileInfo.isDir())
  520 + fileInfo = QFileInfo(Globals->sdkPath + "/share/openbr/models/algorithms/" + description);
  521 + if (fileInfo.exists() && !fileInfo.isDir()) {
  522 + const QString filePath = fileInfo.canonicalFilePath();
  523 + qDebug("Loading %s", qPrintable(filePath));
  524 + load(filePath);
525 525 return true;
526 526 }
527 527  
... ...