版权声明:guojawee https://blog.csdn.net/weixin_36750623/article/details/84782587
读取eye/open下的所有图像,将图像的(0,0,长,宽)保存到txt文件中
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
using namespace cv;
string path_ = "C:\\Users\\GuoJawee\\Desktop\\open\\"; //图像存放的路径
FILE *fp = fopen("C:\\Users\\GuoJawee\\Desktop\\open.txt", "w");
void getJustCurrentFile(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))
{
;
}
else
{
files.push_back(fileinfo.name);
cout << fileinfo.name << endl;
string fileName = path_;
fileName.append(fileinfo.name);
Mat img = imread(fileName,1);
imshow("tmp", img);
waitKey(10);
char temp[1024];
sprintf(temp, "%s open 0 0 %d %d\n", fileinfo.name, img.cols, img.rows);
fwrite(temp, 1, strlen(temp), fp);
//files.push_back(p.assign(path).append("\\").append(fileinfo.name) );
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
}
int main()
{
vector<string> files;
getJustCurrentFile(path_, files);
return 0;
}