Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can refer to OpenCV samples. Many samples use this such concept. Here is one from \opencv\sources\samples\cpp\stereo_calib.cpp.

  1. Create a text file with list of image names along with path to be processed.
  2. Following code opens the text file and prepares the list of file names.

    FILE* f = fopen("ImageList.txt", "r");
    vector<string> imagelist;
    for(int i = 0; ; i++)
    {
    if(!fgets(buf, sizeof(buf)-3, f))
        break;
    size_t len = strlen(buf);
    
    while(len > 0 && isspace(buf[len-1]))
        buf[--len] = '\0';
    
    if(buf[0] == '#')
        continue;
    
    imagelist.push_back(buf);
    }
    fclose(f);
    
  3. Start accessing images by imread(imagelist[i])