genericKernel.h 943 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE
  2. #define _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE
  3. #include <vector>
  4. #include "KernelRBF.h"
  5. #include "KernelExp.h"
  6. namespace OBJREC
  7. {
  8. class GenericKernelSelection
  9. {
  10. public:
  11. static Kernel *selectKernel ( const NICE::Config *conf, std::string kernel_type )
  12. {
  13. Kernel *kernel = NULL;
  14. if ( kernel_type == "rbf" )
  15. {
  16. double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
  17. kernel = new KernelRBF ( log_rbf_gamma );
  18. }
  19. else if ( kernel_type == "exp" )
  20. {
  21. double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
  22. double log_rbf_sv = conf->gD ( "Kernel","log_rbf_sv",0.0 );
  23. kernel = new KernelExp ( log_rbf_gamma, log_rbf_sv );
  24. }
  25. else
  26. {
  27. fthrow ( NICE::Exception, "Kernel type " << kernel_type << " is unknown" );
  28. }
  29. return kernel;
  30. }
  31. };
  32. }
  33. #endif