mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 16:40:49 +08:00
display scales in Train3DMascDialog
This commit is contained in:
+6
-2
@@ -292,7 +292,8 @@ void q3DMASCPlugin::doTrainAction()
|
||||
|
||||
static masc::TrainParameters s_params;
|
||||
masc::Feature::Set features;
|
||||
if (!masc::Tools:: LoadTrainingFile(inputFilename, features, loadedClouds, s_params, &corePoints, m_app->getMainWindow()))
|
||||
std::vector<double> scales;
|
||||
if (!masc::Tools:: LoadTrainingFile(inputFilename, features, scales, loadedClouds, s_params, &corePoints, m_app->getMainWindow()))
|
||||
{
|
||||
m_app->dispToConsole("Failed to load the training file", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
|
||||
return;
|
||||
@@ -336,6 +337,7 @@ void q3DMASCPlugin::doTrainAction()
|
||||
ccPointCloud* testCloud = nullptr;
|
||||
bool needTestSuite = false;
|
||||
masc::Feature::Set featuresTest;
|
||||
std::vector<double> scalesTest;
|
||||
if (loadedClouds.contains("TEST"))
|
||||
{
|
||||
testCloud = loadedClouds["TEST"];
|
||||
@@ -352,7 +354,7 @@ void q3DMASCPlugin::doTrainAction()
|
||||
|
||||
//simply reload the classification file to create duplicated features
|
||||
masc::TrainParameters tempParams;
|
||||
if (!masc::Tools::LoadTrainingFile(inputFilename, featuresTest, loadedCloudsTest, tempParams))
|
||||
if (!masc::Tools::LoadTrainingFile(inputFilename, featuresTest, scalesTest, loadedCloudsTest, tempParams))
|
||||
{
|
||||
m_app->dispToConsole("Failed to load the training file (for test)", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
|
||||
return;
|
||||
@@ -378,6 +380,8 @@ void q3DMASCPlugin::doTrainAction()
|
||||
originalFeatures.push_back(FeatureSelection(f));
|
||||
trainDlg.addFeature(f->toString(), originalFeatures.back().importance, originalFeatures.back().selected);
|
||||
}
|
||||
for(double scale : scales)
|
||||
trainDlg.addScale(scale, true);
|
||||
|
||||
std::vector<FeatureSelection> originalFeaturesTest;
|
||||
if (testCloud && needTestSuite)
|
||||
|
||||
+3
-2
@@ -193,7 +193,8 @@ struct Command3DMASCClassif : public ccCommandLineInterface::Command
|
||||
|
||||
//load features
|
||||
masc::Feature::Set features;
|
||||
if (!masc::Tools::LoadFile(classifierFilename, &cloudPerRole, true, &features, nullptr, nullptr, nullptr, cmd.widgetParent()))
|
||||
std::vector<double> scales;
|
||||
if (!masc::Tools::LoadFile(classifierFilename, &cloudPerRole, true, &features, &scales, nullptr, nullptr, nullptr, cmd.widgetParent()))
|
||||
{
|
||||
return cmd.error("Failed to load the classifier");
|
||||
}
|
||||
@@ -272,7 +273,7 @@ struct Command3DMASCClassif : public ccCommandLineInterface::Command
|
||||
if (!onlyFeatures)
|
||||
{
|
||||
masc::Classifier classifier;
|
||||
if (!masc::Tools::LoadFile(classifierFilename, nullptr, false, nullptr, nullptr, &classifier, nullptr, cmd.widgetParent()))
|
||||
if (!masc::Tools::LoadFile(classifierFilename, nullptr, false, nullptr, nullptr, nullptr, &classifier, nullptr, cmd.widgetParent()))
|
||||
{
|
||||
return cmd.error("Failed to load the classifier");
|
||||
}
|
||||
|
||||
+10
-2
@@ -659,6 +659,7 @@ bool Tools::LoadFile( const QString& filename,
|
||||
Tools::NamedClouds* clouds,
|
||||
bool cloudsAreProvided,
|
||||
std::vector<Feature::Shared>* rawFeatures/*=nullptr*/, //requires 'clouds'
|
||||
std::vector<double>* rawScales/*=nullptr*/,
|
||||
masc::CorePoints* corePoints/*=nullptr*/, //requires 'clouds'
|
||||
masc::Classifier* classifier/*=nullptr*/,
|
||||
TrainParameters* parameters/*=nullptr*/,
|
||||
@@ -801,6 +802,12 @@ bool Tools::LoadFile( const QString& filename,
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rawScales)
|
||||
for (auto scale : scales)
|
||||
rawScales->push_back(scale);
|
||||
}
|
||||
}
|
||||
else if (upperLine.startsWith("FEATURE:")) //feature
|
||||
{
|
||||
@@ -883,18 +890,19 @@ bool Tools::LoadFile( const QString& filename,
|
||||
|
||||
bool Tools::LoadClassifier(QString filename, NamedClouds& clouds, Feature::Set& rawFeatures, masc::Classifier& classifier, QWidget* parent/*=nullptr*/)
|
||||
{
|
||||
return LoadFile(filename, &clouds, true, &rawFeatures, nullptr, &classifier, nullptr, parent);
|
||||
return LoadFile(filename, &clouds, true, &rawFeatures, nullptr, nullptr, &classifier, nullptr, parent);
|
||||
}
|
||||
|
||||
bool Tools::LoadTrainingFile( QString filename,
|
||||
Feature::Set& rawFeatures,
|
||||
std::vector<double>& rawScales,
|
||||
NamedClouds& loadedClouds,
|
||||
TrainParameters& parameters,
|
||||
CorePoints* corePoints/*=nullptr*/,
|
||||
QWidget* parentWidget/*=nullptr*/)
|
||||
{
|
||||
bool cloudsWereProvided = !loadedClouds.empty();
|
||||
if (LoadFile(filename, &loadedClouds, cloudsWereProvided, &rawFeatures, corePoints, nullptr, ¶meters, parentWidget))
|
||||
if (LoadFile(filename, &loadedClouds, cloudsWereProvided, &rawFeatures, &rawScales, corePoints, nullptr, ¶meters, parentWidget))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-1
@@ -38,7 +38,7 @@ namespace masc
|
||||
|
||||
typedef QMap<QString, ccPointCloud* > NamedClouds;
|
||||
|
||||
static bool LoadTrainingFile(QString filename, Feature::Set& rawFeatures, NamedClouds& loadedClouds, TrainParameters& parameters, CorePoints* corePoints = nullptr, QWidget* parent = nullptr);
|
||||
static bool LoadTrainingFile(QString filename, Feature::Set& rawFeatures, std::vector<double>& scales, NamedClouds& loadedClouds, TrainParameters& parameters, CorePoints* corePoints = nullptr, QWidget* parent = nullptr);
|
||||
|
||||
static bool LoadClassifierCloudLabels(QString filename, QList<QString>& labels, QString& corePointsLabel, bool& filenamesSpecified);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace masc
|
||||
Tools::NamedClouds* clouds,
|
||||
bool cloudsAreProvided,
|
||||
std::vector<Feature::Shared>* rawFeatures = nullptr, //requires 'clouds'
|
||||
std::vector<double>* rawScales = nullptr,
|
||||
masc::CorePoints* corePoints = nullptr, //requires 'clouds'
|
||||
masc::Classifier* classifier = nullptr,
|
||||
TrainParameters* parameters = nullptr,
|
||||
|
||||
@@ -65,12 +65,12 @@ int Train3DMASCDialog::addFeature(QString name, float importance, bool isChecked
|
||||
|
||||
int Train3DMASCDialog::addScale(double scale, bool isChecked/*=true*/)
|
||||
{
|
||||
int index = tableWidget->rowCount();
|
||||
tableWidget->setRowCount(index + 1);
|
||||
int index = tableWidgetScales->rowCount();
|
||||
tableWidgetScales->setRowCount(index + 1);
|
||||
|
||||
QTableWidgetItem* nameItem = new QTableWidgetItem(QString::number(scale));
|
||||
nameItem->setCheckState(isChecked ? Qt::Checked : Qt::Unchecked);
|
||||
tableWidget->setItem(index, 0, nameItem);
|
||||
tableWidgetScales->setItem(index, 0, nameItem);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user