Load images into a vector of vector of Mat - vector<vector<Mat>>
<p>I am working on an image processing project using opencv C++ library. I have been able to read image names and load images from a folder into my code using <code>glob()</code> function. The problem I have is how to organize the images in a two-dimensional array fashion (row-column fashion). <strong><em>I want to load 10 images per individual for 100 individual and store them in a <code>MAT</code> array/vector</em></strong> such that my subjects are represented by rows and images for each subject are the columns.</p>

<p>This code is throwing unhandled exception error.</p>

<pre><code>#include &lt;opencv2/opencv.hpp&gt;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;

using namespace std;
using namespace cv;

int main()
{
String folder = "E:\\Face Databases\\FG-NET DATASET\\images\\*.JPG";
vector&lt;String&gt; filenames;
int start = folder.find("*");//get the start of the real image label
//cout &lt;&lt; "Position = " &lt;&lt; start &lt;&lt; endl;
glob(folder, filenames, false);
String label[1001];
ofstream labels;
labels.open("labels.csv");

vector&lt;vector&lt;Mat&gt;&gt; myImage;

for (size_t i = 0; i &lt; filenames.size(); ++i)
{
    vector&lt;Mat&gt; myImage = imread(filenames[i]);
    label[i] = filenames[i].substr(start, 6);
    labels &lt;&lt; label[i] &lt;&lt; "\n";//write labels to a csv file
}
waitKey(0);

return 0;
}
</code></pre>