In order to batch processing images, online search for a long time, basically are C language SPRINRF () and sprinrf_s () method; parameter input can only be char* type; here's a simple C + + approach.
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <string>
using namespace CV;
using namespace Std;
int main ()
{
Mat Srcimage;
Mat Dstimage;
Mat Hsvimage;
String FileName;
char* FilePath = "e:\\ material \ \ Overseas bayonet four lane \ \ Radar 4-lane video _ Night \\201603152002\\dir.txt";
char* dir = "e:\\ material \ \ Overseas bayonet four lane \ \ Radar 4-lane video _ Night \\201603152002\\";
Ifstream InFile (FilePath);
if (!infile.is_open ())
{
cerr<< "Failed Open File" <<endl;
return-1;
}
Size sz;
Double scale = 0.25;
while (Getline (inFile, filename))//Read file names by row
{
cout<<dir<<endl;
cout<<filename<<endl;
String str = dir + fileName; Connection file path and file name;
cout<<str<<endl;
Srcimage = Imread (str,1); Read in image
if (!srcimage.data)
{
cout<< "Image is filed" <<endl;
return-1;
}
Sz.width = (int) (Srcimage.cols * 0.25);
Sz.height = (int) (srcimage.rows * 0.25);
Dstimage.create (SZ, Srcimage.type ());
Resize (srcimage, dstimage, SZ);
Namedwindow (filename,1);
Imshow (Filename,dstimage);
MoveWindow (FileName, srcimage.cols, 0);
Hsvimage.create (Sz,dstimage.type ());
Cvtcolor (Dstimage,hsvimage,cv_bgr2lab);//rgb Convert to Lab color space
Imshow ("HSV", hsvimage);
Waitkey (0);
DestroyWindow (FileName);
}
Infile.close ();
return 0;
}
OPENCV batch processing of images