From eab17f355836682faec1a76d9daf083e52b2c841 Mon Sep 17 00:00:00 2001 From: Christophe Palmann <christophe.palmann@c-s.fr> Date: Thu, 19 Mar 2015 14:14:31 +0100 Subject: [PATCH] ENH: fixed otbTrainOGRLayersClassifier and OGRLayerClassifier apps comp. when libsvm and opencv modules are not installed --- .../AppClassification/app/otbOGRLayerClassifier.cxx | 10 ++++++++++ .../app/otbTrainOGRLayersClassifier.cxx | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx index 5187de4bbb..e01c08a67b 100644 --- a/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbOGRLayerClassifier.cxx @@ -26,7 +26,10 @@ #include "itkListSample.h" #include "otbShiftScaleSampleListFilter.h" + +#ifdef OTB_USE_LIBSVM #include "otbLibSVMMachineLearningModel.h" +#endif #include <time.h> @@ -119,6 +122,8 @@ private: void DoExecute() { + + #ifdef OTB_USE_LIBSVM clock_t tic = clock(); std::string shapefile = GetParameterString("inshp").c_str(); @@ -214,6 +219,11 @@ private: clock_t toc = clock(); otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); + + #elseif + otbAppLogFATAL("Module LIBSVM is not installed. You should consider turning OTB_USE_LIBSVM on during cmake configuration."); + #endif + } }; diff --git a/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx b/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx index 54141604e1..2e4faf9551 100644 --- a/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbTrainOGRLayersClassifier.cxx @@ -26,7 +26,10 @@ #include "itkListSample.h" #include "otbShiftScaleSampleListFilter.h" + +#ifdef OTB_USE_LIBSVM #include "otbLibSVMMachineLearningModel.h" +#endif #include <time.h> @@ -118,6 +121,7 @@ private: void DoExecute() { + #ifdef OTB_USE_LIBSVM clock_t tic = clock(); std::string shapefile = GetParameterString("inshp"); @@ -197,6 +201,11 @@ private: clock_t toc = clock(); otbAppLogINFO( "Elapsed: "<< ((double)(toc - tic) / CLOCKS_PER_SEC)<<" seconds."); + + #elseif + otbAppLogFATAL("Module LIBSVM is not installed. You should consider turning OTB_USE_LIBSVM on during cmake configuration."); + #endif + } }; -- GitLab