#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
ifstream in("F:\\DataSets\\dataset1.txt");
if(!in)
{
cerr << "some errors happened";
return -1;
}
const char *pathname0 = "F:\\DataSets\\imagebase1\\imagebase\\";
const char *pathname1 = "F:\\DataSets\\imgdb1\\";
char imagename0[200];
char imagename1[200];
string str;
int count = 1;
while(getline(in, str))
{
if (count%100 == 1)
{
cout<<"-----------------第 "<<count<<" 幅图像处理中---------------\n";
}
count++;
strcpy(imagename0,pathname0);
strcpy(imagename1,str.c_str());
strcat(imagename0,imagename1);
// cout<<imagename0<<endl;
IplImage *image = cvLoadImage(imagename0, CV_LOAD_IMAGE_COLOR);
if (image == NULL)
{
cout<<imagename0<<endl;
}
for (int i=0;i<strlen(imagename1);i++)
{
if (imagename1[i]=='#'||imagename1[i]==' ')
{
imagename1[i] = '_';
}
}
strcpy(imagename0,pathname1);
strcat(imagename0,imagename1);
// cout<<imagename0<<endl;
int restlt = cvSaveImage(imagename0,image);
if (restlt==0)
{
cout<<imagename0<<endl;
}
cvReleaseImage(&image);
}
}
批量对txt里列出的图像去掉空格和#
最新推荐文章于 2022-09-01 11:58:21 发布