opencv3训练SVM数据

本文档介绍了如何使用OpenCV3进行SVM(支持向量机)训练,首先强调样本图片需要统一尺寸,接着详细阐述了训练SVM的步骤,最后讲解了如何运用已训练的数据。
摘要由CSDN通过智能技术生成

 样本图片要一样大

1.训练SVM 


#include <stdio.h>  
#include <time.h>  
#include <opencv2/opencv.hpp>  
#include <opencv/cv.h>  
#include <iostream> 
#include <opencv2/core/core.hpp>  
#include <opencv2/highgui/highgui.hpp>  
#include <opencv2/ml/ml.hpp>  
#include <io.h> //查找文件相关函数

using namespace std;
using namespace cv;

using namespace cv::ml;

void getFiles(string path, vector<string>& files);
void getBubble(Mat& trainingImages, vector<int>& trainingLabels);
void getNoBubble(Mat& trainingImages, vector<int>& trainingLabels);

int main()
{
	//获取训练数据
	Mat classes;
	Mat trainingData;
	Mat trainingImages;



	vector<int> trainingLabels;

	//getBubble()与getNoBubble()将获取一张图片后会将图片(特征)写入
	//  到容器中,紧接着会将标签写入另一个容器中,这样就保证了特征
	//  和标
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值