学习OpenCV——HOG+SVM

#include "cv.h"
#include "highgui.h"
#include "stdafx.h"
#include <ml.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace cv;
using namespace std;


int main(int argc, char** argv)  
{  
	vector<string> img_path;
	vector<int> img_catg;
	int nLine = 0;
	string buf;
	ifstream svm_data( "E:/SVM_DATA.txt" );
	unsigned long n;

	while( svm_data )
	{
		if( getline( svm_data, buf ) )
		{
			nLine ++;
			if( nLine % 2 == 0 )
			{
				 img_catg.push_back( atoi( buf.c_str() ) );//atoi将字符串转换成整型,标志(0,1)
			}
			else
			{
				img_path.push_back( buf );//图像路径
			}
		}
	}
	svm_data.close();//关闭文件

	CvMat *data_mat, *res_mat;
	int nImgNum = nLine / 2;			//读入样本数量
	样本矩阵,nImgNum:横坐标是样本数量, WIDTH * HEIGHT:样本特征向量,即图像大小
	data_mat = cvCreateMat( nImgNum, 1764, CV_32FC1 );
	cvSetZer
  • 2
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 95
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 95
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值