Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

converting from pixel array (rgba) to Mat - (java API)

Hi all,

I am struggling on how to convert the pixel array of an image

int [] pixels = new int[myheight * mywidth];

to a Mat so that I can apply various transformations. I have tried the following (and more):

decodeYUV420SP(pixels, data, mywidth, myheight);
Mat mRgbaRaw = new Mat(myheight, mywidth, CvType.CV_8UC4);
mRgbaRaw.put(0, 0, pixels);

but it gives me the error:

Exception in thread "main" java.lang.UnsupportedOperationException: Mat data type is not compatible: 24
    at org.opencv.core.Mat.put(Mat.java:2511)

Anyone knows how to do this?

Thanks a lot!

converting from pixel array (rgba) to Mat - (java API)

Hi all,

I am struggling on how to convert the pixel array of an image

int [] pixels = new int[myheight * mywidth];

to a Mat so that I can apply various transformations. I have tried the following (and more):

decodeYUV420SP(pixels, data, mywidth, myheight);
Mat mRgbaRaw = new Mat(myheight, mywidth, CvType.CV_8UC4);
mRgbaRaw.put(0, 0, pixels);

but it gives me the error:

Exception in thread "main" java.lang.UnsupportedOperationException: Mat data type is not compatible: 24
    at org.opencv.core.Mat.put(Mat.java:2511)

Anyone knows how to do this?

Thanks a lot!