大佬教程收集整理的这篇文章主要介绍了android – 无法使用language = eng初始化Tesseract API,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>我已将文件“eng.Traineddata”复制到该位置.
>我使用的是Android studio 2.1.2(SDK 23)
>使用API 22 Android Lollipop 5.1.1在设备上进行测试(阅读Marshmallow上的权限问题)
这是我正在使用的代码:
public void reads(@R_673_3868@) { TextView textView = (TextView) findViewById(R.id.textView); int rotation = 0; try { ExifInterface exifInterface = new ExifInterface(mCurrentPhotoPath); int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.oRIENTATION_NORMAL); switch (orientation){ case ExifInterface.oRIENTATION_ROTATE_90: rotation = 90; break; case ExifInterface.oRIENTATION_ROTATE_180: rotation = 180; break; case ExifInterface.oRIENTATION_ROTATE_270: rotation = 270; break; } } catch(Exception E) { } int w = imageBitmap.getWidth(); int h = imageBitmap.getHeight(); if (rotation != 0) { Matrix matrix = new Matrix(); matrix.preRotate(rotation); imageBitmap = Bitmap.createBitmap(imageBitmap,w,h,matrix,falsE); } else { imageBitmap = Bitmap.createBitmap(imageBitmap,h); } imageBitmap = imageBitmap.copy(Bitmap.Config.ARGB_8888,truE); TessBaseAPI ReadIt = new TessBaseAPI(); ReadIt.init("/storage/emulated/0/","eng"); ReadIt.setImage(imageBitmap); String Text = ReadIt.getUTF8Text(); if (Text!=null) textView.setText(Text); }
我在build.gradle依赖项中使用了这一行:
TessBaseAPI ReadIt = new TessBaseAPI(); ReadIt.init("/storage/emulated/0/","eng");
“/ storage / emulated / 0 /”路径应该指向您的数据文件.您必须有一个子目录
名为“tessdata”.看到
https://github.com/rmtheis/tess-two/blob/d7a45fd2e08b7ec315cd1e29d1a7e0c72fb24a66/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java#L176
以上是大佬教程为你收集整理的android – 无法使用language = eng初始化Tesseract API全部内容,希望文章能够帮你解决android – 无法使用language = eng初始化Tesseract API所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。