title: Bad flag error in OpenCV after throwing an instance of 'cv::Exception' . Unsupported array type in cvGetMat
body: <p>I am new to OpenCV , and trying to read the sequence of images in a folder. My code is as follows :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;opencv2/opencv.hpp&gt;
  #include &lt;cv.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  
     void loadImage(Mat image,int number)
      {
        char filename[100];
         strcpy(filename, "/home/folder1/imagefolder/");
  
       char frameNo[10];
         sprintf(frameNo, "%08i", number); 
         strcat(filename, frameNo);
         strcat(filename, ".png");
         cout&lt;&lt; filename;
  
         image = imread(filename);
         if (image.empty()) //check whether the image is loaded or not
      {
      cout &lt;&lt; "Error : Image not loaded." &lt;&lt; endl;
          }
      }
  
      int main()
      {
       Mat image;
       int nImages=8;
       for (int i = 1; i &lt; nImages; i++)
      {
       loadImage(image,i);
       namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
       imshow( "Display Image", image );
       waitKey(100000);
       return 0;
  
      }
      }
  </code></pre>
  
  <p>It gets compiled, But on running the executable, it gives following error:</p>
  
  <p>OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /home/vuadmin/OpenCV-2.3.1/modules/core/src/array.cpp, line 2482
  terminate called after throwing an instance of 'cv::Exception'
    what():  /home/vuadmin/OpenCV-2.3.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat
  Aborted (core dumped)</p>
  
  <p>Please help me find out the error. </p>
  
  <p>I also tried out the other method as given in 
  <a href="https://stackoverflow.com/questions/16713258/opencv-reading-image-series-from-a-folder">OpenCV: Reading image series from a folder</a></p>
  
  <p>but in my case it shows only the first image .</p>