diff --git a/q3DMASC.cpp b/q3DMASC.cpp index fddb2a8..489fcd9 100644 --- a/q3DMASC.cpp +++ b/q3DMASC.cpp @@ -134,17 +134,31 @@ void q3DMASCPlugin::doTrainAction() features.push_back(Feature::Shared(new PointFeature(cloud, PointFeature::Intensity, Feature::ScalarField, "Intensity"))); } - masc::Classifier classifier; - QString errorMessage; - if (!classifier.train(params, features, errorMessage, m_app->getMainWindow())) - { - m_app->dispToConsole(errorMessage); - return; - } - - //save the classifier QString outputFilename = QCoreApplication::applicationDirPath() + "/classifier.yaml"; - classifier.toFile(outputFilename, m_app->getMainWindow()); + + masc::Classifier classifier; + if (QFile(outputFilename).exists()) + { + if (!classifier.fromFile(outputFilename, m_app->getMainWindow())) + { + m_app->dispToConsole("Failed to load previous classifier file", ccMainAppInterface::ERR_CONSOLE_MESSAGE); + return; + } + m_app->dispToConsole("Previous classifier loaded", ccMainAppInterface::WRN_CONSOLE_MESSAGE); + } + else + { + QString errorMessage; + if (!classifier.train(params, features, errorMessage, m_app->getMainWindow())) + { + m_app->dispToConsole(errorMessage, ccMainAppInterface::ERR_CONSOLE_MESSAGE); + return; + } + + //save the classifier + classifier.toFile(outputFilename, m_app->getMainWindow()); + m_app->dispToConsole("Classifier succesfully created", ccMainAppInterface::WRN_CONSOLE_MESSAGE); + } } void q3DMASCPlugin::registerCommands(ccCommandLineInterface* cmd) diff --git a/q3DMASCClassifier.cpp b/q3DMASCClassifier.cpp index 58a3ca8..02f069d 100644 --- a/q3DMASCClassifier.cpp +++ b/q3DMASCClassifier.cpp @@ -328,7 +328,7 @@ bool Classifier::fromFile(QString filename, QWidget* parentWidget/*=nullptr*/) //load the classifier QProgressDialog pDlg(parentWidget); pDlg.setRange(0, 0); //infinite loop - pDlg.setLabelText(QObject::tr("Saving classifier")); + pDlg.setLabelText(QObject::tr("Loading classifier")); pDlg.show(); QCoreApplication::processEvents();