C++实现人脸识别csv文件的写入(加labels)
2016-08-17 09:31
369 查看
前面也写了一个csv是没有加label的(http://blog.csdn.net/u013812682/article/details/52013074),
上次写完因为有点事所以没看这块,才发现少加了label,所以在这里补上
orl下载地址:http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html
代码:
上次写完因为有点事所以没看这块,才发现少加了label,所以在这里补上
orl下载地址:http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html
代码:
#include<iostream> #include<vector> #include<io.h> #include<fstream> using namespace std; ofstream off("csv.txt", ios::out); vector<int> number; int num = 0; void getFiles(string path, vector<string>& files) { //文件句柄 long hFile = 0; //文件信息 struct _finddata_t fileinfo; string p; if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1) { do { //如果是目录,迭代之 //如果不是,加入列表 if ((fileinfo.attrib & _A_SUBDIR)) { if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0){ getFiles(p.assign(path).append("\\").append(fileinfo.name), files); num++; } } else { files.push_back(p.assign(path).append("\\").append(fileinfo.name)); number.push_back(num); } } while (_findnext(hFile, &fileinfo) == 0); _findclose(hFile); } } int main(){ char* filepath = "F:\\opencv\\DATA\\orl"; vector<string> files; getFiles(filepath,files); char str[30]; int size = files.size(); for (int i = 1; i < size; i++){ off << files[i].c_str(); off << " "; off << number[i]; off << "\n"; } off.close(); return 0; }
相关文章推荐
- 人脸识别CSV文件(c++实现)
- c++实现逐行读取配置文件写入内存的示例
- C++开发人脸性别识别教程(5)——通过FaceRecognizer类实现性别识别
- 人脸识别之读取csv文件(opencv)
- C++实现文件简单加密与解密(读取文件中的字符,对字符转换,然后写入,完成加密,解密反之)
- Python实现读取及写入csv文件的方法示例
- 人脸识别性别识别 csv文件生成
- C++实现md5加密或计算文件的唯一性识别
- 简单文件操作(Linux下C++实现) 打开,读取 写入 关闭
- C++开发人脸性别识别——通过SVM实现性别识别
- CSV文件简介及C++实现
- C++开发人脸性别识别教程(6)——通过SVM实现性别识别
- 结合C++和GDAL实现shapefile(shp)文件的创建和写入
- CSV文件的使用-写入/写出(C++/Python)
- C++实现md5加密或计算文件的唯一性识别
- C++开发人脸性别识别教程(5)——通过FaceRecognizer类实现性别识别
- 标准的c++中int,float,double等怎么转换成string类,并实现文件写入
- python 实现将字典写入csv文件
- C++开发人脸性别识别教程(6)——通过SVM实现性别识别
- C++开发人脸性别识别教程(6)——通过SVM实现性别识别