diff --git a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx index 55ae73e91c51e4cd09cedcf1bd95a88ce75a50be..0fdc7a2524e2705a0a22f603b9829d03f55d7044 100644 --- a/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainVectorClassifier.cxx @@ -65,9 +65,9 @@ protected: // Enforce the need of class field name in supervised mode if (GetClassifierCategory() == Supervised) { - m_featuresInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) ); + m_FeaturesInfo.SetClassFieldNames( GetChoiceNames( "cfield" ), GetSelectedItems( "cfield" ) ); - if( m_featuresInfo.m_SelectedCFieldIdx.empty() ) + if( m_FeaturesInfo.m_SelectedCFieldIdx.empty() ) { otbAppLogFATAL( << "No field has been selected for data labelling!" ); } @@ -77,8 +77,8 @@ protected: if (GetClassifierCategory() == Supervised) { - ConfusionMatrixCalculatorType::Pointer confMatCalc = ComputeConfusionMatrix( m_predictedList, - m_classificationSamplesWithLabel.labeledListSample ); + ConfusionMatrixCalculatorType::Pointer confMatCalc = ComputeConfusionMatrix( m_PredictedList, + m_ClassificationSamplesWithLabel.labeledListSample ); WriteConfusionMatrix( confMatCalc ); } else diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h index f01a99737b18c8ee2ea22a22488239d289bc49fd..871db9dcf446f265d36ff899512712f63f2a233d 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.h +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.h @@ -175,10 +175,10 @@ protected: */ ShiftScaleParameters ComputeStatistics(unsigned int nbFeatures); - SamplesWithLabel m_trainingSamplesWithLabel; - SamplesWithLabel m_classificationSamplesWithLabel; - TargetListSampleType::Pointer m_predictedList; - FeaturesInfo m_featuresInfo; + SamplesWithLabel m_TrainingSamplesWithLabel; + SamplesWithLabel m_ClassificationSamplesWithLabel; + TargetListSampleType::Pointer m_PredictedList; + FeaturesInfo m_FeaturesInfo; void DoInit() ITK_OVERRIDE; void DoUpdateParameters() ITK_OVERRIDE; diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx index c7fdda03d9db634f07dac21e88d0deade17f753e..2f22b778c8ece5c9ea43fda055ce064610386615 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx @@ -143,28 +143,28 @@ void TrainVectorBase::DoUpdateParameters() void TrainVectorBase::DoExecute() { - m_featuresInfo.SetFieldNames( GetChoiceNames( "feat" ), GetSelectedItems( "feat" )); + m_FeaturesInfo.SetFieldNames( GetChoiceNames( "feat" ), GetSelectedItems( "feat" )); // Check input parameters - if( m_featuresInfo.m_SelectedIdx.empty() ) + if( m_FeaturesInfo.m_SelectedIdx.empty() ) { otbAppLogFATAL( << "No features have been selected to train the classifier on!" ); } - ShiftScaleParameters measurement = ComputeStatistics( m_featuresInfo.m_NbFeatures ); + ShiftScaleParameters measurement = ComputeStatistics( m_FeaturesInfo.m_NbFeatures ); ExtractAllSamples( measurement ); - this->Train( m_trainingSamplesWithLabel.listSample, m_trainingSamplesWithLabel.labeledListSample, GetParameterString( "io.out" ) ); + this->Train( m_TrainingSamplesWithLabel.listSample, m_TrainingSamplesWithLabel.labeledListSample, GetParameterString( "io.out" ) ); - m_predictedList = TargetListSampleType::New(); - this->Classify( m_classificationSamplesWithLabel.listSample, m_predictedList, GetParameterString( "io.out" ) ); + m_PredictedList = TargetListSampleType::New(); + this->Classify( m_ClassificationSamplesWithLabel.listSample, m_PredictedList, GetParameterString( "io.out" ) ); } void TrainVectorBase::ExtractAllSamples(const ShiftScaleParameters &measurement) { - m_trainingSamplesWithLabel = ExtractTrainingSamplesWithLabel(measurement); - m_classificationSamplesWithLabel = ExtractClassificationSamplesWithLabel(measurement); + m_TrainingSamplesWithLabel = ExtractTrainingSamplesWithLabel(measurement); + m_ClassificationSamplesWithLabel = ExtractClassificationSamplesWithLabel(measurement); } TrainVectorBase::SamplesWithLabel @@ -190,15 +190,15 @@ TrainVectorBase::ExtractClassificationSamplesWithLabel(const ShiftScaleParameter { otbAppLogWARNING( "The validation set is empty. The performance estimation is done using the input training set in this case." ); - tmpSamplesWithLabel.listSample = m_trainingSamplesWithLabel.listSample; - tmpSamplesWithLabel.labeledListSample = m_trainingSamplesWithLabel.labeledListSample; + tmpSamplesWithLabel.listSample = m_TrainingSamplesWithLabel.listSample; + tmpSamplesWithLabel.labeledListSample = m_TrainingSamplesWithLabel.labeledListSample; } return tmpSamplesWithLabel; } else { - return m_trainingSamplesWithLabel; + return m_TrainingSamplesWithLabel; } } @@ -235,7 +235,7 @@ TrainVectorBase::ExtractSamplesWithLabel(std::string parameterName, std::string { ListSampleType::Pointer input = ListSampleType::New(); TargetListSampleType::Pointer target = TargetListSampleType::New(); - input->SetMeasurementVectorSize( m_featuresInfo.m_NbFeatures ); + input->SetMeasurementVectorSize( m_FeaturesInfo.m_NbFeatures ); std::vector<std::string> fileList = this->GetParameterStringList( parameterName ); for( unsigned int k = 0; k < fileList.size(); k++ ) @@ -254,21 +254,21 @@ TrainVectorBase::ExtractSamplesWithLabel(std::string parameterName, std::string // Check all needed fields are present : // - check class field if we use supervised classification or if class field name is not empty - int cFieldIndex = feature.ogr().GetFieldIndex( m_featuresInfo.m_SelectedCFieldName.c_str() ); - if( cFieldIndex < 0 && !m_featuresInfo.m_SelectedCFieldName.empty()) + int cFieldIndex = feature.ogr().GetFieldIndex( m_FeaturesInfo.m_SelectedCFieldName.c_str() ); + if( cFieldIndex < 0 && !m_FeaturesInfo.m_SelectedCFieldName.empty()) { - otbAppLogFATAL( "The field name for class label (" << m_featuresInfo.m_SelectedCFieldName + otbAppLogFATAL( "The field name for class label (" << m_FeaturesInfo.m_SelectedCFieldName << ") has not been found in the vector file " << fileList[k] ); } // - check feature fields - std::vector<int> featureFieldIndex( m_featuresInfo.m_NbFeatures, -1 ); - for( unsigned int i = 0; i < m_featuresInfo.m_NbFeatures; i++ ) + std::vector<int> featureFieldIndex( m_FeaturesInfo.m_NbFeatures, -1 ); + for( unsigned int i = 0; i < m_FeaturesInfo.m_NbFeatures; i++ ) { - featureFieldIndex[i] = feature.ogr().GetFieldIndex( m_featuresInfo.m_SelectedNames[i].c_str() ); + featureFieldIndex[i] = feature.ogr().GetFieldIndex( m_FeaturesInfo.m_SelectedNames[i].c_str() ); if( featureFieldIndex[i] < 0 ) - otbAppLogFATAL( "The field name for feature " << m_featuresInfo.m_SelectedNames[i] + otbAppLogFATAL( "The field name for feature " << m_FeaturesInfo.m_SelectedNames[i] << " has not been found in the vector file " << fileList[k] ); } @@ -278,8 +278,8 @@ TrainVectorBase::ExtractSamplesWithLabel(std::string parameterName, std::string { // Retrieve all the features for each field in the ogr layer. MeasurementType mv; - mv.SetSize( m_featuresInfo.m_NbFeatures ); - for( unsigned int idx = 0; idx < m_featuresInfo.m_NbFeatures; ++idx ) + mv.SetSize( m_FeaturesInfo.m_NbFeatures ); + for( unsigned int idx = 0; idx < m_FeaturesInfo.m_NbFeatures; ++idx ) mv[idx] = feature.ogr().GetFieldAsDouble( featureFieldIndex[idx] ); input->PushBack( mv );