Ask Your Question

Revision history [back]

If you have not very large DB of pics (10-15 pics), the most easiest way to do it, is with bat file, that call your program and parse the input parameters (argc and **argv).

The other way is to use dirrent.h That is small example, that will do the job ;)

int check_ext(string path)   //only images
{
    string ext[]={"BMP","DIB","JPEG","JPG","JPE","PNG","PBM","PGM","PPM","SR","RAS","TIFF","TIF"
            ,"bmp","dib","jpeg","jpg","jpe","png","pbm","pgm","ppm","sr","ras","tiff","tif"};
    for(unsigned int i=0;i<(sizeof(ext)/sizeof(ext[0]));i++)
    {
        if(path.substr(path.find_last_of(".") + 1) == ext[i])return 1;
    }
    return 0;
}

//someware open files
if ((dir = opendir ((path).c_str())) != NULL)
{
    while ((ent = readdir (dir)) != NULL)
    {
        if(check_ext(ent->d_name))Mat img = imread(path+"\\"+ent->d_name);
    }
}

If you have not very large DB of pics (10-15 pics), the most easiest way to do it, is with bat file, that call your program and parse the input parameters (argc and **argv).

The other way is to use dirrent.h That is small example, that will do the job ;)

int check_ext(string path)   //only images
{
    string ext[]={"BMP","DIB","JPEG","JPG","JPE","PNG","PBM","PGM","PPM","SR","RAS","TIFF","TIF"
            ,"bmp","dib","jpeg","jpg","jpe","png","pbm","pgm","ppm","sr","ras","tiff","tif"};
    for(unsigned int i=0;i<(sizeof(ext)/sizeof(ext[0]));i++)
    {
        if(path.substr(path.find_last_of(".") + 1) == ext[i])return 1;
    }
    return 0;
}

//someware open files
if ((dir = opendir ((path).c_str())) != NULL)
{
    while ((ent = readdir (dir)) != NULL)
    {
        if(check_ext(ent->d_name))Mat img = imread(path+"\\"+ent->d_name);
        //processing               
        imwrite(outputdir+"\\"+ent->d_name,img);
    }
}