mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 08:34:48 +08:00
use the existing scalar fields when available
This commit is contained in:
@@ -51,13 +51,12 @@ CCCoreLib::ScalarField* Feature::PrepareSF(ccPointCloud* cloud, const char* resu
|
|||||||
int sfIdx = cloud->getScalarFieldIndexByName(resultSFName);
|
int sfIdx = cloud->getScalarFieldIndexByName(resultSFName);
|
||||||
if (sfIdx >= 0)
|
if (sfIdx >= 0)
|
||||||
{
|
{
|
||||||
ccLog::Warning("Existing SF: " + QString(resultSFName) + ", SFCollector::Behavior " + QString::number(behavior));
|
ccLog::Warning("Existing SF: " + QString(resultSFName) + ", do not store in generatedScalarFields");
|
||||||
resultSF = cloud->getScalarField(sfIdx);
|
resultSF = cloud->getScalarField(sfIdx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ccLog::Warning("SF does not exist, create it: " + QString(resultSFName) + ", SFCollector::Behavior " + QString::number(behavior));
|
ccLog::Warning("SF does not exist, create it: " + QString(resultSFName) + ", SFCollector::Behavior " + QString::number(behavior));
|
||||||
resultSF = cloud->getScalarField(sfIdx);
|
|
||||||
ccScalarField* newSF = new ccScalarField(resultSFName);
|
ccScalarField* newSF = new ccScalarField(resultSFName);
|
||||||
if (!newSF->resizeSafe(cloud->size()))
|
if (!newSF->resizeSafe(cloud->size()))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,7 +91,11 @@ bool NeighborhoodFeature::prepare( const CorePoints& corePoints,
|
|||||||
assert(!sf1);
|
assert(!sf1);
|
||||||
sf1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName));
|
sf1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName));
|
||||||
if (sf1WasAlreadyExisting)
|
if (sf1WasAlreadyExisting)
|
||||||
|
{
|
||||||
sf1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
sf1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||||
|
if (generatedScalarFields->scalarFields.contains(sf1)) // i.e. the SF is existing but was not present at the startup of the plugin
|
||||||
|
generatedScalarFields->setBehavior(sf1, SFCollector::CAN_REMOVE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sf1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
sf1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||||
if (!sf1)
|
if (!sf1)
|
||||||
|
|||||||
@@ -579,7 +579,12 @@ bool PointFeature::prepare( const CorePoints& corePoints,
|
|||||||
//prepare the corresponding scalar field
|
//prepare the corresponding scalar field
|
||||||
statSF1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName));
|
statSF1WasAlreadyExisting = CheckSFExistence(corePoints.cloud, qPrintable(resultSFName));
|
||||||
if (statSF1WasAlreadyExisting)
|
if (statSF1WasAlreadyExisting)
|
||||||
|
{
|
||||||
|
// if the SF is not existing, it is not added to generatedScalarFields
|
||||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::ALWAYS_KEEP);
|
||||||
|
if (generatedScalarFields->scalarFields.contains(statSF1)) // i.e. the SF is existing but was not present at the startup of the plugin
|
||||||
|
generatedScalarFields->setBehavior(statSF1, SFCollector::CAN_REMOVE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
statSF1 = PrepareSF(corePoints.cloud, qPrintable(resultSFName), generatedScalarFields, SFCollector::CAN_REMOVE);
|
||||||
if (!statSF1)
|
if (!statSF1)
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
void SFCollector::push(ccPointCloud* cloud, CCCoreLib::ScalarField* sf, Behavior behavior)
|
void SFCollector::push(ccPointCloud* cloud, CCCoreLib::ScalarField* sf, Behavior behavior)
|
||||||
{
|
{
|
||||||
assert(!scalarFields.contains(sf));
|
assert(!scalarFields.contains(sf));
|
||||||
|
if (scalarFields.contains(sf))
|
||||||
|
ccLog::Warning(QString("[SFCollector] scalar field '%1' HAS ALREADY BEEN COLLECTED").arg(sf->getName()) + ", behaviour " + QString::number(behavior));
|
||||||
|
else
|
||||||
|
ccLog::Warning(QString("[SFCollector] collect scalar field '%1'").arg(sf->getName()) + ", behaviour " + QString::number(behavior));
|
||||||
SFDesc desc;
|
SFDesc desc;
|
||||||
desc.behavior = behavior;
|
desc.behavior = behavior;
|
||||||
desc.cloud = cloud;
|
desc.cloud = cloud;
|
||||||
@@ -63,3 +67,15 @@ void SFCollector::releaseSFs(bool keepByDefault)
|
|||||||
|
|
||||||
scalarFields.clear();
|
scalarFields.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SFCollector::setBehavior(CCCoreLib::ScalarField *sf, Behavior behavior)
|
||||||
|
{
|
||||||
|
if (scalarFields.contains(sf))
|
||||||
|
{
|
||||||
|
Behavior previousBehavior = scalarFields[sf].behavior;
|
||||||
|
scalarFields[sf].behavior = behavior;
|
||||||
|
ccLog::Warning("behavior of " + QString(sf->getName()) + " changed from " + QString::number(previousBehavior) + " to " + QString::number(behavior));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class SFCollector
|
|||||||
|
|
||||||
void releaseSFs(bool keepByDefault);
|
void releaseSFs(bool keepByDefault);
|
||||||
|
|
||||||
|
bool setBehavior(CCCoreLib::ScalarField *sf, Behavior behavior);
|
||||||
|
|
||||||
struct SFDesc
|
struct SFDesc
|
||||||
{
|
{
|
||||||
ccPointCloud* cloud = nullptr;
|
ccPointCloud* cloud = nullptr;
|
||||||
|
|||||||
+6
-2
@@ -21,6 +21,10 @@ QColor getColor(double value, double r1, double g1, double b1)
|
|||||||
double r0 = 255;
|
double r0 = 255;
|
||||||
double g0 = 255;
|
double g0 = 255;
|
||||||
double b0 = 255;
|
double b0 = 255;
|
||||||
|
if (value < 0.05)
|
||||||
|
value = 0.05;
|
||||||
|
if (value > 0.95)
|
||||||
|
value = 0.95;
|
||||||
int r = int((r1 - r0) * value + r0);
|
int r = int((r1 - r0) * value + r0);
|
||||||
int g = int ((g1 - g0) * value + g0);
|
int g = int ((g1 - g0) * value + g0);
|
||||||
int b = int ((b1 - b0) * value + b0);
|
int b = int ((b1 - b0) * value + b0);
|
||||||
@@ -42,7 +46,7 @@ ConfusionMatrix::ConfusionMatrix(std::vector<ScalarType> &actual, std::vector<Sc
|
|||||||
this->ui->tableWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
this->ui->tableWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||||
QSize tableSize = this->ui->tableWidget->sizeHint();
|
QSize tableSize = this->ui->tableWidget->sizeHint();
|
||||||
QSize labelSize = this->ui->label->sizeHint();
|
QSize labelSize = this->ui->label->sizeHint();
|
||||||
QSize widgetSize = QSize(tableSize.width(), tableSize.height() + 2 * labelSize.height());
|
QSize widgetSize = QSize(tableSize.width() + 10, tableSize.height() + 50);
|
||||||
this->setMinimumSize(widgetSize);
|
this->setMinimumSize(widgetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +242,7 @@ void ConfusionMatrix::compute(std::vector<ScalarType>& actual, std::vector<Scala
|
|||||||
newItem->setFont(f);
|
newItem->setFont(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
newItem->setBackground(getColor(val / vec_TP_FN.at<int>(row, 0), 0, 128, 255));
|
newItem->setBackground(getColor(val / vec_TP_FN.at<int>(row, 0), 200, 50, 50));
|
||||||
this->ui->tableWidget->setItem(2 + row, + 2 + column, newItem);
|
this->ui->tableWidget->setItem(2 + row, + 2 + column, newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -427,7 +427,7 @@ static bool CreateFeaturesFromCommand(const QString& command, QString corePoints
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ccLog::Warning(QString("ContextBasedFeature: you are using the DEPRECATED syntax").arg(token).arg(lineNumber));
|
ccLog::Warning(QString("ContextBasedFeature: you are using the DEPRECATED syntax (for instance, DZ1_SC0_CTX_10 is correct)").arg(token).arg(lineNumber));
|
||||||
qSharedPointerCast<ContextBasedFeature>(feature)->ctxClassLabel = classLabel;
|
qSharedPointerCast<ContextBasedFeature>(feature)->ctxClassLabel = classLabel;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -1092,7 +1092,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
|
|
||||||
//build the scaled feature list attached to the second cloud (if any)
|
//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
|
&& !static_cast<PointFeature*>(feature.data())->statSF1WasAlreadyExisting
|
||||||
|
&& !static_cast<PointFeature*>(feature.data())->statSF2WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||||
{
|
{
|
||||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||||
++fas.featureCount;
|
++fas.featureCount;
|
||||||
@@ -1123,7 +1124,8 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
|
|
||||||
//build the scaled feature list attached to the second cloud (if any)
|
//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
|
&& !static_cast<NeighborhoodFeature*>(feature.data())->sf1WasAlreadyExisting
|
||||||
|
&& !static_cast<NeighborhoodFeature*>(feature.data())->sf2WasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||||
{
|
{
|
||||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||||
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
|
fas.neighborhoodFeaturesPerScale[feature->scale].push_back(qSharedPointerCast<NeighborhoodFeature>(feature));
|
||||||
@@ -1140,7 +1142,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
case Feature::Type::ContextBasedFeature:
|
case Feature::Type::ContextBasedFeature:
|
||||||
{
|
{
|
||||||
//build the scaled feature list attached to the second cloud (the 'context' cloud)
|
//build the scaled feature list attached to the second cloud (the 'context' cloud)
|
||||||
if (feature->cloud2
|
if (feature->cloud1
|
||||||
&& !static_cast<ContextBasedFeature*>(feature.data())->sfWasAlreadyExisting) // nothing to compute if the scalar field was already there
|
&& !static_cast<ContextBasedFeature*>(feature.data())->sfWasAlreadyExisting) // nothing to compute if the scalar field was already there
|
||||||
{
|
{
|
||||||
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
FeaturesAndScales& fas = cloudsWithScaledFeatures[feature->cloud2];
|
||||||
@@ -1262,7 +1264,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
//Point features
|
//Point features
|
||||||
for (PointFeature::Shared& feature : fas.pointFeaturesPerScale[currentScale])
|
for (PointFeature::Shared& feature : fas.pointFeaturesPerScale[currentScale])
|
||||||
{
|
{
|
||||||
if (feature->cloud1 == sourceCloud && feature->statSF1 && feature->field1)
|
if (feature->cloud1 == sourceCloud && feature->statSF1 && feature->field1)
|
||||||
{
|
{
|
||||||
double outputValue = 0;
|
double outputValue = 0;
|
||||||
if (!feature->computeStat(nNSS.pointsInNeighbourhood, feature->field1, outputValue))
|
if (!feature->computeStat(nNSS.pointsInNeighbourhood, feature->field1, outputValue))
|
||||||
@@ -1276,7 +1278,7 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
feature->statSF1->setValue(i, v1);
|
feature->statSF1->setValue(i, v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feature->cloud2 == sourceCloud && feature->statSF2 && feature->field2)
|
if (feature->cloud2 == sourceCloud && feature->statSF2 && feature->field2)
|
||||||
{
|
{
|
||||||
assert(feature->op != Feature::NO_OPERATION);
|
assert(feature->op != Feature::NO_OPERATION);
|
||||||
double outputValue = 0;
|
double outputValue = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user