這是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;}
添加回答
舉報
0/150
提交
取消