Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to store stort[] array in Matrix object : OpenCV Java

Hi, I am trying to store a short[1280*1024] 1D array in Mat object and and trying to create an image out of it. Below is code:

Mat mat1=new Mat();
mat1.create(1280, 1024, CvType.CV_16UC1);
mat1.put(1280, 1024,pix);  //pix is short[1280*1024]
Imgcodecs.imwrite("/../pic.png", mat1);

The put() function is not able to store all the [1280*1024] elements in the cells of the matrix. Only around 1/4th of the data seems to be stored. The rest are all 0s. I would be grateful if anyone can throw some light on this and tell if this is the right way to store the array into Matrix object.