genericKernel.h 847 B

12345678910111213141516171819202122232425262728293031323334353637
  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. class GenericKernelSelection
  8. {
  9. public:
  10. static Kernel *selectKernel ( const NICE::Config *conf, std::string kernel_type )
  11. {
  12. Kernel *kernel = NULL;
  13. if ( kernel_type == "rbf" ) {
  14. double log_rbf_gamma = conf->gD("Kernel","log_rbf_gamma",-2.5);
  15. kernel = new KernelRBF (log_rbf_gamma);
  16. } else if ( kernel_type == "exp" ) {
  17. double log_rbf_gamma = conf->gD("Kernel","log_rbf_gamma",-2.5);
  18. double log_rbf_sv = conf->gD("Kernel","log_rbf_sv",0.0);
  19. kernel = new KernelExp (log_rbf_gamma, log_rbf_sv);
  20. } else {
  21. fthrow(Exception, "Kernel type " << kernel_type << " is unknown" );
  22. }
  23. return kernel;
  24. }
  25. };
  26. }
  27. #endif