// testopencv.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <opencv2\opencv.hpp>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
using namespace cv;
void getFileName(string & filename,vector<string> &vstr)
{
cout<<"begin read file name from "<< filename<<endl;
string name;
ifstream in(filename);
while(!in.eof())
{
in>>name;
vstr.push_back(name);
}
cout<<"end read filename , the total image number is "<< vstr.size()<<endl;
}
void writeIntegral(vector<string> &vstr,string& filename)
{
cout<<"begin calculate the image integral"<<endl;
ofstream out(filename,ofstream::binary);
int num = ;
vector<string>::iterator begin = vstr.begin();
for( ;begin != vstr.end(); begin++)
{
//第二个参数为0读进来的image都是灰度的
Mat img = imread(*begin,);
if(img.empty())
{
cout<<"read image "<<*begin<<" failed"<<endl;
continue;
}
num++;
Mat gray_img;
CvMat sour_image=gray_img;
CvMat *inte_image = cvCreateMat(gray_img.rows+,gray_img.cols+,CV_32F);
cvIntegral(&sour_image,inte_image);
float *f = inte_image->data.fl;
out.write((char*)(f),inte_image->width*inte_image->height*sizeof(float));
}
out.close();
cout<<"total image:"<<vstr.size()<<" cvIntegral number:"<<num<<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> v;
getFileName(string("face.txt"),v);
writeIntegral(v,string("face.dat"));
waitKey();
return ;
}