Adding matrix to a list of matrix, causes a size changing

Hi,

I would like to add a matrix to a list of matrix, but what I get is that the first matrix added well(1920x1080), but from the second matrix the size is changed to 1920x1080.

This is part of my code:

                List<Mat> M = new ArrayList<Mat>();
Mat mainMat = new Mat();
b = retriever.getFrameAtTime(((630 + i)/30)*1000000,MediaMetadataRetriever.OPTION_CLOSEST);
mainMat =  new Mat(new Size(b.getWidth(),b.getHeight()),CvType.CV_8U);
Utils.bitmapToMat(b, mainMat);
Imgproc.cvtColor(mainMat, mainMat, Imgproc.COLOR_RGB2GRAY);