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!
CvType.CV_8UC4 != int !
it means, that you probably need to supply a byte[4] per pixel in
mRgbaRaw.put(i,j, pixel); // *1* pixel at a time, too