如何判断opencv中CvSVMParams的默认参数
How can I tell what the default parameters are for CvSVMParams in opencv?
我对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;
}
};
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 如何使用默认参数等选择模板专业化
- 具有默认模板参数的多态类的模板推导失败
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 当函数模板参数是具有默认参数的类模板时,函数模板参数的推导如何执行
- 初始化具有非默认构造函数的std::数组项的更好方法
- 何时提供默认参数作为模板参数
- 是默认情况下分配给char数组常量的值
- 具有默认值的引用获取函数
- 具有默认模板类型的默认构造函数的类型推导
- 当给定默认值时,为什么此模板参数推导失败
- 修改 VS Code 中的默认C++代码段
- 声明默认的模板化函数
- 将const引用参数初始化为默认参数会导致悬空引用吗
- 如何使用非默认构造函数实例化模板化类
- 如何修复带有 clang 的参数'args'缺少默认参数的问题?
- 从具有默认值的部分指定模板类继承时发生SWIG错误,具有不带默认值的正向声明
- 为什么大多数 pair 实现默认不使用压缩(空基优化)?
- 格式化浮点值:返回默认值
- 如何判断opencv中CvSVMParams的默认参数