diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index a6362a4b4f700fdb2f1b62635716ec0a3938e507..a8b0e06e834808a9529e17fab5b12539fdbac30d 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -5,9 +5,7 @@ #include <iostream> #include "otbImage.h" -//#include "otbVectorImage.h" -#include "otbImageFileReader.h" -#include "otbImageFileWriter.h" +#include "otbVectorImage.h" #include <shark/Models/Autoencoder.h>//normal autoencoder model @@ -16,6 +14,7 @@ #include <shark/Models/Normalizer.h> #include "encode_filter.h" +//#include "dummy_filter.h" namespace otb { @@ -25,11 +24,18 @@ namespace Wrapper class CbDimensionalityReduction : public otb::Wrapper::Application { public: - typedef CbDimensionalityReduction Self; + /** Standard class typedefs. */ + typedef CbDimensionalityReduction Self; + typedef Application Superclass; typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + /** Standard macro */ itkNewMacro(Self); - itkTypeMacro(CbDimensionalityReduction, otb::Wrapper::Application); + itkTypeMacro(CbDimensionalityReduction, otb::Application); private: + void DoInit() { SetName("CbDimensionalityReduction"); @@ -56,33 +62,34 @@ private: void DoExecute() { - typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; - - using image_type = otb::VectorImage<double, 2>; + typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; + using image_type = FloatVectorImageType; using FilterType = EncodeFilter<image_type, AutoencoderType, shark::Normalizer<shark::RealVector>> ; + using DummyFilterType = DummyFilter<image_type> ; std::cout << "Appli !" << std::endl; FloatVectorImageType::Pointer inImage = GetParameterImage("in"); std::string encoderPath = GetParameterString("model"); std::string normalizerPath = GetParameterString("normalizer"); - //inImage->UpdateOutputInformation(); - - using ReaderType = otb::ImageFileReader<image_type>; - - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName("/mnt/data/home/vincenta/features_2014/SL_MultiTempGapF_Brightness_NDVI_NDWI__.tif"); - FilterType::Pointer filter = FilterType::New(); filter->SetAutoencoderModel(encoderPath); filter->SetNormalizerModel(normalizerPath); - filter->SetInput(reader->GetOutput()); - //filter->SetInput(inImage); - - filter->UpdateOutputInformation(); - + filter->SetInput(inImage); + filter->Update(); SetParameterOutputImage("out", filter->GetOutput()); +/* + DummyFilterType::Pointer dummy_filter = DummyFilterType::New(); // this filter simply copies the input image (do not need shark library) + dummy_filter->SetInput(GetParameterFloatVectorImage("in")); + dummy_filter->Update(); + dummy_filter->UpdateOutputInformation(); + SetParameterOutputImage("out", dummy_filter->GetOutput()); + +*/ + + //SetParameterOutputImage("out", inImage); // copy input image + } }; diff --git a/app/cbDimensionalityReductionTrainer.cxx b/app/cbDimensionalityReductionTrainer.cxx index cd18d7e5c412bc8e6e98e0a7f0502021b1f414be..92e23672e559ca5a398033d1f2fefe4a3ff3d84c 100644 --- a/app/cbDimensionalityReductionTrainer.cxx +++ b/app/cbDimensionalityReductionTrainer.cxx @@ -1,6 +1,14 @@ #include "otbWrapperApplication.h" #include "otbWrapperApplicationFactory.h" +#include "otbWrapperChoiceParameter.h" +#include "otbOGRDataSourceWrapper.h" +#include "otbOGRFeatureWrapper.h" + +namespace otb +{ +namespace Wrapper +{ class CbDimensionalityReductionTrainer : public otb::Wrapper::Application { public: @@ -13,6 +21,14 @@ private: { SetName("CbDimensionalityReductionTrainer"); SetDescription("Trainer for the dimensionality reduction algorithms used in the cbDimensionalityReduction application."); + + + AddParameter(ParameterType_InputVectorData, "train", "Name of the input training vector data"); + SetParameterDescription("train","The vector data used for training."); +/* + AddParameter(ParameterType_InputVectorData, "val", "Name of the input validation vector data"); + SetParameterDescription("val","The vector data used for validation."); +*/ AddRAMParameter(); } @@ -23,9 +39,19 @@ private: void DoExecute() { std::cout << "Appli !" << std::endl; - int ThisDoesNothing = 0; + std::string shapefile = GetParameterString("train"); + otb::ogr::DataSource::Pointer source = otb::ogr::DataSource::New(shapefile, otb::ogr::DataSource::Modes::Read); + otb::ogr::Layer layer = source->GetLayer(0); + //ListSampleType::Pointer input = ListSampleType::New(); + //const int nbFeatures = GetSelectedItems("feat").size(); + //input->SetMeasurementVectorSize(nbFeatures); + } }; -OTB_APPLICATION_EXPORT(CbDimensionalityReductionTrainer) + +} +} + +OTB_APPLICATION_EXPORT(otb::Wrapper::CbDimensionalityReductionTrainer)