1 | initial version |
ok, you can use Mat.get() to copy all of the pixels into a buffer:
//but first : check !
if (mat.depth() == CvType.CV_8U) { //bytes !
byte[] buffer = new byte[mat.total() * mat.channels()];
mat.get(0,0,buffer);
} else
if (mat.depth() == CvType.CV_32) { //float !
float[] buffer = new float[mat.total() * mat.channels()];
... etc
2 | No.2 Revision |
ok, you can use Mat.get() to copy all of the pixels into a buffer:
//but first : check !
if (mat.depth() == CvType.CV_8U) { //bytes !
byte[] buffer = new byte[mat.total() * mat.channels()];
mat.get(0,0,buffer);
} else
if (mat.depth() == CvType.CV_32) { //float !
float[] buffer = new float[mat.total() * mat.channels()];
... etc
the reverse is simply:
Mat m(height, width, type);
m.put(0,0,buffer);
3 | No.3 Revision |
ok, you can use Mat.get() to copy all of the pixels into a buffer:
//but first : check !
if (mat.depth() == CvType.CV_8U) { //bytes !
byte[] buffer = new byte[mat.total() * mat.channels()];
mat.get(0,0,buffer);
} else
if (mat.depth() == CvType.CV_32) CvType.CV_32F) { //float !
float[] buffer = new float[mat.total() * mat.channels()];
... etc
the reverse is simply:
Mat m(height, width, type);
m.put(0,0,buffer);