为了账号安全,请及时绑定邮箱和手机立即绑定

能帮我看看这个空指针异常是怎么回事?求大神指点

能帮我看看这个空指针异常是怎么回事?求大神指点

慕沐林林 2023-04-24 22:18:35
这是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;}
查看完整描述

1 回答

?
HUH函数

TA贡献1836条经验 获得超4个赞

你153行有个对象是null的。

查看完整回答
反对 回复 2023-04-27
  • 1 回答
  • 0 关注
  • 153 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信