diff --git a/Code/ApplicationEngine/otbWrapperApplicationHtmlDocGenerator.cxx b/Code/ApplicationEngine/otbWrapperApplicationHtmlDocGenerator.cxx index b7690a08980e717d8dc9884c11518e3c91b8bbae..a1c5c59d927ca2519c5560c058985e9a72cdda9d 100644 --- a/Code/ApplicationEngine/otbWrapperApplicationHtmlDocGenerator.cxx +++ b/Code/ApplicationEngine/otbWrapperApplicationHtmlDocGenerator.cxx @@ -136,14 +136,14 @@ ApplicationHtmlDocGenerator::GenerateDoc(const Application::Pointer app, const s ApplicationHtmlDocGenerator::GenerateDoc( app, doc ); - std::ofstream ofs(filename.c_str()); + std::ofstream ofs(filename.c_str()); if (!ofs.is_open()) { fprintf(stderr, "Error, can't open file"); itkGenericExceptionMacro( << "Error, can't open file "<<filename<<"."); } ofs << doc; - ofs.close(); + ofs.close(); } void ApplicationHtmlDocGenerator::GetDocParameters( const Application::Pointer app, std::string & val) diff --git a/Testing/Code/Learning/CMakeLists.txt b/Testing/Code/Learning/CMakeLists.txt index 517639deae9db4cc0724c08ca6c78bb90b2e7984..5c3a6e0ad1eaebcc75e2aacbedad626275342f98 100644 --- a/Testing/Code/Learning/CMakeLists.txt +++ b/Testing/Code/Learning/CMakeLists.txt @@ -549,13 +549,6 @@ SET_TESTS_PROPERTIES(leTvConfusionMatrixCalculatorWrongSize PROPERTIES WILL_FAIL ADD_TEST(leTvConfusionMatrixCalculatorUpdate ${LEARNING_TESTS4} 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 ---------- ADD_TEST(leTuShiftScaleSampleListFilterNew ${LEARNING_TESTS4} otbShiftScaleSampleListFilterNew) @@ -715,7 +708,6 @@ otbExhaustiveExponentialOptimizerNew.cxx otbExhaustiveExponentialOptimizerTest.cxx otbListSampleGeneratorTest.cxx otbConfusionMatrixCalculatorTest.cxx -otbSVMValidation.cxx otbShiftScaleSampleListFilter.cxx otbGaussianAdditiveNoiseSampleListFilter.cxx otbConcatenateSampleListFilter.cxx diff --git a/Testing/Code/Learning/otbLearningTests4.cxx b/Testing/Code/Learning/otbLearningTests4.cxx index 84514a1ad8c60944b6da474def87b9cd40d6ba55..c499e0900a0677c3fcb097bb83d52e355310a50b 100644 --- a/Testing/Code/Learning/otbLearningTests4.cxx +++ b/Testing/Code/Learning/otbLearningTests4.cxx @@ -35,7 +35,6 @@ void RegisterTests() REGISTER_TEST(otbConfusionMatrixCalculatorSetListSamples); REGISTER_TEST(otbConfusionMatrixCalculatorWrongSize); REGISTER_TEST(otbConfusionMatrixCalculatorUpdate); - REGISTER_TEST(otbSVMValidation); REGISTER_TEST(otbShiftScaleSampleListFilterNew); REGISTER_TEST(otbShiftScaleSampleListFilter); REGISTER_TEST(otbGaussianAdditiveNoiseSampleListFilterNew); diff --git a/Testing/Code/Learning/otbSVMValidation.cxx b/Testing/Fa/0000209-SVMValidationLinearlySeparableProbEstimation.cxx similarity index 81% rename from Testing/Code/Learning/otbSVMValidation.cxx rename to Testing/Fa/0000209-SVMValidationLinearlySeparableProbEstimation.cxx index f02006a9e86f2e4e5c6d16f488317d0e286ac380..6b0d80cb148e9d0097d1491fda3c8dd371c78fc1 100644 --- a/Testing/Code/Learning/otbSVMValidation.cxx +++ b/Testing/Fa/0000209-SVMValidationLinearlySeparableProbEstimation.cxx @@ -34,25 +34,37 @@ #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; return EXIT_FAILURE; } - unsigned int nbTrainingSamples = atoi(argv[1]); - unsigned int nbValidationSamples = atoi(argv[2]); - double cpx = atof(argv[3]); - double cpy = atof(argv[4]); - double cnx = atof(argv[5]); - double cny = atof(argv[6]); - double prmin = atof(argv[7]); - double prmax = atof(argv[8]); - double nrmin = atof(argv[9]); - double nrmax = atof(argv[10]); - unsigned int kernel = atoi(argv[11]); - bool probEstimate = atoi(argv[12]); + unsigned int nbTrainingSamples = atoi(argv[2]); + unsigned int nbValidationSamples = atoi(argv[3]); + double cpx = atof(argv[4]); + double cpy = atof(argv[5]); + double cnx = atof(argv[6]); + double cny = atof(argv[7]); + double prmin = atof(argv[8]); + double prmax = atof(argv[9]); + double nrmin = atof(argv[10]); + double nrmax = atof(argv[11]); + unsigned int kernel = atoi(argv[12]); + bool probEstimate = atoi(argv[13]); typedef double InputPixelType; typedef unsigned short LabelType; @@ -79,7 +91,7 @@ int otbSVMValidation(int argc, char* argv[]) TrainingListSampleType::Pointer validationLabels = TrainingListSampleType::New(); // Generate training set -// std::ofstream training("training.csv"); + //std::ofstream training("training.csv"); for(unsigned int i =0; i < nbTrainingSamples; ++i) { // Generate a positive sample @@ -93,7 +105,7 @@ int otbSVMValidation(int argc, char* argv[]) trainingSamples->PushBack(pSample); 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 angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI ); @@ -105,14 +117,14 @@ int otbSVMValidation(int argc, char* argv[]) trainingSamples->PushBack(nSample); 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 -// std::ofstream validation("validation.csv"); + std::ofstream validation("validation.csv"); for(unsigned int i =0; i < nbValidationSamples; ++i) { // Generate a positive sample @@ -125,7 +137,7 @@ int otbSVMValidation(int argc, char* argv[]) label[0]=1; validationSamples->PushBack(pSample); 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 angle = random->GetVariateWithOpenUpperRange( otb::CONST_2PI ); @@ -136,10 +148,10 @@ int otbSVMValidation(int argc, char* argv[]) label[0]=2; validationSamples->PushBack(nSample); 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 EstimatorType::Pointer estimator = EstimatorType::New(); @@ -151,7 +163,7 @@ int otbSVMValidation(int argc, char* argv[]) // estimator->SetParametersOptimization(true); estimator->Update(); -// estimator->SaveModel("model.svm"); + //estimator->SaveModel("model.svm"); // Classify ClassifierType::Pointer validationClassifier = ClassifierType::New(); diff --git a/Testing/Fa/CMakeLists.txt b/Testing/Fa/CMakeLists.txt index 561014d58348dd85bc5d3e1c5b29ca0fcb44398c..7c1d0097c56e8538eb82ed3bb0dece58b1c79683 100644 --- a/Testing/Fa/CMakeLists.txt +++ b/Testing/Fa/CMakeLists.txt @@ -258,6 +258,14 @@ ADD_TEST(faTvWriteUnsignedLong ${CXX_TEST_PATH}/WriteUnsignedLong ${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 ----------------------------------- # FIXME Desactivated until http://bugs.orfeo-toolbox.org/view.php?id=94 # has somebody working on it @@ -302,4 +310,7 @@ TARGET_LINK_LIBRARIES(SensorModelBorder OTBIO OTBCommon OTBBasicFilters OTBProje ADD_EXECUTABLE(WriteUnsignedLong WriteUnsignedLong.cxx) 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 )