So I make a bitmap from a blob with the next code:
byte[] blob = contact.getMP();
ByteArrayInputStream inputStream = new ByteArrayInputStream(blob);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
Bitmap scalen = Bitmap.createScaledBitmap(bitmap, 320, 240, false);
and it gives back the next output, which is good
Then I do the following to make the bitmap into a Mat, but then my colors just change...
//Mat ImageMat = new Mat();
Mat ImageMat = new Mat(320, 240, CvType.CV_32F);
Utils.bitmapToMat(scalen, ImageMat);
I have no idea why, nor another way to make the bitmap into a Mat. What is wrong?
Mat ImageMat = new Mat(320, 240, CvType.CV_32F);
will allocate a matrix which is not suitable to receive the output ofbitmapToMat
, the type should beCV_8UC4
. Coincidentally the same number of bytes :) See doc iopencv.com/docs/java/2.4.9/org/opencv/android/Utils.html – Scandal