Skip to content
Snippets Groups Projects
Commit 9e6b26ab authored by Cédric Traizet's avatar Cédric Traizet
Browse files

app cxx added

parent 8426dd2a
No related branches found
No related tags found
1 merge request!4Dimensionality reduction algorithms
......@@ -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
}
};
......
#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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment