Ask Your Question
1

vector of vectors

asked 2014-03-31 05:11:07 -0600

yamanneameh gravatar image

updated 2016-01-10 15:54:56 -0600

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;
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-03-31 06:14:40 -0600

For the first loop, it should be:

vector <Mat> Images;

For the second loop, it shoud be:

vector<vector<Mat>> FilesVector;
FilesVector.push_back(Images);
edit flag offensive delete link more

Comments

This not work because if you have in first file 20 images and in the second 10 images at the end you will get FilesVector[30] (with 30 images) but what I need is FilesVector[ vict(20) , vict(10)] so finally when I call FilesVector[0] this mean that I call the images in the first file

yamanneameh gravatar imageyamanneameh ( 2014-03-31 06:26:55 -0600 )edit

For the second loop, you will have FilesVector[0] (a vector of Mats) containing images from 1st file, FilesVector[1] (another vector of Mats) containing images from 2nd files. Did you test that for sure?

tuannhtn gravatar imagetuannhtn ( 2014-03-31 06:42:09 -0600 )edit

Question Tools

Stats

Asked: 2014-03-31 05:11:07 -0600

Seen: 2,086 times

Last updated: Mar 31 '14