Commit c7091eae authored by Julien Michel's avatar Julien Michel
Browse files

Déplacement de la librairie SVM dans Utilities/otbsvm.

parent 7d4f906d
......@@ -4,7 +4,7 @@
FILE(GLOB OTBLearning_SRCS "*.cxx" )
ADD_LIBRARY(OTBLearning ${OTBLearning_SRCS})
TARGET_LINK_LIBRARIES (OTBLearning OTBCommon OTBIO ITKCommon ITKIO)
TARGET_LINK_LIBRARIES (OTBLearning otbsvm OTBCommon OTBIO ITKCommon ITKIO)
INSTALL_TARGETS(/lib/otb OTBLearning )
INSTALL_FILES(/include/otb/Learning "(\\.h|\\.txx)$")
This diff is collapsed.
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _LIBSVM_H
#define _LIBSVM_H
#ifdef __cplusplus
extern "C" {
#endif
struct svm_node
{
int index;
double value;
};
struct svm_problem
{
int l;
double *y;
struct svm_node **x;
};
enum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR }; /* svm_type */
enum { LINEAR, POLY, RBF, SIGMOID }; /* kernel_type */
struct svm_parameter
{
int svm_type;
int kernel_type;
double degree; /* for poly */
double gamma; /* for poly/rbf/sigmoid */
double coef0; /* for poly/sigmoid */
/* these are for training only */
double cache_size; /* in MB */
double eps; /* stopping criteria */
double C; /* for C_SVC, EPSILON_SVR and NU_SVR */
int nr_weight; /* for C_SVC */
int *weight_label; /* for C_SVC */
double* weight; /* for C_SVC */
double nu; /* for NU_SVC, ONE_CLASS, and NU_SVR */
double p; /* for EPSILON_SVR */
int shrinking; /* use the shrinking heuristics */
int probability; /* do probability estimates */
};
struct svm_model
{
svm_parameter param; // parameter
int nr_class; // number of classes, = 2 in regression/one class svm
int l; // total #SV
svm_node **SV; // SVs (SV[l])
double **sv_coef; // coefficients for SVs in decision functions (sv_coef[n-1][l])
double *rho; // constants in decision functions (rho[n*(n-1)/2])
double *probA; // pariwise probability information
double *probB;
// for classification only
int *label; // label of each class (label[n])
int *nSV; // number of SVs for each class (nSV[n])
// nSV[0] + nSV[1] + ... + nSV[n-1] = l
// XXX
int free_sv; // 1 if svm_model is created by svm_load_model
// 0 if svm_model is created by svm_train
};
struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);
void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);
int svm_save_model(const char *model_file_name, const struct svm_model *model);
struct svm_model *svm_load_model(const char *model_file_name);
int svm_get_svm_type(const struct svm_model *model);
int svm_get_nr_class(const struct svm_model *model);
void svm_get_labels(const struct svm_model *model, int *label);
double svm_get_svr_probability(const struct svm_model *model);
void svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);
double svm_predict(const struct svm_model *model, const struct svm_node *x);
double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);
void svm_destroy_model(struct svm_model *model);
void svm_destroy_param(struct svm_parameter *param);
const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);
int svm_check_probability_model(const struct svm_model *model);
#ifdef __cplusplus
}
#endif
#endif /* _LIBSVM_H */
......@@ -147,7 +147,7 @@ otbSOMActivationBuilder.cxx
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
ADD_EXECUTABLE(otbLearningTests otbLearningTests.cxx ${BasicLearning_SRCS})
TARGET_LINK_LIBRARIES(otbLearningTests gdal OTBLearning OTBCommon OTBIO ITKIO ITKCommon)
TARGET_LINK_LIBRARIES(otbLearningTests gdal otbsvm OTBLearning OTBCommon OTBIO ITKIO ITKCommon)
ENDIF( NOT OTB_DISABLE_CXX_TESTING )
......
......@@ -54,7 +54,7 @@ ADD_EXECUTABLE(otbImageViewerWithitkImage otbImageViewerWithitkImage.cxx)
TARGET_LINK_LIBRARIES(otbImageViewerWithitkImage OTBVisu OTBIO OTBCommon gdal ITKIO ITKCommon)
ADD_EXECUTABLE(otbImageViewerAS otbImageViewerAS.cxx)
TARGET_LINK_LIBRARIES(otbImageViewerAS OTBVisu OTBIO OTBCommon gdal ITKIO ITKCommon)
TARGET_LINK_LIBRARIES(otbImageViewerAS OTBVisu OTBIO OTBCommon otbsvm gdal ITKIO ITKCommon)
ENDIF( NOT OTB_DISABLE_CXX_TESTING )
......
......@@ -4,7 +4,8 @@ IF(NOT OTB_USE_EXTERNAL_ITK)
SUBDIRS( ITK )
ENDIF(NOT OTB_USE_EXTERNAL_ITK)
SUBDIRS( BGL )
SUBDIRS( BGL otbsvm )
#-----------------------------------------------------------------------------
# Install the UseOTB.cmake file configured from the top-level.
......
......@@ -22,6 +22,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${OTB_BINARY_DIR}/Code/Visu
${OTB_SOURCE_DIR}/Utilities/BGL
${OTB_SOURCE_DIR}/Utilities/BGL/boost
${OTB_SOURCE_DIR}/Utilities/otbsvm
)
#-----------------------------------------------------------------------------
......@@ -78,6 +79,7 @@ SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}
${OTB_INSTALL_INCLUDE_DIR}/Utilities/ITK
${OTB_INSTALL_INCLUDE_DIR}/Utilities/BGL
${OTB_INSTALL_INCLUDE_DIR}/Utilities/BGL/boost
${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbsvm
)
SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}
......
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