Android 中图像字节表示的每像素字节数
我目前正在编写一个Android应用程序,需要在其中使用OCR。
为了实现这一目标,我将 Tesseract 与 tesseract-android-tools 项目。
我已经设法让 Tesseract API 进行初始化,并且需要使用以下 setImage 函数:
void com.googlecode.tesseract.android.TessBaseAPI.setImage(byte[] imagedata, int width, int height, int bpp, int bpl)
我正在努力解决的是如何获取 bpp(每像素字节数)和 bpl(每行字节数)的正确值。 有人知道我如何获得这些值吗?我目前已经在其中放置了相当随机的值,并相信它稍后会导致错误。
我应该注意到,该应用程序还使用 JavaCV 进行图像识别,它可以很好地识别图像,并且我在这个超立方体调用中使用相同的图像数据源。
谢谢。
I'm currently writing an Android application which needs to use OCR within it.
To achieve this I am using Tesseract in conjunction with the tesseract-android-tools project.
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)
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.
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.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我实际上也做了同样的事情并且成功了。我想您会以某种方式使用相机和相机预览来捕获屏幕以进行 OCR 识别。
因此,您可以获得相机预览格式,这允许您通过 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:
I hope it helps. If you'll have further questions let me now.
Best wishes and good luck,
Volker