mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 08:34:48 +08:00
changes following PR
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ if (INSTALL_Q3DMASC_PLUGIN)
|
||||
project( Q3DMASC_PLUGIN )
|
||||
|
||||
AddPlugin( NAME ${PROJECT_NAME} )
|
||||
set(Q3DMASC_PLUGIN_VERSION "0.11")
|
||||
set(Q3DMASC_PLUGIN_VERSION "0.12")
|
||||
|
||||
include( CMakePolicies NO_POLICY_SCOPE )
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace masc
|
||||
int ctxClassLabel;
|
||||
//! The computed scalar
|
||||
CCCoreLib::ScalarField* sf;
|
||||
|
||||
//! Whether the SF pre-exists
|
||||
bool sfWasAlreadyExisting;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,15 +27,14 @@ using namespace masc;
|
||||
|
||||
bool Feature::CheckSFExistence(ccPointCloud* cloud, const char* resultSFName)
|
||||
{
|
||||
int sfIdx = cloud->getScalarFieldIndexByName(resultSFName);
|
||||
if (sfIdx >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!cloud || !resultSFName)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int sfIdx = cloud->getScalarFieldIndexByName(resultSFName);
|
||||
return (sfIdx >= 0);
|
||||
}
|
||||
|
||||
CCCoreLib::ScalarField* Feature::PrepareSF(ccPointCloud* cloud, const char* resultSFName, SFCollector* generatedScalarFields/*=nullptr*/, SFCollector::Behavior behavior/*=SFCollector::CAN_REMOVE*/)
|
||||
|
||||
@@ -97,7 +97,9 @@ bool NeighborhoodFeature::prepare( const CorePoints& corePoints,
|
||||
generatedScalarFields->setBehavior(sf1, SFCollector::CAN_REMOVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sf1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||
}
|
||||
if (!sf1)
|
||||
{
|
||||
error = QString("Failed to prepare scalar %1 @ scale %2").arg(resultSFName).arg(scale);
|
||||
@@ -112,11 +114,10 @@ bool NeighborhoodFeature::prepare( const CorePoints& corePoints,
|
||||
keepSF2 = (corePoints.cloud->getScalarFieldIndexByName(qPrintable(resultSFName2)) >= 0); //we remember that the scalar field was already existing!
|
||||
|
||||
assert(!sf2);
|
||||
sf2WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName2));
|
||||
if (sf2WasAlreadyExisting)
|
||||
sf2 = PrepareSF(corePoints.cloud, qPrintable(resultSFName2), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||
else
|
||||
sf2 = PrepareSF(corePoints.cloud, qPrintable(resultSFName2), generatedScalarFields, SFCollector::ALWAYS_REMOVE);
|
||||
|
||||
sf2WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName2));
|
||||
sf2 = PrepareSF(corePoints.cloud, qPrintable(resultSFName2), generatedScalarFields, sf2WasAlreadyExisting ? SFCollector::ALWAYS_KEEP : SFCollector::ALWAYS_REMOVE);
|
||||
|
||||
if (!sf2)
|
||||
{
|
||||
error = QString("Failed to prepare scalar field for %1 @ scale %2").arg(cloud2Label).arg(scale);
|
||||
|
||||
+24
-27
@@ -266,39 +266,36 @@ void ConfusionMatrix::setSessionRun(QString session, int run)
|
||||
|
||||
bool ConfusionMatrix::save(QString filePath)
|
||||
{
|
||||
std::unique_ptr<QFile> file(new QFile(filePath));
|
||||
QTextStream stream;
|
||||
QFile file(filePath);
|
||||
|
||||
if(!file->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
ccLog::Error("impossible to open file: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file && file->isOpen())
|
||||
QTextStream stream(&file);
|
||||
stream << "# columns: predicted classes\n# rows: actual classes\n";
|
||||
stream << "# last three colums: precision / recall / F1-score\n";
|
||||
for (auto class_number : class_numbers)
|
||||
{
|
||||
stream.setDevice(file.get());
|
||||
stream << "# columns: predicted classes\n# rows: actual classes\n";
|
||||
stream << "# last three colums: precision / recall / F1-score\n";
|
||||
for (auto class_number : class_numbers)
|
||||
{
|
||||
stream << class_number << " ";
|
||||
}
|
||||
stream << Qt::endl;
|
||||
for (int row = 0; row < confusionMatrix.rows; row++)
|
||||
{
|
||||
stream << class_numbers.at(row) << " ";
|
||||
for (int col = 0; col < confusionMatrix.cols; col++)
|
||||
{
|
||||
stream << confusionMatrix.at<int>(row, col) << " ";
|
||||
}
|
||||
stream << precisionRecallF1Score.at<float>(row, PRECISION) << " ";
|
||||
stream << precisionRecallF1Score.at<float>(row, RECALL) << " ";
|
||||
stream << precisionRecallF1Score.at<float>(row, F1_SCORE) << Qt::endl;
|
||||
}
|
||||
file->close();
|
||||
return true;
|
||||
stream << class_number << " ";
|
||||
}
|
||||
else
|
||||
return false;
|
||||
stream << Qt::endl;
|
||||
for (int row = 0; row < confusionMatrix.rows; row++)
|
||||
{
|
||||
stream << class_numbers.at(row) << " ";
|
||||
for (int col = 0; col < confusionMatrix.cols; col++)
|
||||
{
|
||||
stream << confusionMatrix.at<int>(row, col) << " ";
|
||||
}
|
||||
stream << precisionRecallF1Score.at<float>(row, PRECISION) << " ";
|
||||
stream << precisionRecallF1Score.at<float>(row, RECALL) << " ";
|
||||
stream << precisionRecallF1Score.at<float>(row, F1_SCORE) << Qt::endl;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,5 +1,4 @@
|
||||
#ifndef CONFUSIONMATRIX_H
|
||||
#define CONFUSIONMATRIX_H
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <set>
|
||||
@@ -25,7 +24,7 @@ public:
|
||||
};
|
||||
|
||||
explicit ConfusionMatrix(const std::vector<ScalarType>& actual, const std::vector<ScalarType>& predicted, QWidget *parent = nullptr);
|
||||
~ConfusionMatrix();
|
||||
~ConfusionMatrix() override;
|
||||
|
||||
void computePrecisionRecallF1Score(cv::Mat& matrix, cv::Mat& precisionRecallF1Score, cv::Mat &vec_TP_FN);
|
||||
float computeOverallAccuracy(cv::Mat& matrix);
|
||||
@@ -42,5 +41,3 @@ private:
|
||||
cv::Mat precisionRecallF1Score;
|
||||
std::vector<ScalarType> class_numbers;
|
||||
};
|
||||
|
||||
#endif // CONFUSIONMATRIX_H
|
||||
|
||||
@@ -181,6 +181,9 @@ bool Tools::LoadClassifierCloudLabels(QString filename, QList<QString>& labels,
|
||||
|
||||
bool CheckFeatureUnicity(std::vector<Feature::Shared>& rawFeatures, Feature::Shared feature)
|
||||
{
|
||||
if (!feature)
|
||||
return false;
|
||||
|
||||
// check that the feature does not exists already!
|
||||
for (const auto &feat : rawFeatures)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user