Commit 1fcbde84 authored by Christophe Palmann's avatar Christophe Palmann

COMP: fixed comp. of other tests when OTB_USE_LIBSVM and OTB_USE_OPENCV are turned off

parent 91700598
......@@ -17,7 +17,13 @@
=========================================================================*/
#include <iostream>
#include <otbMachineLearningModel.h>
#ifdef OTB_USE_LIBSVM
#include "otbLibSVMMachineLearningModel.h"
#endif
#ifdef OTB_USE_OPENCV
#include "otbSVMMachineLearningModel.h"
#include "otbRandomForestsMachineLearningModel.h"
#include "otbBoostMachineLearningModel.h"
......@@ -26,6 +32,7 @@
#include "otbDecisionTreeMachineLearningModel.h"
#include "otbGradientBoostedTreeMachineLearningModel.h"
#include "otbKNearestNeighborsMachineLearningModel.h"
#endif
typedef otb::MachineLearningModel<float,short> MachineLearningModelType;
typedef MachineLearningModelType::InputValueType InputValueType;
......@@ -49,6 +56,8 @@ int otbLibSVMMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_LIBSVM
typedef otb::LibSVMMachineLearningModel<InputValueType, TargetValueType> SVMType;
SVMType::Pointer classifier = SVMType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -57,6 +66,7 @@ int otbLibSVMMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::LibSVMMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -75,6 +85,8 @@ int otbSVMMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::SVMMachineLearningModel<InputValueType, TargetValueType> SVMType;
SVMType::Pointer classifier = SVMType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -83,6 +95,7 @@ int otbSVMMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::SVMMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -101,6 +114,8 @@ int otbRandomForestsMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::RandomForestsMachineLearningModel<InputValueType, TargetValueType> RFType;
RFType::Pointer classifier = RFType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -109,6 +124,7 @@ int otbRandomForestsMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::RandomForestsMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -127,6 +143,8 @@ int otbBoostMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::BoostMachineLearningModel<InputValueType, TargetValueType> BoostType;
BoostType::Pointer classifier = BoostType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -135,6 +153,7 @@ int otbBoostMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::BoostMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -153,6 +172,8 @@ int otbNeuralNetworkMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::NeuralNetworkMachineLearningModel<InputValueType, TargetValueType> ANNType;
ANNType::Pointer classifier = ANNType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -161,6 +182,7 @@ int otbNeuralNetworkMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::NeuralNetworkMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -179,6 +201,8 @@ int otbNormalBayesMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::NormalBayesMachineLearningModel<InputValueType, TargetValueType> NormalBayesType;
NormalBayesType::Pointer classifier = NormalBayesType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -187,6 +211,7 @@ int otbNormalBayesMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::NormalBayesMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -205,6 +230,8 @@ int otbDecisionTreeMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::DecisionTreeMachineLearningModel<InputValueType, TargetValueType> DecisionTreeType;
DecisionTreeType::Pointer classifier = DecisionTreeType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -213,6 +240,7 @@ int otbDecisionTreeMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::DecisionTreeMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -231,6 +259,8 @@ int otbGradientBoostedTreeMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::GradientBoostedTreeMachineLearningModel<InputValueType, TargetValueType> GBTreeType;
GBTreeType::Pointer classifier = GBTreeType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -239,6 +269,7 @@ int otbGradientBoostedTreeMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::GradientBoostedTreeMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......@@ -257,6 +288,8 @@ int otbKNNMachineLearningModelCanRead(int argc, char* argv[])
return EXIT_FAILURE;
}
std::string filename(argv[1]);
#ifdef OTB_USE_OPENCV
typedef otb::KNearestNeighborsMachineLearningModel<InputValueType, TargetValueType> KNNType;
KNNType::Pointer classifier = KNNType::New();
bool lCanRead = classifier->CanReadFile(filename);
......@@ -265,6 +298,7 @@ int otbKNNMachineLearningModelCanRead(int argc, char* argv[])
std::cerr << "Erreur otb::KNearestNeighborsMachineLearningModel : impossible to open the file " << filename << "." << std::endl;
return EXIT_FAILURE;
}
#endif
return EXIT_SUCCESS;
}
......
......@@ -9,7 +9,12 @@ void RegisterTests()
REGISTER_TEST(otbConfusionMatrixMeasurementsNew);
REGISTER_TEST(otbConfusionMatrixMeasurementsTest);
REGISTER_TEST(otbConfusionMatrixConcatenateTest);
#ifdef OTB_USE_LIBSVM
REGISTER_TEST(otbLibSVMMachineLearningModelCanRead);
#endif
#ifdef OTB_USE_OPENCV
REGISTER_TEST(otbSVMMachineLearningModelCanRead);
REGISTER_TEST(otbRandomForestsMachineLearningModelCanRead);
REGISTER_TEST(otbBoostMachineLearningModelCanRead);
......@@ -18,8 +23,14 @@ void RegisterTests()
REGISTER_TEST(otbDecisionTreeMachineLearningModelCanRead);
REGISTER_TEST(otbGradientBoostedTreeMachineLearningModelCanRead);
REGISTER_TEST(otbKNNMachineLearningModelCanRead);
#endif
#ifdef OTB_USE_LIBSVM
REGISTER_TEST(otbLibSVMMachineLearningModelNew);
REGISTER_TEST(otbLibSVMMachineLearningModel);
#endif
#ifdef OTB_USE_OPENCV
REGISTER_TEST(otbSVMMachineLearningModelNew);
REGISTER_TEST(otbSVMMachineLearningModel);
REGISTER_TEST(otbSVMMachineLearningRegressionModel);
......@@ -37,6 +48,8 @@ void RegisterTests()
REGISTER_TEST(otbDecisionTreeMachineLearningModel);
REGISTER_TEST(otbGradientBoostedTreeMachineLearningModelNew);
REGISTER_TEST(otbGradientBoostedTreeMachineLearningModel);
#endif
REGISTER_TEST(otbImageClassificationFilterNew);
REGISTER_TEST(otbImageClassificationFilter);
}
......@@ -20,7 +20,13 @@
#include <string>
#include <algorithm>
#include <otbMachineLearningModel.h>
#ifdef OTB_USE_LIBSVM
#include "otbLibSVMMachineLearningModel.h"
#endif
#ifdef OTB_USE_OPENCV
#include "otbSVMMachineLearningModel.h"
#include "otbKNearestNeighborsMachineLearningModel.h"
#include "otbRandomForestsMachineLearningModel.h"
......@@ -30,6 +36,7 @@
#include "otbDecisionTreeMachineLearningModel.h"
#include "otbGradientBoostedTreeMachineLearningModel.h"
#include "otbKNearestNeighborsMachineLearningModel.h"
#endif
#include "otbConfusionMatrixCalculator.h"
......@@ -188,6 +195,7 @@ bool ReadDataRegressionFile(const std::string & infname, InputListSampleRegressi
return true;
}
#ifdef OTB_USE_LIBSVM
int otbLibSVMMachineLearningModelNew(int itkNotUsed(argc), char * itkNotUsed(argv) [])
{
typedef otb::LibSVMMachineLearningModel<InputValueType, TargetValueType> SVMType;
......@@ -276,7 +284,9 @@ int otbSVMMachineLearningModelNew(int itkNotUsed(argc), char * itkNotUsed(argv)
SVMType::Pointer svmclassifier = SVMType::New();
return EXIT_SUCCESS;
}
#endif
#ifdef OTB_USE_OPENCV
int otbSVMMachineLearningModel(int argc, char * argv[])
{
if (argc != 3 )
......@@ -1036,3 +1046,4 @@ int otbGradientBoostedTreeMachineLearningModel(int argc, char * argv[])
return EXIT_FAILURE;
}
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment