|
|
@@ -99,7 +99,7 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
* @param rawPhotoBytes 原图
|
|
|
* @param scene 识别场景类型
|
|
|
*/
|
|
|
- public void startOcrFromFile(Context context, byte[] rawPhotoBytes, int[] rectData, File file, String scene) {
|
|
|
+ public void startOcrFromFile(Context context, byte[] rawPhotoBytes, int[] rectData, File file, String scene, boolean isLandscape) {
|
|
|
getView().showLoading(context.getResources().getString(R.string.loading));
|
|
|
int mLeft = rectData[0];
|
|
|
int mTop = rectData[1];
|
|
|
@@ -116,7 +116,13 @@ public class OperationPresenter extends BasePresenter<IOperationView> {
|
|
|
int newHeight = (mRight-mLeft)*originalBmp.getHeight()/ SizeTool.SCREEN_WIDTH;
|
|
|
Bitmap croppedBmp = Bitmap.createBitmap(originalBmp, newLeft, newTop, newWidth, newHeight);
|
|
|
// 旋转90度,让OCR可以识别
|
|
|
- Bitmap rotatedBitmap = ImageUtil.rotateBitmap90(croppedBmp);
|
|
|
+ Bitmap rotatedBitmap;
|
|
|
+ if (isLandscape) {
|
|
|
+ rotatedBitmap = croppedBmp;
|
|
|
+ } else {
|
|
|
+ rotatedBitmap = ImageUtil.rotateBitmap90(croppedBmp);
|
|
|
+ }
|
|
|
+
|
|
|
if (!file.getParentFile().exists()) {
|
|
|
file.mkdirs();
|
|
|
}
|