这是logcat报错信息
这是报错函数的代码(识别图片中字符的函数)
public String decodeBitmapValue(String path) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeFile(IMAGE_PATH, options);
Log.i(TAG, "---in ocr() before try--");
try {
Log.v(TAG, "not in the exception");
ExifInterface exif = new ExifInterface(IMAGE_PATH);
int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
Log.v(TAG, "Orient: " + exifOrientation);
int rotate = 0;
switch (exifOrientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
}
Log.i(TAG, "Rotation: " + rotate);
} catch (IOException e) {
Log.e(TAG, "Rotate or coversion failed: " + e.toString());
Log.v(TAG, "in the exception");
}
Log.i(TAG, "Bitmap创建成功");
if (bitmap == null) {
return null;
}
baseApi.init(TESSBASE_PATH, DEFAULT_LANGUAGE);
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false);
baseApi.setImage(bitmap);
Log.i(TAG, "Bitmap加载成功");
String value = baseApi.getUTF8Text();
Log.i("TAG", " the value is ===> " + value);
baseApi.clear();
baseApi.end();
return value;
}
HUH函数
相关分类