Ask Your Question

Revision history [back]

vector of vectors

Hello,

I am looping through multiple files to read images inside each one, I got the files paths and number of images in each file:

//here is part of the code:

vector <Mat>& Images;

for( size_t i = 0; i < ImagesCounts.size(); i++ )
    {
       Mat img = imread( filename, 1 ); //
       Images.push_back( img );
}

I read by this code the images of the first file so: Images[0]= img1 , Images[1]=img2 .....

I am now in the second loop (which has different filename and ImageCounts)

and I need to save first vector of Images in a global vector.. this mean:

FilesVector(vect[1],vect[2]......vect[N]); N is number of files

where: vect[1] should include the images of the first file vect[2] should include the images of the second file

So how I can define the global vector and push the images I have in the first loop to vect[1].. ?

I tried this code before going to the second loop but didn't work!

vector<vector<Mat>> FilesVector;
FilesVector[0]=Images;

vector of vectors

Hello,

I am looping through multiple files to read images inside each one, I got the files paths and number of images in each file:

//here is part of the code:

vector <Mat>& Images;

for( size_t i = 0; i < ImagesCounts.size(); i++ )
    {
       Mat img = imread( filename, 1 ); //
       Images.push_back( img );
}

I read by this code the images of the first file so: Images[0]= img1 , Images[1]=img2 .....

I am now in the second loop (which has different filename and ImageCounts)

and I need to save first vector of Images in a global vector.. this mean:

FilesVector(vect[1],vect[2]......vect[N]); N is number of files

where: vect[1] should include the images of the first file vect[2] should include the images of the second file

So how I can define the global vector and push the images I have in the first loop to vect[1].. ?

I tried this code before going to the second loop but didn't work!

vector<vector<Mat>> FilesVector;
FilesVector[0]=Images;