Address: Mosquito 132 today to introduce the simplest CFileFind program implementation
File lookup in the program is more commonly used,Mosquito 132Today to introduce the simplest CFileFind program implementation
Function: Find the. jpg in the folder, write the video
#include "direct.h"//Specify Path
#include "cv.h"//looking for an image
#include "cvaux.h"
#include "highgui.h"
void Cshowtestdlg::writeavi ()
{
cvvideowriter* wrt = 0; Write video
CFileFind Filefinder;
CString filename; Extract filename
CString Avipath;
Filename= "d:\\";
filename+= "1\\20110510101605";
Avipath=filename+ ". avi"; Name avi
_chdir (filename); Go to the specified path
filename+= "\\*.jpg"; Files in. jpg format
int i=0;
BOOL bfind =filefinder. FindFile (filename);
while (bfind)
{
bfind = Filefinder. FindNextFile ()//Do not know why the first search will have this sentence
CString Imagename=filefinder. GetFileName ()//Gets the name of the file found, not the absolute path.
Iplimage* Frame=null;
Frame=cvloadimage (imagename,1);
if (i==0)
{
WRT = Cvcreatevideowriter (Avipath, CV_FOURCC (' D ', ' I ', ' V ', ' X '), 10,cvsize (Frame->width, Frame->height), 1); 10f/s
i++;
}
Cvwriteframe (wrt, frame); Write to the video recorder
Cvreleaseimage (&frame);
}
Cvreleasevideowriter (&WRT);
}
The problem is, when the folder has 1.jpg, 2.jpg, until 251.jpg files, the order of the find file is chaotic, the file found in turn is 1.jpg,10.jpg,100.jpg, so the file name is changed to 3 digits, If 001.jpg,002.jpg, there would be no mistake. The normal lookup order is by the time the file is saved.