Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

According to [OpenCV Java API Documentation](http://docs.opencv.org/java/2.4.2/org/opencv/core/Mat.html#Mat(org.opencv.core.Size,%20int) the constructor Mat(Size size, int type) creates Mat in cols X rows order.

Mat(Size(cols, rows), int type)

So your code should be changed to

Mat test = new Mat(new Size(10,100),5); //create mat with 10 column and 100 rows
Mat row = new Mat(new Size(10,1),5); // create mat with 10 column and 1 rows
test.push_back(row);

or

Mat test = new Mat(new Size(100,10),5); //create mat with 100 column and 10 rows
Mat row = new Mat(new Size(100,1),5); // create mat with 100 column and 1 rows
test.push_back(row);

According to [OpenCV OpenCV Java API Documentation](http://docs.opencv.org/java/2.4.2/org/opencv/core/Mat.html#Mat(org.opencv.core.Size,%20int) Documentation the constructor Mat(Size size, int type) creates Mat in cols X rows order.order like,

Mat(Size(cols, rows), int type)

So your code should be changed to

Mat test = new Mat(new Size(10,100),5); //create mat with 10 column and 100 rows
Mat row = new Mat(new Size(10,1),5); // create mat with 10 column and 1 rows
test.push_back(row);

or

Mat test = new Mat(new Size(100,10),5); //create mat with 100 column and 10 rows
Mat row = new Mat(new Size(100,1),5); // create mat with 100 column and 1 rows
test.push_back(row);