From 2fcee9db76f500f15d560a169ce4fa518f581b82 Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Thu, 8 Feb 2024 17:11:38 +0100 Subject: [PATCH] Do not show confusion matrix when in command line mode --- confusionmatrix.cpp | 8 +++++--- confusionmatrix.h | 7 ++++++- q3DMASCClassifier.cpp | 10 ++++++++-- q3DMASCClassifier.h | 3 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/confusionmatrix.cpp b/confusionmatrix.cpp index 1e34cd2..cca7ac6 100644 --- a/confusionmatrix.cpp +++ b/confusionmatrix.cpp @@ -32,7 +32,7 @@ QColor getColor(double value, double r1, double g1, double b1) return QColor(r, g, b); } -ConfusionMatrix::ConfusionMatrix(const std::vector &actual, const std::vector &predicted, QWidget *parent) : +ConfusionMatrix::ConfusionMatrix(const std::vector &actual, const std::vector &predicted, QWidget *parent, ccMainAppInterface *app) : QWidget(parent), ui(new Ui::ConfusionMatrix) { @@ -41,11 +41,13 @@ ConfusionMatrix::ConfusionMatrix(const std::vector &actual, const st compute(actual, predicted); - this->show(); + if (app) + { + this->show(); + } this->ui->tableWidget->resizeColumnsToContents(); this->ui->tableWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); QSize tableSize = this->ui->tableWidget->sizeHint(); - QSize labelSize = this->ui->label->sizeHint(); QSize widgetSize = QSize(tableSize.width() + 30, tableSize.height() + 50); this->setMinimumSize(widgetSize); } diff --git a/confusionmatrix.h b/confusionmatrix.h index 25bfc42..1675bea 100644 --- a/confusionmatrix.h +++ b/confusionmatrix.h @@ -5,6 +5,8 @@ #include "CCTypes.h" +#include + #include namespace Ui { @@ -23,7 +25,10 @@ public: F1_SCORE = 2 }; - explicit ConfusionMatrix(const std::vector& actual, const std::vector& predicted, QWidget *parent = nullptr); + explicit ConfusionMatrix( const std::vector& actual, + const std::vector& predicted, + QWidget *parent = nullptr, + ccMainAppInterface* app = nullptr); ~ConfusionMatrix() override; void computePrecisionRecallF1Score(cv::Mat& matrix, cv::Mat& precisionRecallF1Score, cv::Mat &vec_TP_FN); diff --git a/q3DMASCClassifier.cpp b/q3DMASCClassifier.cpp index 0fa1c6f..02e3577 100644 --- a/q3DMASCClassifier.cpp +++ b/q3DMASCClassifier.cpp @@ -110,7 +110,8 @@ static IScalarFieldWrapper::Shared GetSource(const Feature::Source& fs, const cc bool Classifier::classify( const Feature::Source::Set& featureSources, ccPointCloud* cloud, QString& errorMessage, - QWidget* parentWidget/*=nullptr*/ + QWidget* parentWidget/*=nullptr*/, + ccMainAppInterface* app/*nullptr*/ ) { if (!cloud) @@ -278,7 +279,12 @@ bool Classifier::classify( const Feature::Source::Set& featureSources, } if (classifSFBackup != nullptr) - ConfusionMatrix *confusionMatrix = new ConfusionMatrix(*classifSFBackup, *classificationSF); + { + if (app) + { + ConfusionMatrix *confusionMatrix = new ConfusionMatrix(*classifSFBackup, *classificationSF); + } + } return success; } diff --git a/q3DMASCClassifier.h b/q3DMASCClassifier.h index c24611a..e2b313b 100644 --- a/q3DMASCClassifier.h +++ b/q3DMASCClassifier.h @@ -76,7 +76,8 @@ namespace masc bool classify( const Feature::Source::Set& featureSources, ccPointCloud* cloud, QString& errorMessage, - QWidget* parentWidget = nullptr); + QWidget* parentWidget = nullptr, + ccMainAppInterface* app = nullptr); //! Returns whether the classifier is valid or not bool isValid() const;