diff --git a/ContextBasedFeature.cpp b/ContextBasedFeature.cpp index 0da5bf2..ef9b066 100644 --- a/ContextBasedFeature.cpp +++ b/ContextBasedFeature.cpp @@ -26,6 +26,10 @@ //Qt #include +#if defined(_OPENMP) +#include +#endif + using namespace masc; bool ContextBasedFeature::checkValidity(QString corePointRole, QString &error) const @@ -187,6 +191,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints, bool cancelled = false; #ifndef _DEBUG #if defined(_OPENMP) + omp_set_num_threads(std::max(1, omp_get_max_threads() - 2)); #pragma omp parallel for #endif #endif diff --git a/PointFeature.cpp b/PointFeature.cpp index a2bac7a..5e2d56a 100644 --- a/PointFeature.cpp +++ b/PointFeature.cpp @@ -20,6 +20,10 @@ //Local #include "q3DMASCTools.h" +#if defined(_OPENMP) +#include +#endif + //qPDALIO #ifdef PLUGIN_IO_QPDAL #include "../../../core/IO/qPDALIO/include/LASFields.h" @@ -420,6 +424,7 @@ static bool ComputeMathOpWithNearestNeighbor( const CorePoints& corePoints, error.clear(); #ifndef _DEBUG #if defined(_OPENMP) + omp_set_num_threads(std::max(1, omp_get_max_threads() - 2)); #pragma omp parallel for #endif #endif diff --git a/confusionmatrix.cpp b/confusionmatrix.cpp index f96ec12..1e34cd2 100644 --- a/confusionmatrix.cpp +++ b/confusionmatrix.cpp @@ -150,7 +150,7 @@ void ConfusionMatrix::compute(const std::vector& actual, const std:: // get the set of classes with the contents of the actual classes std::set classes(actual.begin(), actual.end()); - int nbClasses = classes.size(); + int nbClasses = static_cast(classes.size()); confusionMatrix = cv::Mat(nbClasses, nbClasses, CV_32S, cv::Scalar(0)); precisionRecallF1Score = cv::Mat(nbClasses, 3, CV_32F, cv::Scalar(0)); cv::Mat vec_TP_FN(nbClasses, 1, CV_32S, cv::Scalar(0)); diff --git a/q3DMASC.cpp b/q3DMASC.cpp index 2d8422c..cf3e2d4 100644 --- a/q3DMASC.cpp +++ b/q3DMASC.cpp @@ -191,7 +191,6 @@ void q3DMASCPlugin::doClassifyAction() } progressDlg.close(); QCoreApplication::processEvents(); - progressDlg.setAutoClose(true); //restore the default behavior of the progress dialog //apply classifier { @@ -423,6 +422,7 @@ void q3DMASCPlugin::doTrainAction() //compute the core points (if necessary) ccProgressDialog progressDlg(true, m_app->getMainWindow()); + progressDlg.setAutoClose(false); if (!corePoints.prepare(&progressDlg)) { m_app->dispToConsole("Failed to compute/prepare the core points!", ccMainAppInterface::ERR_CONSOLE_MESSAGE); @@ -505,7 +505,7 @@ void q3DMASCPlugin::doTrainAction() //prepare the features (should be done once) if (!toPrepare.empty()) { - progressDlg.setAutoClose(false); //we don't want the progress dialog to 'pop' for each feature + progressDlg.show(); QString error; if (!masc::Tools::PrepareFeatures(corePoints, toPrepare, error, &progressDlg, &generatedScalarFields)) { @@ -514,8 +514,7 @@ void q3DMASCPlugin::doTrainAction() generatedScalarFieldsTest.releaseSFs(false); return; } - progressDlg.setAutoClose(true); //restore the default behavior of the progress dialog - progressDlg.hide(); + progressDlg.close(); QCoreApplication::processEvents(); m_app->redrawAll(); @@ -619,7 +618,7 @@ void q3DMASCPlugin::doTrainAction() //prepare the features and the test cloud if (!toPrepareTest.empty()) { - progressDlg.setAutoClose(false); //we don't want the progress dialog to 'pop' for each feature + progressDlg.show(); QString error; masc::CorePoints corePointsTest; corePointsTest.cloud = corePointsTest.origin = testCloud; @@ -631,8 +630,7 @@ void q3DMASCPlugin::doTrainAction() generatedScalarFieldsTest.releaseSFs(false); return; } - progressDlg.setAutoClose(true); //restore the default behavior of the progress dialog - progressDlg.hide(); + progressDlg.close(); QCoreApplication::processEvents(); m_app->redrawAll(); diff --git a/q3DMASCClassifier.cpp b/q3DMASCClassifier.cpp index 9369937..7a7464a 100644 --- a/q3DMASCClassifier.cpp +++ b/q3DMASCClassifier.cpp @@ -42,6 +42,10 @@ #include "qTrain3DMASCDialog.h" #include "confusionmatrix.h" +#if defined(_OPENMP) +#include +#endif + using namespace masc; Classifier::Classifier() @@ -197,9 +201,10 @@ bool Classifier::classify( const Feature::Source::Set& featureSources, CCCoreLib::NormalizedProgress nProgress(pDlg.data(), cloud->size()); bool success = true; - int numberOfTrees = m_rtrees->getRoots().size(); + int numberOfTrees = static_cast(m_rtrees->getRoots().size()); #ifndef _DEBUG #if defined(_OPENMP) + omp_set_num_threads(std::max(1, omp_get_max_threads() - 2)); #pragma omp parallel for #endif #endif @@ -391,7 +396,7 @@ bool Classifier::evaluate(const Feature::Source::Set& featureSources, } } - int numberOfTrees = m_rtrees->getRoots().size(); + int numberOfTrees = static_cast(m_rtrees->getRoots().size()); //estimate the efficiency of the classifier std::vector actualClass(testSampleCount); diff --git a/q3DMASCCommands.h b/q3DMASCCommands.h index 797bcbf..223530b 100644 --- a/q3DMASCCommands.h +++ b/q3DMASCCommands.h @@ -235,7 +235,7 @@ struct Command3DMASCClassif : public ccCommandLineInterface::Command if (pDlg) { pDlg->setAutoClose(true); //restore the default behavior of the progress dialog - pDlg->hide(); + pDlg->close(); QCoreApplication::processEvents(); } diff --git a/q3DMASCTools.cpp b/q3DMASCTools.cpp index 66ff452..68eb972 100644 --- a/q3DMASCTools.cpp +++ b/q3DMASCTools.cpp @@ -39,11 +39,15 @@ #include #include #include -#include +#include //system #include +#include +#if defined(_OPENMP) +#include +#endif using namespace masc; bool Tools::SaveClassifier( QString filename, @@ -430,7 +434,7 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints } else { - ccLog::Warning(QString("ContextBasedFeature: you are using the DEPRECATED syntax, the feature should contain only one cloud, as in DZ1_SC0_CTX_10)").arg(token).arg(lineNumber)); + ccLog::Warning("ContextBasedFeature: you are using the DEPRECATED syntax, the feature should contain only one cloud, as in DZ1_SC0_CTX_10)"); qSharedPointerCast(feature)->ctxClassLabel = classLabel; ++i; } @@ -1202,6 +1206,9 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features if (!octree) { ccLog::Print(QString("Computing octree of cloud %1 (%2 points)").arg(sourceCloud->getName()).arg(sourceCloud->size())); + if (progressCb) + progressCb->start(); + QCoreApplication::processEvents(); octree = sourceCloud->computeOctree(progressCb); if (!octree) { @@ -1228,6 +1235,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features QMutex mutex; #ifndef _DEBUG #if defined(_OPENMP) + omp_set_num_threads(std::max(1, omp_get_max_threads() - 2)); #pragma omp parallel for #endif #endif