Merge pull request #4 from p-leroy/master

do not show confusion matrix when in command line mode
This commit is contained in:
Paul Leroy
2024-02-09 14:41:27 +01:00
committed by GitHub
5 changed files with 28 additions and 11 deletions
+5 -3
View File
@@ -32,7 +32,7 @@ QColor getColor(double value, double r1, double g1, double b1)
return QColor(r, g, b);
}
ConfusionMatrix::ConfusionMatrix(const std::vector<ScalarType> &actual, const std::vector<ScalarType> &predicted, QWidget *parent) :
ConfusionMatrix::ConfusionMatrix(const std::vector<ScalarType> &actual, const std::vector<ScalarType> &predicted, QWidget *parent, ccMainAppInterface *app) :
QWidget(parent),
ui(new Ui::ConfusionMatrix)
{
@@ -41,11 +41,13 @@ ConfusionMatrix::ConfusionMatrix(const std::vector<ScalarType> &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);
}
+6 -1
View File
@@ -5,6 +5,8 @@
#include "CCTypes.h"
#include <ccMainAppInterface.h>
#include <opencv2/core/mat.hpp>
namespace Ui {
@@ -23,7 +25,10 @@ public:
F1_SCORE = 2
};
explicit ConfusionMatrix(const std::vector<ScalarType>& actual, const std::vector<ScalarType>& predicted, QWidget *parent = nullptr);
explicit ConfusionMatrix( const std::vector<ScalarType>& actual,
const std::vector<ScalarType>& predicted,
QWidget *parent = nullptr,
ccMainAppInterface* app = nullptr);
~ConfusionMatrix() override;
void computePrecisionRecallF1Score(cv::Mat& matrix, cv::Mat& precisionRecallF1Score, cv::Mat &vec_TP_FN);
+2 -1
View File
@@ -653,7 +653,8 @@ void q3DMASCPlugin::doTrainAction()
trainDlg,
testCloud ? nullptr : testSubset.data(),
testCloud ? "Classification_prediction" : "", // outputSFName, empty is the test cloud is not a separate cloud
m_app->getMainWindow()))
m_app->getMainWindow(),
m_app))
{
m_app->dispToConsole(errorMessage, ccMainAppInterface::ERR_CONSOLE_MESSAGE);
generatedScalarFields.releaseSFs(false);
+11 -4
View File
@@ -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;
}
@@ -290,7 +296,8 @@ bool Classifier::evaluate(const Feature::Source::Set& featureSources,
Train3DMASCDialog& train3DMASCDialog,
CCCoreLib::ReferenceCloud* testSubset/*=nullptr=*/,
QString outputSFName/*=QString()*/,
QWidget* parentWidget/*=nullptr*/)
QWidget* parentWidget/*=nullptr*/,
ccMainAppInterface *app/*=nullptr*/)
{
if (!testCloud)
{
@@ -468,7 +475,7 @@ bool Classifier::evaluate(const Feature::Source::Set& featureSources,
metrics.ratio = static_cast<float>(metrics.goodGuess) / metrics.sampleCount;
}
train3DMASCDialog.addConfusionMatrixAndSaveTraces(new ConfusionMatrix(actualClass, predictectedClass));
train3DMASCDialog.addConfusionMatrixAndSaveTraces(new ConfusionMatrix(actualClass, predictectedClass, nullptr, app));
//show the Classification_prediction field by default
if (outSF)
+4 -2
View File
@@ -70,13 +70,15 @@ namespace masc
Train3DMASCDialog& train3DMASCDialog,
CCCoreLib::ReferenceCloud* testSubset = nullptr,
QString outputSFName = QString(),
QWidget* parentWidget = nullptr);
QWidget* parentWidget = nullptr,
ccMainAppInterface* app = nullptr);
//! Applies the classifier
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;