title: How to load multiple images for processing with opencv?
body: <p>I have a code in OpenCV C++ and I have to apply to twenty or more images. Now I'm debbuging one by one, changing the name of the image every time. Is there a way that I can, like, call all the images and submit them to that process and save all of them?</p>
  
  <p>I'm using this:</p>
  
  <pre><code>Mat input_image = imread("img1.jpg");
  </code></pre>
  
  <p>for load a image. And this:</p>
  
  <pre><code>imwrite("output_image.jpg", output_image);
  </code></pre>
  
  <p>for save the image in my project folder.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I did this but it didn't work:</p>
  
  <pre><code>int main(int argc, char **argv){
  
      char name[50];
      int i=0;
      Mat output_image;
  
      while(1){
  
          sprintf(name, "cam%d.jpg", i);
  
          //Load the image
          Mat input_image = imread(name, 1);
          if(!input_image.data) break;
  
          //Image RGB to Grayscale
          cvtColor(input_image, output_image, CV_RGB2GRAY);
  
          //Applying Gaussian
          GaussianBlur(output_image, output_image, Size(21.0, 21.0), 50.0);
  
          //applying adaptive threshold
          adaptiveThreshold(output_image, output_image, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 111, -20);
  
          sprintf(name,"cam%d-bin.jpg",i);
  
          //save the image
          imwrite(name, output_image);
  
          i++;
  
  
      }
  
  }
  </code></pre>