diff --git a/Testing/Code/Learning/otbSVMClassifierImage.cxx b/Testing/Code/Learning/otbSVMClassifierImage.cxx index 91108d8e4ebbcf87aea42d65bf36b4b997fddc44..3c30b81e99bdb0a0ace811144250feef3bf8901d 100644 --- a/Testing/Code/Learning/otbSVMClassifierImage.cxx +++ b/Testing/Code/Learning/otbSVMClassifierImage.cxx @@ -22,15 +22,7 @@ #include <fstream> -/*#include "itkPoint.h" -#include "itkPointSet.h" - - -#include "itkPointSetToListAdaptor.h" -#include "itkSubsample.h"*/ - #include "itkListSample.h" - #include "otbImage.h" #include "otbVectorImage.h" #include "itkImageToListAdaptor.h" @@ -46,13 +38,35 @@ namespace otb class Linear : public GenericKernelFunctorBase { public: + typedef Linear Self; + typedef GenericKernelFunctorBase Superclass; + Linear() : GenericKernelFunctorBase() {} virtual ~Linear() {} - virtual double operator ()(const svm_node *x, const svm_node *y, const svm_parameter& param) const + // Deep copy operator + virtual GenericKernelFunctorBase* Clone() const + { + return new Self(*this); + } + + virtual double operator ()(const svm_node *x, const svm_node *y, const svm_parameter&) const { return this->dot(x, y); } + +protected: + Linear(const Self& copy) + : Superclass(copy) + { + *this = copy; + } + + Linear& operator=(const Self& copy) + { + Superclass::operator =(copy); + return *this; + } }; } diff --git a/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageClassificationTest.cxx b/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageClassificationTest.cxx index 0de7effa0aaa34eb82f9b7a9c48ed5cc5bd0fc27..2e0cd998ab32b11959de56eb6d86ce804ee45a35 100644 --- a/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageClassificationTest.cxx +++ b/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageClassificationTest.cxx @@ -35,6 +35,12 @@ int otbSVMInverseCosSpectralAngleKernelFunctorImageClassificationTest(int argc, char* argv[]) { + if (argc != 4) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EXIT_FAILURE; + } + const char* inputImageFileName = argv[1]; const char* trainingImageFileName = argv[2]; const char* outputModelFileName = argv[3]; diff --git a/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageModelEstimatorTest.cxx b/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageModelEstimatorTest.cxx index 2b353ecc18c4ecab9223c92175db1c931e62f443..288d374cef21ef340c012875856c9281232a21af 100644 --- a/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageModelEstimatorTest.cxx +++ b/Testing/Code/Learning/otbSVMInverseCosSpectralAngleKernelFunctorImageModelEstimatorTest.cxx @@ -34,6 +34,12 @@ int otbSVMInverseCosSpectralAngleKernelFunctorImageModelEstimatorTest(int argc, char* argv[]) { + if (argc != 4) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EXIT_FAILURE; + } + const char* inputImageFileName = argv[1]; const char* trainingImageFileName = argv[2]; const char* outputModelFileName = argv[3]; diff --git a/Testing/Code/Learning/otbSVMModelCopyComposedKernelTest.cxx b/Testing/Code/Learning/otbSVMModelCopyComposedKernelTest.cxx index 83ee2602448e7f4cc5cdfa6d877983092a1e3de7..7cde85c271a45f894e559e5dce6a07dece207daf 100644 --- a/Testing/Code/Learning/otbSVMModelCopyComposedKernelTest.cxx +++ b/Testing/Code/Learning/otbSVMModelCopyComposedKernelTest.cxx @@ -27,6 +27,13 @@ int otbSVMModelCopyComposedKernelTest(int argc, char* argv[]) { + if (argc != 3) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EXIT_FAILURE; + } + + typedef unsigned char InputPixelType; typedef unsigned char LabelPixelType; diff --git a/Testing/Code/Learning/otbSVMModelCopyGenericKernelTest.cxx b/Testing/Code/Learning/otbSVMModelCopyGenericKernelTest.cxx index c72b41096b2d50ae86d947233ce15c770b16a2a8..a3a3f806802678587f2664e1fa44a7bc0edae77a 100644 --- a/Testing/Code/Learning/otbSVMModelCopyGenericKernelTest.cxx +++ b/Testing/Code/Learning/otbSVMModelCopyGenericKernelTest.cxx @@ -27,6 +27,12 @@ int otbSVMModelCopyGenericKernelTest(int argc, char* argv[]) { + if (argc != 3) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EXIT_FAILURE; + } + typedef unsigned char InputPixelType; typedef unsigned char LabelPixelType;