1

I am trying to process many picture's at a time and then make all to equal size

Mat pic = imread ("C:\\Pick");
for (int i=0;i<10;i++)
{
 imshow("mainwin" , pick);
 resize (pick,re_pic,size(150,100));
}

Pick is a folder which contain 10 different picture's

1 Answers1

2

You can get list of images in directory and then process them.

    #include <vector>
    #include <stdio.h>
    #include <windows.h>
    #include <iostream>
    #include <string>

        using namespace std;
        //----------------------------------------------------------------------
        // Get list of files 
        // Usage:
        //  string ImagesDir=tmp+"C:\\Images\\*.jpg";
        //  vector<string> files=listFilesInDirectory(ImagesDir); 
        //----------------------------------------------------------------------
        vector<string> listFilesInDirectory(string directoryName)
        {
            WIN32_FIND_DATA FindFileData;
            HANDLE hFind = FindFirstFile(directoryName.c_str(), &FindFileData);

            vector<string> listFileNames;
            listFileNames.push_back(FindFileData.cFileName);

            while (FindNextFile(hFind, &FindFileData))
                listFileNames.push_back(FindFileData.cFileName);

            return listFileNames;
        }
...
// somewhere in main
string YourImagesDirectory="C:\\Pick\\";
vector<string> files=listFilesInDirectory(YourImagesDirectory+"*.jpg"); 
for(int i=0;i<files.size();i++)
    {
         Mat img=imread(YourImagesDirectory+files[i]);
         imshow("mainwin" , img);
         ...
    }
...
Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • Yes,sorry, I missed a few lines. Now, I think, code must work. – Andrey Smorodov Aug 01 '13 at 16:47
  • why it give error when i replace `imshow("mainwin" , img);` with `cvShowImage("mainWin", img);` because it run but it didn't show the images –  Aug 01 '13 at 16:56
  • It's because cv::imshow get cv::Mat as parameter, but cvShowImage get IplImage* . They can be converted as described here: http://stackoverflow.com/questions/4664187/converting-cvmat-to-iplimage – Andrey Smorodov Aug 01 '13 at 16:58