字节每像素值,在Android的形象重新字节presentation [英] Bytes Per Pixel value for byte representation of image in Android

查看:203
本文介绍了字节每像素值,在Android的形象重新字节presentation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写一个Android应用程序这需要在其中使用OCR。

I'm currently writing an Android application which needs to use OCR within it.

要与的tesseract-机器人一起实现这个我使用的tesseract -tools项目

我已设法得到的tesseract API来初始化,需要使用下列setImage功能:

I have managed to get the Tesseract API to initialize and need to use the following setImage function:

void com.googlecode.tesseract.android.TessBaseAPI.setImage(byte[] imagedata, int width, int height, int bpp, int bpl)

我所挣扎的是如何得到正确的值BPP(字节每像素)和BPL(每行字节)。 有谁知道我如何能得到这些值吗我已经把相当随机值在那里的那一刻,并认为它是造成后来的错误。

What I am struggling with is how to get the correct values for bpp (bytes per pixel) and bpl (bytes per line). Does anyone know how I can get these values? I have put fairly random values in there at the moment and believe it is causing errors later on.

我要指出,该应用程序也使用JavaCV为其识别出细腻的图像图像识别和我使用的图像数据,此调用的tesseract同一来源。

I should note that the application is also using JavaCV for image recognition which is recognising images fine and I'm using the same source of image data for this tesseract call.

感谢。

推荐答案

其实我也一样,得到了它的工作。我猜你会以某种方式使用相机和摄像机preVIEW来捕捉屏幕的OCR识别。
因此,您可以让相机preVIEW格式,它允许你通过的PixelFormat检索BytesPerPixel。

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

这篇关于字节每像素值,在Android的形象重新字节presentation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆