Bytes Per Pixel value for byte representation of image in Android

可紊 提交于 2019-12-06 12:25:30

I actually did the same and got it working. I guess you'll use somehow the camera and the camera preview to capture the screen for the OCR recognition. Therefore you can get the camera preview format, which allows you through the PixelFormat to retrieve the BytesPerPixel.

I'll give you a short example:

Camera.Parameters cameraParameters = camera.getParameters(); // retrieve the camera parameters
previewFormat = cameraParameters.getPreviewFormat(); // retrieve the Previewformat according to your camera

PixelFormat pf = new PixelFormat(); // create a PixelFormat object
PixelFormat.getPixelFormatInfo(previewFormat, pf); // get through the previewFormat-int the PixelFormat

int bpp = pf.bytesPerPixel; // save the BytesPerPixel for this Pixelformat
int bpl = bpp*width; // BytesPerLines is just the "BPP * width" of your PreviewFormat/Picture

tess.setImage(imagedata, width, height, bpp, bpl); // setImage with imagedata[], width and height of the previewFormat, etc.

I hope it helps. If you'll have further questions let me now.

Best wishes and good luck, Volker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!