【SVM模型训练】

SVM模型训练

1. 制作数据集及标签:

void generate_dataset(Mat &trainData, Mat &labels) {
	vector images;
	vector> vecDec;
	vector fv;
	glob(positive_dir, images);
	int posNum = images.size();
	for (int i = 0; i < posNum; i++)
	{
		Mat image = imread(images[i].c_str());
		vector fv;
		get_hog_descripor(image, fv);
		printf("image path : %s, feature data length: %d \n", images[i].c_str(), fv.size());
		vecDec.push_back(fv);
	}
	images.clear();
	glob(negative_dir, images);
	int negNum = images.size();
	for (int i = 0; i < negNum; i++)
	{
		fv.clear();
		Mat image = imread(images[i].c_str());
		get_hog_descripor(image, fv);
		printf("image path : %s, feature data length: %d \n", images[i].c_str(), fv.size());
		vecDec.push_back(fv);
	}
	int trainDataNum = posNum + negNum;
	int trainDataLen &

你可能感兴趣的:(人工智能)