Mosquito 132 today to introduce the simplest CFileFind program implementation

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.