By GP089
on Wed, 11/11/2015 - 07:24
Hi, I want to transform camera image to android.graphics.Bitmap. The following is my source code, but the imageview object named m_ivCamera can not show the bitmap correctly. Thank you very much. @Override public void onQCARUpdate(State state) { Image imageRGB565 = null; Frame frame = state.getFrame(); for (int i = 0; i < frame.getNumImages(); ++i) { Image image = frame.getImage(i); if (image.getFormat() == PIXEL_FORMAT.RGB565) { imageRGB565 = image; break; } } if (imageRGB565 != null) { ByteBuffer pixels = imageRGB565.getPixels(); byte[] pixelArray = new byte[pixels.remaining()]; pixels.get(pixelArray, 0, pixelArray.length()); int imageWidth = imageRGB565.getWidth(); int imageHeight = imageRGB565.getHeight(); int stride = imageRGB565.getStride(); Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Bitmap.Config.RGB_656; Bitmap bm = BitmapFactory.decodeByByteArray(pixelArray, 0, pixelArray.length, opts); // m_ivCamera is a android.widget.ImageView object. m_ivCamera.setImageBitmap(bm); }
I tried this solution but i
I tried this solution but i getting PIXEL_FORMAT.GRAYSCALE not PIXEL_FORMAT.RGB565. If I initialize imageRGB565 for GRAYSCALE than BitmapFactory.decodeByByteArray(pixelArray, 0, pixelArray.length, opts); return null.
I'm having same problem as
I'm having same problem as you @sanjaytestid.
I added Vuforia.setFrameFormat(PIXEL_FORMAT.RGB565, true); in startAR() as mentioned in the documentation but I'm still getting GRAYSCALE image from frames.