Use existing scalar fields implemented

confusion matrix update
This commit is contained in:
Paul Leroy
2023-05-29 12:45:02 +02:00
parent 7062d8c5e2
commit bf9229e6b2
12 changed files with 155 additions and 48 deletions
+43 -8
View File
@@ -178,6 +178,19 @@ bool Tools::LoadClassifierCloudLabels(QString filename, QList<QString>& labels,
return true;
}
bool CheckFeatureUnicity(std::vector<Feature::Shared>& rawFeatures, Feature::Shared feature)
{
// check that the feature does not exists already!
for (const auto &feat : rawFeatures)
{
if (feat->toString() == feature->toString())
{
return false;
}
}
return true;
}
static bool CreateFeaturesFromCommand(const QString& command, QString corePointsRole, int lineNumber, const Tools::NamedClouds& clouds, std::vector<Feature::Shared>& rawFeatures, std::vector<double>& scales)
{
QStringList tokens = command.split('_');
@@ -470,8 +483,16 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints
return false;
}
//save it
rawFeatures.push_back(feature);
if (!CheckFeatureUnicity(rawFeatures, feature)) // check that the feature does not exists already!
{
ccLog::Warning("[3DMASC] duplicated feature " + feature->toString() + ", check your parameter file");
return false;
}
else
{
//save the feature
rawFeatures.push_back(feature);
}
if (useAllScales)
{
@@ -484,7 +505,16 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints
//as we only change the scale value, all the duplicated features should be valid
assert(newFeature->checkValidity(corePointsRole, errorMessage));
rawFeatures.push_back(newFeature);
if (!CheckFeatureUnicity(rawFeatures, newFeature)) // check that the feature does not exists already!
{
ccLog::Warning("[3DMASC] duplicated feature " + newFeature->toString() + ", check your parameter file");
return false;
}
else
{
//save the feature
rawFeatures.push_back(newFeature);
}
}
}
@@ -1001,7 +1031,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
case Feature::Type::PointFeature:
{
//build the scaled feature list attached to the first cloud
if (feature->cloud1)
if (feature->cloud1
&& !static_cast<PointFeature*>(feature.data())->statSF1WasAlreadyExisting) // nothing to compute if the scalar field was already there
{
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud1];
fas.pointFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<PointFeature>(feature));
@@ -1013,7 +1044,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
}
//build the scaled feature list attached to the second cloud (if any)
if (feature->cloud2 && feature->cloud2 != feature->cloud1 && feature->op != Feature::NO_OPERATION)
if (feature->cloud2 && feature->cloud2 != feature->cloud1 && feature->op != Feature::NO_OPERATION
&& !static_cast<PointFeature*>(feature.data())->statSF1WasAlreadyExisting) // nothing to compute if the scalar field was already there
{
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
++fas.featureCount;
@@ -1030,7 +1062,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
case Feature::Type::NeighborhoodFeature:
{
//build the scaled feature list attached to the first cloud
if (feature->cloud1)
if (feature->cloud1
&& !static_cast<NeighborhoodFeature*>(feature.data())->sf1WasAlreadyExisting) // nothing to compute if the scalar field was already there
{
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud1];
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
@@ -1042,7 +1075,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
}
//build the scaled feature list attached to the second cloud (if any)
if (feature->cloud2 && feature->cloud2 != feature->cloud1 && feature->op != Feature::NO_OPERATION)
if (feature->cloud2 && feature->cloud2 != feature->cloud1 && feature->op != Feature::NO_OPERATION
&& !static_cast<NeighborhoodFeature*>(feature.data())->sf1WasAlreadyExisting) // nothing to compute if the scalar field was already there
{
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
@@ -1059,7 +1093,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
case Feature::Type::ContextBasedFeature:
{
//build the scaled feature list attached to the second cloud (the 'context' cloud)
if (feature->cloud2)
if (feature->cloud2
&& !static_cast<ContextBasedFeature*>(feature.data())->sfWasAlreadyExisting) // nothing to compute if the scalar field was already there
{
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
fas.contextBasedFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<ContextBasedFeature>(feature));