1.代码如下
#include<iostream>
#include<time.h>
#include<opencv2/opencv.hpp>
#include<fstream>
using namespace std;
using namespace cv;
void main()
{
ifstream file("d:/filelist.txt");
int img_index = 0;
while (!file.eof())
{
char txt_cont[24];
file.getline(txt_cont,24);
char img_file[24],save_file[24];
sprintf(img_file, "d:/pic2/%s", txt_cont);
sprintf(save_file, "d:/pic3/%d.jpg", img_index);
Mat src = imread(img_file);
Mat crs;
cvtColor(src,crs,CV_RGB2GRAY);
img_index++;
imwrite(save_file,crs);
}
}
运行完出现了如下警告
这是什么意思,该怎么办啊?
2第二种批量处理代码如下
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace cv;
using namespace std;
int main()
{
std::string pattern_jpg = "D:/pic2/*.png";
std::string savefile="D:/pic3";
std::vector<cv::String> image_files;
cv::glob(pattern_jpg, image_files);
for (unsigned int frame = 0; frame < image_files.size(); ++frame) //image_file.size()代表文件中总共的图片个数
{
Mat image = cv::imread(image_files[frame]);
Mat dst;
cvtColor(image,dst,CV_RGB2GRAY);
imshow("1",dst);
imwrite(savefile,dst);
waitKey(30);
}
}
出现了相同警告,请问该如何修改?
谢谢。