diff --git a/Modules/Applications/AppClassification/app/CMakeLists.txt b/Modules/Applications/AppClassification/app/CMakeLists.txt index 5f8dd4368605527840151f68faffab67c6e9fc0f..7da4e25da879e9f8a8f00b806fbd22f789e6f476 100644 --- a/Modules/Applications/AppClassification/app/CMakeLists.txt +++ b/Modules/Applications/AppClassification/app/CMakeLists.txt @@ -50,6 +50,10 @@ otb_create_application( SOURCES otbTrainVectorClassifier.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) +otb_create_application( + NAME TrainVectorClustering + SOURCES otbTrainVectorClustering.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) otb_create_application( NAME ComputeConfusionMatrix diff --git a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h index 8c451322064e3b70060cf72543be33c358fd6183..9f8bbcdf7b005982f1ff754c07c4220d5565a053 100644 --- a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h +++ b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.h @@ -110,7 +110,7 @@ public: // Machine Learning models typedef otb::MachineLearningModelFactory< - InputValueType, OutputValueType> ModelFactoryType; + InputValueType, OutputValueType> ModelFactoryType; typedef typename ModelFactoryType::MachineLearningModelTypePointer ModelPointerType; typedef typename ModelFactoryType::MachineLearningModelType ModelType; diff --git a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.txx b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.txx index 59ffcb2b4dfd9914b9df51bd3e9ba9a5490911bd..1b75305a570de4a3efab5666c6131fe7e52563bf 100644 --- a/Modules/Applications/AppClassification/include/otbLearningApplicationBase.txx +++ b/Modules/Applications/AppClassification/include/otbLearningApplicationBase.txx @@ -93,7 +93,6 @@ LearningApplicationBase<TInputValue,TOutputValue> #ifdef OTB_USE_SHARK InitSharkRandomForestsParams(); - InitSharkKMeansParams(); #endif } @@ -102,7 +101,9 @@ void LearningApplicationBase<TInputValue,TOutputValue> ::InitUnsupervisedClassifierParams() { - +#ifdef OTB_USE_SHARK + InitSharkKMeansParams(); +#endif } template <class TInputValue, class TOutputValue> diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx index 97706bf56c20f4971670ad80b7d0537869f8cd3c..ebb651b324597b6b0bd94b5bcfaeafde7b0b1ddd 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.txx @@ -249,7 +249,7 @@ TrainVectorBase::ExtractListSamples(std::string parameterName, std::string param input->PushBack( mv ); - if( feature.ogr().IsFieldSet( cFieldIndex ) ) + if( feature.ogr().IsFieldSet( cFieldIndex ) && cFieldIndex != -1 ) target->PushBack( feature.ogr().GetFieldAsInteger( cFieldIndex ) ); else target->PushBack( 0 ); @@ -259,6 +259,8 @@ TrainVectorBase::ExtractListSamples(std::string parameterName, std::string param } } + + ShiftScaleFilterType::Pointer shiftScaleFilter = ShiftScaleFilterType::New(); shiftScaleFilter->SetInput( input ); shiftScaleFilter->SetShifts( measurement.meanMeasurementVector ); diff --git a/Modules/Applications/AppClassification/test/CMakeLists.txt b/Modules/Applications/AppClassification/test/CMakeLists.txt index 8455a03eb3e47ddbb02125ec7c104e022756f2c0..70550e3e50b217cd04322b6684e991a91409d8c2 100644 --- a/Modules/Applications/AppClassification/test/CMakeLists.txt +++ b/Modules/Applications/AppClassification/test/CMakeLists.txt @@ -935,6 +935,24 @@ if(OTB_USE_OPENCV) ${TEMP}/apTvClTrainVectorClassifierModel.rf) endif() +#----------- TrainVectorClustering TESTS ---------------- +if(OTB_USE_SHARK) + otb_test_application(NAME apTvClTrainVectorClustering + APP TrainVectorClustering + OPTIONS -io.vd ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -feat value_0 value_1 value_2 value_3 + -classifier sharkkm + -io.out ${TEMP}/apTvClTrainVectorClusteringModel.txt) + + otb_test_application(NAME apTvClTrainVectorClusteringWithClass + APP TrainVectorClustering + OPTIONS -io.vd ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite + -feat value_0 value_1 value_2 value_3 + -cfield class + -classifier sharkkm + -io.out ${TEMP}/apTvClTrainVectorClusteringModelWithClass.txt) +endif() + #------------ MultiImageSamplingRate TESTS ---------------- otb_test_application( NAME apTvClMultiImageSamplingRate