|
简单高效的使用SVM支持向量机:
视频链接:https://pan.baidu.com/s/1xdnckcLcV0jhfsuEbL2Gfg 提取码:qixt
- * 创建SVM支持向量机模型
- * 7是特征总数
- * 3表示分类的类别数
- * 5表示降维后的特征数
- create_class_svm (7, 'rbf', 0.1, 0.0005, 3, 'one-versus-one', 'principal_components', 5, SVMHandle)
- * 一副图像的特征
- * 假设产生一个空的Region
- gen_empty_obj(Region)
- area_center (Region, Area, Row, Column)
- compactness (Region, Compactness)
- moments_region_central_invar (Region, PSI1, PSI2, PSI3, PSI4)
- convexity (Region, Convexity)
- Features := real([Area,Compactness,PSI1,PSI2,PSI3,PSI4,Convexity])
- * ClassNumber为图像对应的类别
- ClassNumber :=0
- add_sample_class_svm (SVMHandle, Features, ClassNumber)
- * 训练
- train_class_svm (SVMHandle, 0.001, 'default')
- write_class_svm (SVMHandle, 'classifier.svm')
- * Clear the classifier from memory
- clear_class_svm (SVMHandle)
- read_class_svm('classifier.svm', SVMHandle)
- *
- * Classify
- * Class表示分类的结果
- classify_class_svm (SVMHandle, Features, 1, Class)
- *
- * Clear the classifier from memory
- clear_class_svm (SVMHandle)
复制代码
|
|