Skip to content
Snippets Groups Projects
Commit 29a68140 authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

MRG

parents 2ce2a93e bf430d12
No related branches found
No related tags found
No related merge requests found
...@@ -136,14 +136,14 @@ ApplicationHtmlDocGenerator::GenerateDoc(const Application::Pointer app, const s ...@@ -136,14 +136,14 @@ ApplicationHtmlDocGenerator::GenerateDoc(const Application::Pointer app, const s
ApplicationHtmlDocGenerator::GenerateDoc( app, doc ); ApplicationHtmlDocGenerator::GenerateDoc( app, doc );
std::ofstream ofs(filename.c_str()); std::ofstream ofs(filename.c_str());
if (!ofs.is_open()) if (!ofs.is_open())
{ {
fprintf(stderr, "Error, can't open file"); fprintf(stderr, "Error, can't open file");
itkGenericExceptionMacro( << "Error, can't open file "<<filename<<"."); itkGenericExceptionMacro( << "Error, can't open file "<<filename<<".");
} }
ofs << doc; ofs << doc;
ofs.close(); ofs.close();
} }
void ApplicationHtmlDocGenerator::GetDocParameters( const Application::Pointer app, std::string & val) void ApplicationHtmlDocGenerator::GetDocParameters( const Application::Pointer app, std::string & val)
......
...@@ -549,13 +549,6 @@ SET_TESTS_PROPERTIES(leTvConfusionMatrixCalculatorWrongSize PROPERTIES WILL_FAIL ...@@ -549,13 +549,6 @@ SET_TESTS_PROPERTIES(leTvConfusionMatrixCalculatorWrongSize PROPERTIES WILL_FAIL
ADD_TEST(leTvConfusionMatrixCalculatorUpdate ${LEARNING_TESTS4} ADD_TEST(leTvConfusionMatrixCalculatorUpdate ${LEARNING_TESTS4}
otbConfusionMatrixCalculatorUpdate 1000 4) otbConfusionMatrixCalculatorUpdate 1000 4)
# ------- SVM Validation -------------------------
ADD_TEST(leTvSVMValidationLinearlySeparableWithoutProbEstimate ${LEARNING_TESTS4}
otbSVMValidation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 0)
ADD_TEST(leTvSVMValidationLinearlySeparableWithProbEstimate ${LEARNING_TESTS4}
otbSVMValidation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 1)
# ShiftScaleSampleListFilter tests ---------- # ShiftScaleSampleListFilter tests ----------
ADD_TEST(leTuShiftScaleSampleListFilterNew ${LEARNING_TESTS4} ADD_TEST(leTuShiftScaleSampleListFilterNew ${LEARNING_TESTS4}
otbShiftScaleSampleListFilterNew) otbShiftScaleSampleListFilterNew)
...@@ -715,7 +708,6 @@ otbExhaustiveExponentialOptimizerNew.cxx ...@@ -715,7 +708,6 @@ otbExhaustiveExponentialOptimizerNew.cxx
otbExhaustiveExponentialOptimizerTest.cxx otbExhaustiveExponentialOptimizerTest.cxx
otbListSampleGeneratorTest.cxx otbListSampleGeneratorTest.cxx
otbConfusionMatrixCalculatorTest.cxx otbConfusionMatrixCalculatorTest.cxx
otbSVMValidation.cxx
otbShiftScaleSampleListFilter.cxx otbShiftScaleSampleListFilter.cxx
otbGaussianAdditiveNoiseSampleListFilter.cxx otbGaussianAdditiveNoiseSampleListFilter.cxx
otbConcatenateSampleListFilter.cxx otbConcatenateSampleListFilter.cxx
......
...@@ -35,7 +35,6 @@ void RegisterTests() ...@@ -35,7 +35,6 @@ void RegisterTests()
REGISTER_TEST(otbConfusionMatrixCalculatorSetListSamples); REGISTER_TEST(otbConfusionMatrixCalculatorSetListSamples);
REGISTER_TEST(otbConfusionMatrixCalculatorWrongSize); REGISTER_TEST(otbConfusionMatrixCalculatorWrongSize);
REGISTER_TEST(otbConfusionMatrixCalculatorUpdate); REGISTER_TEST(otbConfusionMatrixCalculatorUpdate);
REGISTER_TEST(otbSVMValidation);
REGISTER_TEST(otbShiftScaleSampleListFilterNew); REGISTER_TEST(otbShiftScaleSampleListFilterNew);
REGISTER_TEST(otbShiftScaleSampleListFilter); REGISTER_TEST(otbShiftScaleSampleListFilter);
REGISTER_TEST(otbGaussianAdditiveNoiseSampleListFilterNew); REGISTER_TEST(otbGaussianAdditiveNoiseSampleListFilterNew);
......
...@@ -34,25 +34,37 @@ ...@@ -34,25 +34,37 @@
#include <fstream> #include <fstream>
int otbSVMValidation(int argc, char* argv[]) /*
This test show a problem with the SVM library using the probability
estimation : bug 209.
If the probability estimation is activated, the classifier isn't
abble to find the hyperplan even if the sample are linearly
seperable.
cf. test leTvBug209_SVMValidationLinearlySeparableWithoutProbEstimate
=> OK
and leTvBug209_SVMValidationLinearlySeparableWithProbEstimate => KO
http://bugs.orfeo-toolbox.org/view.php?id=209
*/
int main(int argc, char* argv[])
{ {
if(argc != 13) if(argc != 14)
{ {
std::cerr<<"Usage: "<<argv[0]<<" nbTrainingSamples nbValidationSamples positiveCenterX positiveCenterY negativeCenterX negativeCenterY positiveRadiusMin positiveRadiusMax negativeRadiusMin negativeRadiusMax kernel probEstimate"<<std::endl; std::cerr<<"Usage: "<<argv[0]<<" nbTrainingSamples nbValidationSamples positiveCenterX positiveCenterY negativeCenterX negativeCenterY positiveRadiusMin positiveRadiusMax negativeRadiusMin negativeRadiusMax kernel probEstimate"<<std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
unsigned int nbTrainingSamples = atoi(argv[1]); unsigned int nbTrainingSamples = atoi(argv[2]);
unsigned int nbValidationSamples = atoi(argv[2]); unsigned int nbValidationSamples = atoi(argv[3]);
double cpx = atof(argv[3]); double cpx = atof(argv[4]);
double cpy = atof(argv[4]); double cpy = atof(argv[5]);
double cnx = atof(argv[5]); double cnx = atof(argv[6]);
double cny = atof(argv[6]); double cny = atof(argv[7]);
double prmin = atof(argv[7]); double prmin = atof(argv[8]);
double prmax = atof(argv[8]); double prmax = atof(argv[9]);
double nrmin = atof(argv[9]); double nrmin = atof(argv[10]);
double nrmax = atof(argv[10]); double nrmax = atof(argv[11]);
unsigned int kernel = atoi(argv[11]); unsigned int kernel = atoi(argv[12]);
bool probEstimate = atoi(argv[12]); bool probEstimate = atoi(argv[13]);
typedef double InputPixelType; typedef double InputPixelType;
typedef unsigned short LabelType; typedef unsigned short LabelType;
...@@ -79,7 +91,7 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -79,7 +91,7 @@ int otbSVMValidation(int argc, char* argv[])
TrainingListSampleType::Pointer validationLabels = TrainingListSampleType::New(); TrainingListSampleType::Pointer validationLabels = TrainingListSampleType::New();
// Generate training set // Generate training set
// std::ofstream training("training.csv"); //std::ofstream training("training.csv");
for(unsigned int i =0; i < nbTrainingSamples; ++i) for(unsigned int i =0; i < nbTrainingSamples; ++i)
{ {
// Generate a positive sample // Generate a positive sample
...@@ -93,7 +105,7 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -93,7 +105,7 @@ int otbSVMValidation(int argc, char* argv[])
trainingSamples->PushBack(pSample); trainingSamples->PushBack(pSample);
trainingLabels->PushBack(label); trainingLabels->PushBack(label);
// training<<"1 1:"<<pSample[0]<<" 2:"<<pSample[1]<<std::endl; //training<<"1 1:"<<pSample[0]<<" 2:"<<pSample[1]<<std::endl;
// Generate a negative sample // Generate a negative sample
angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI ); angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI );
...@@ -105,14 +117,14 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -105,14 +117,14 @@ int otbSVMValidation(int argc, char* argv[])
trainingSamples->PushBack(nSample); trainingSamples->PushBack(nSample);
trainingLabels->PushBack(label); trainingLabels->PushBack(label);
// training<<"2 1:"<<nSample[0]<<" 2:"<<nSample[1]<<std::endl; //training<<"2 1:"<<nSample[0]<<" 2:"<<nSample[1]<<std::endl;
} }
// training.close(); //training.close();
// Generate validation set // Generate validation set
// std::ofstream validation("validation.csv"); std::ofstream validation("validation.csv");
for(unsigned int i =0; i < nbValidationSamples; ++i) for(unsigned int i =0; i < nbValidationSamples; ++i)
{ {
// Generate a positive sample // Generate a positive sample
...@@ -125,7 +137,7 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -125,7 +137,7 @@ int otbSVMValidation(int argc, char* argv[])
label[0]=1; label[0]=1;
validationSamples->PushBack(pSample); validationSamples->PushBack(pSample);
validationLabels->PushBack(label); validationLabels->PushBack(label);
// validation<<"1 1:"<<pSample[0]<<" 2:"<<pSample[1]<<std::endl; //validation<<"1 1:"<<pSample[0]<<" 2:"<<pSample[1]<<std::endl;
// Generate a negative sample // Generate a negative sample
angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI ); angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI );
...@@ -136,10 +148,10 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -136,10 +148,10 @@ int otbSVMValidation(int argc, char* argv[])
label[0]=2; label[0]=2;
validationSamples->PushBack(nSample); validationSamples->PushBack(nSample);
validationLabels->PushBack(label); validationLabels->PushBack(label);
// validation<<"2 1:"<<nSample[0]<<" 2:"<<nSample[1]<<std::endl; //validation<<"2 1:"<<nSample[0]<<" 2:"<<nSample[1]<<std::endl;
} }
// validation.close(); //validation.close();
// Learn // Learn
EstimatorType::Pointer estimator = EstimatorType::New(); EstimatorType::Pointer estimator = EstimatorType::New();
...@@ -151,7 +163,7 @@ int otbSVMValidation(int argc, char* argv[]) ...@@ -151,7 +163,7 @@ int otbSVMValidation(int argc, char* argv[])
// estimator->SetParametersOptimization(true); // estimator->SetParametersOptimization(true);
estimator->Update(); estimator->Update();
// estimator->SaveModel("model.svm"); //estimator->SaveModel("model.svm");
// Classify // Classify
ClassifierType::Pointer validationClassifier = ClassifierType::New(); ClassifierType::Pointer validationClassifier = ClassifierType::New();
......
...@@ -258,6 +258,14 @@ ADD_TEST(faTvWriteUnsignedLong ${CXX_TEST_PATH}/WriteUnsignedLong ...@@ -258,6 +258,14 @@ ADD_TEST(faTvWriteUnsignedLong ${CXX_TEST_PATH}/WriteUnsignedLong
${TEMP}/WriteUnsignedLong.tif ${TEMP}/WriteUnsignedLong.tif
) )
# ------- FA 0000209 : SVM Validation issue -------------------------
ADD_TEST(FA-000209-SVMValidationLinearlySeparableWithoutProbEstimate_OK ${CXX_TEST_PATH}/0000209-SVMValidationLinearlySeparableProbEstimation
0000209-SVMValidationLinearlySeparableProbEstimation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 0)
ADD_TEST(FA-000209-SVMValidationLinearlySeparableWithProbEstimate_KO ${CXX_TEST_PATH}/0000209-SVMValidationLinearlySeparableProbEstimation
0000209-SVMValidationLinearlySeparableProbEstimation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 1)
# ------- Vectorization issue ----------------------------------- # ------- Vectorization issue -----------------------------------
# FIXME Desactivated until http://bugs.orfeo-toolbox.org/view.php?id=94 # FIXME Desactivated until http://bugs.orfeo-toolbox.org/view.php?id=94
# has somebody working on it # has somebody working on it
...@@ -302,4 +310,7 @@ TARGET_LINK_LIBRARIES(SensorModelBorder OTBIO OTBCommon OTBBasicFilters OTBProje ...@@ -302,4 +310,7 @@ TARGET_LINK_LIBRARIES(SensorModelBorder OTBIO OTBCommon OTBBasicFilters OTBProje
ADD_EXECUTABLE(WriteUnsignedLong WriteUnsignedLong.cxx) ADD_EXECUTABLE(WriteUnsignedLong WriteUnsignedLong.cxx)
TARGET_LINK_LIBRARIES(WriteUnsignedLong OTBIO OTBCommon) TARGET_LINK_LIBRARIES(WriteUnsignedLong OTBIO OTBCommon)
ADD_EXECUTABLE(0000209-SVMValidationLinearlySeparableProbEstimation 0000209-SVMValidationLinearlySeparableProbEstimation.cxx)
TARGET_LINK_LIBRARIES(0000209-SVMValidationLinearlySeparableProbEstimation OTBIO OTBLearning)
ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
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