如何判断opencv中CvSVMParams的默认参数

How can I tell what the default parameters are for CvSVMParams in opencv?

本文关键字:CvSVMParams 默认 参数 opencv 何判断 判断      更新时间:2023-10-16

我对opencv还很陌生,刚刚习惯C++编程,所以这个问题可能很傻。如果我将"struct-CvSVMParams"中的参数保留为默认值并在不修改它们的情况下训练分类器,那么它们是用什么值初始化的?

好吧,因为opencv是开源的,所以你可以看看源代码

但仅仅用谷歌搜索它通常会更快,比如https://www.google.no/search?q=struct+CvSVM参数

然后右键单击第三个点击,最后到达opencv文档http://docs.opencv.org/modules/ml/doc/support_vector_machines.html

然后使用浏览器的页面搜索功能(通常[Ctrl F]表示"查找")在该页面中查找文本"CvSVMParams",然后向下搜索页面http://docs.opencv.org/modules/ml/doc/support_vector_machines.html#cvsvmparams-cvsvmparams

此时需要阅读文档

这是一项必不可少的技能,所以我不会在0.5秒内重复我在这里发现的东西,从而破坏它–看看就知道了。我还建议你自己从头开始搜索。因为这也是你需要的一项基本技能,必须经过

的培训

这里是构造函数:

https://github.com/Itseez/opencv/blob/ddf82d0b154873510802ef75c53e628cd7b2cb13/modules/ml/src/svm.cpp

// SVM training parameters
struct SvmParams
{
    int         svmType;
    int         kernelType;
    double      gamma;
    double      coef0;
    double      degree;
    double      C;
    double      nu;
    double      p;
    Mat         classWeights;
    TermCriteria termCrit;
    SvmParams()
    {
        svmType = SVM::C_SVC;
        kernelType = SVM::RBF;
        degree = 0;
        gamma = 1;
        coef0 = 0;
        C = 1;
        nu = 0;
        p = 0;
        termCrit = TermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 1000, FLT_EPSILON );
    }
    SvmParams( int _svmType, int _kernelType,
            double _degree, double _gamma, double _coef0,
            double _Con, double _nu, double _p,
            const Mat& _classWeights, TermCriteria _termCrit )
    {
        svmType = _svmType;
        kernelType = _kernelType;
        degree = _degree;
        gamma = _gamma;
        coef0 = _coef0;
        C = _Con;
        nu = _nu;
        p = _p;
        classWeights = _classWeights;
        termCrit = _termCrit;
    }
};