cameraProviderFuture = ProcessCameraProvider.getInstance(this);
104 |
105 | cameraProviderFuture.addListener(() -> {
106 | try {
107 | // 将你的相机和当前生命周期的所有者绑定所需的对象
108 | ProcessCameraProvider processCameraProvider = cameraProviderFuture.get();
109 |
110 | // 创建一个Preview 实例,并设置该实例的 surface 提供者(provider)。
111 | Preview preview = new Preview.Builder()
112 | .setTargetRotation(Surface.ROTATION_90)
113 | .setTargetAspectRatio(AspectRatio.RATIO_16_9)
114 | .build();
115 | preview.setSurfaceProvider(mBinding.preview.getSurfaceProvider());
116 |
117 | // 选择后置摄像头作为默认摄像头
118 | CameraSelector cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA;
119 |
120 | // 创建拍照所需的实例
121 | imageCapture = new ImageCapture.Builder()
122 | .setTargetRotation(Surface.ROTATION_90)
123 | .setTargetAspectRatio(AspectRatio.RATIO_16_9)
124 | .build();
125 |
126 | // 重新绑定用例前先解绑
127 | processCameraProvider.unbindAll();
128 |
129 | // 绑定用例至相机
130 | processCameraProvider.bindToLifecycle(this, cameraSelector,
131 | preview,
132 | imageCapture);
133 |
134 | } catch (Exception e) {
135 | }
136 | }, ContextCompat.getMainExecutor(this));
137 | }
138 |
139 | private void takePhoto() {
140 | if (imageCapture != null) {
141 | // 创建带时间戳的输出文件以保存图片,带时间戳是为了保证文件名唯一
142 | File photoFile = new File(getCacheDir(), "/" + System.currentTimeMillis() + ".jpg");
143 |
144 | // 创建 output option 对象,用以指定照片的输出方式
145 | ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions
146 | .Builder(photoFile)
147 | .build();
148 |
149 | // 执行takePicture(拍照)方法
150 | imageCapture.takePicture(outputFileOptions,
151 | ContextCompat.getMainExecutor(this),
152 | new ImageCapture.OnImageSavedCallback() {// 保存照片时的回调
153 | @Override
154 | public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
155 | Uri savedUri = Uri.fromFile(photoFile);
156 | launchActivity(savedUri);
157 | }
158 |
159 | @Override
160 | public void onError(@NonNull ImageCaptureException exception) {
161 | }
162 | });
163 | }
164 | }
165 |
166 | /**
167 | * 拍照界面
168 | */
169 | private View.OnClickListener onClickListener = new View.OnClickListener() {
170 | @Override
171 | public void onClick(View view) {
172 | switch (view.getId()) {
173 | case R.id.btn_close: //关闭相机
174 | finish();
175 | break;
176 | case R.id.btn_shutter: //拍照
177 | takePhoto();
178 | break;
179 | case R.id.btn_album: //相册
180 | Intent intent = new Intent();
181 | intent.setType("image/*");
182 | intent.setAction(Intent.ACTION_GET_CONTENT);
183 | startActivityForResult(intent, 1);
184 | break;
185 | }
186 | }
187 | };
188 |
189 | /**
190 | * 获取图片回调
191 | */
192 | @Override
193 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
194 | if (resultCode == RESULT_OK) {
195 | Uri uri = data.getData();
196 | Log.e("uri", uri.toString());
197 | launchActivity(uri);
198 | }
199 | super.onActivityResult(requestCode, resultCode, data);
200 | }
201 |
202 | private void launchActivity(Uri uri) {
203 | String path = UriUtils.getFileFromUri(this, uri);
204 | if (path == null) {
205 | Toast.makeText(this, "文件已损坏", Toast.LENGTH_SHORT).show();
206 | return;
207 | }
208 | Intent intent = new Intent(this, CutOutPhotoActivity.class);
209 | intent.putExtra("path", path);
210 | startActivity(intent);
211 | }
212 |
213 | }
214 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wt/ocr/camear/ReferenceLine.java:
--------------------------------------------------------------------------------
1 | package com.wt.ocr.camear;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | import com.wt.ocr.utils.Utils;
11 |
12 | /**
13 | * 网格参考线
14 | * Created by Administrator on 2016/12/8.
15 | */
16 |
17 | public class ReferenceLine extends View {
18 | private Paint mLinePaint;
19 |
20 | public ReferenceLine(Context context) {
21 | super(context);
22 | init();
23 | }
24 |
25 | public ReferenceLine(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | init();
28 | }
29 |
30 | public ReferenceLine(Context context, AttributeSet attrs, int defStyleAttr) {
31 | super(context, attrs, defStyleAttr);
32 | init();
33 | }
34 |
35 | private void init() {
36 | mLinePaint = new Paint();
37 | mLinePaint.setAntiAlias(true);
38 | mLinePaint.setColor(Color.parseColor("#ffffffff"));
39 | mLinePaint.setStrokeWidth(1);
40 | }
41 |
42 |
43 | @Override
44 | protected void onDraw(Canvas canvas) {
45 | int screenWidth = Utils.getScreenWH(getContext()).widthPixels;
46 | int screenHeight = Utils.getScreenWH(getContext()).heightPixels;
47 |
48 | int width = screenWidth / 3;
49 | int height = screenHeight / 3;
50 |
51 | for (int i = width, j = 0; i < screenWidth && j < 2; i += width, j++) {
52 | canvas.drawLine(i, 0, i, screenHeight, mLinePaint);
53 | }
54 | for (int j = height, i = 0; j < screenHeight && i < 2; j += height, i++) {
55 | canvas.drawLine(0, j, screenWidth, j, mLinePaint);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wt/ocr/utils/UriUtils.java:
--------------------------------------------------------------------------------
1 | package com.wt.ocr.utils;
2 |
3 | import android.content.ContentResolver;
4 | import android.content.ContentUris;
5 | import android.content.Context;
6 | import android.database.Cursor;
7 | import android.net.Uri;
8 | import android.provider.DocumentsContract;
9 | import android.provider.MediaStore;
10 |
11 | import java.io.File;
12 | import java.io.FileOutputStream;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.OutputStream;
16 |
17 | public class UriUtils {
18 | /**
19 | * 获取真实路径
20 | *
21 | * 支持以下
22 | *
23 | * file://
24 | * content://media/external/file/109009
25 | * FileProvider适配
26 | * content://com.tencent.mobileqq.fileprovider/external_files/storage/emulated/0/Tencent/QQfile_recv/
27 | * content://com.tencent.mm.external.fileprovider/external/tencent/MicroMsg/Download/
28 | * content://com.android.providers.downloads.documents"
29 | * content://com.android.externalstorage.documents
30 | * content://com.android.providers.media.documents
31 | * content://com.google.android.apps.photos.content
32 | */
33 | public static String getFileFromUri(Context context, Uri uri) {
34 | if (uri == null) {
35 | return null;
36 | }
37 | switch (uri.getScheme()) {
38 | case ContentResolver.SCHEME_CONTENT:
39 | if (isGooglePhotosUri(uri)) {
40 | return uri.getLastPathSegment();
41 | } else if (isMediaDocument(uri)) {
42 | // MediaProvider
43 | final String docId = DocumentsContract.getDocumentId(uri);
44 | final String[] split = docId.split(":");
45 | final String type = split[0];
46 | Uri contentUri = null;
47 | if ("image".equals(type)) {
48 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
49 | } else if ("video".equals(type)) {
50 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
51 | } else if ("audio".equals(type)) {
52 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
53 | }
54 | final String selection = "_id=?";
55 | final String[] selectionArgs = new String[]{split[1]};
56 |
57 | return getFilePathFromContentUri(context, contentUri, selection, selectionArgs);
58 | } else if (isDownloadsDocument(uri)) {
59 | // DownloadsProvider
60 | final String id = DocumentsContract.getDocumentId(uri);
61 | final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
62 | return getFilePathFromContentUri(context, contentUri, null, null);
63 | }
64 |
65 | return getFilePathFromContentUri(context, uri, null, null);
66 | case ContentResolver.SCHEME_FILE:
67 | default:
68 | //file://
69 | return new File(uri.getPath()).getAbsolutePath();
70 | }
71 | }
72 |
73 | /**
74 | * 从uri获取path 或 拷贝
75 | */
76 | private static String getFilePathFromContentUri(Context context, Uri uri, String selection, String[] selectionArgs) {
77 | if (null == uri) return null;
78 | String data = null;
79 |
80 | String[] filePathColumn = {MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DISPLAY_NAME};
81 | Cursor cursor = context.getContentResolver().query(uri, filePathColumn, selection, selectionArgs, null);
82 | if (null != cursor) {
83 | if (cursor.moveToFirst()) {
84 | int index = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
85 | if (index > -1) {
86 | data = cursor.getString(index);
87 | if (data == null || !fileIsExists(data)) {
88 | //可能拿不到真实路径 或 文件不存在 走拷贝流程
89 | int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
90 | String fileName = cursor.getString(nameIndex);
91 | data = getPathFromInputStreamUri(context, uri, fileName);
92 | }
93 | } else {
94 | //拷贝一份
95 | int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
96 | String fileName = cursor.getString(nameIndex);
97 | data = getPathFromInputStreamUri(context, uri, fileName);
98 | }
99 | }
100 | cursor.close();
101 | }
102 | return data;
103 | }
104 |
105 | /**
106 | * 用流拷贝文件一份到自己APP私有目录下
107 | *
108 | * @param context
109 | * @param uri
110 | * @param fileName
111 | */
112 | private static String getPathFromInputStreamUri(Context context, Uri uri, String fileName) {
113 | InputStream inputStream = null;
114 | String filePath = null;
115 |
116 | if (uri.getAuthority() != null) {
117 | try {
118 | inputStream = context.getContentResolver().openInputStream(uri);
119 | File file = createTemporalFileFrom(context, inputStream, fileName);
120 | filePath = file.getPath();
121 |
122 | } catch (Exception e) {
123 | } finally {
124 | try {
125 | if (inputStream != null) {
126 | inputStream.close();
127 | }
128 | } catch (Exception e) {
129 | }
130 | }
131 | }
132 |
133 | return filePath;
134 | }
135 |
136 | private static File createTemporalFileFrom(Context context, InputStream inputStream, String fileName)
137 | throws IOException {
138 | File targetFile = null;
139 |
140 | if (inputStream != null) {
141 | int read;
142 | byte[] buffer = new byte[8 * 1024];
143 | //自己定义拷贝文件路径
144 | targetFile = new File(context.getExternalCacheDir(), fileName);
145 | if (targetFile.exists()) {
146 | targetFile.delete();
147 | }
148 | OutputStream outputStream = new FileOutputStream(targetFile);
149 |
150 | while ((read = inputStream.read(buffer)) != -1) {
151 | outputStream.write(buffer, 0, read);
152 | }
153 | outputStream.flush();
154 |
155 | try {
156 | outputStream.close();
157 | } catch (IOException e) {
158 | e.printStackTrace();
159 | }
160 | }
161 |
162 | return targetFile;
163 | }
164 |
165 | private static boolean isDownloadsDocument(Uri uri) {
166 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
167 | }
168 |
169 | private static boolean isMediaDocument(Uri uri) {
170 | return "com.android.providers.media.documents".equals(uri.getAuthority());
171 | }
172 |
173 | public static boolean isGooglePhotosUri(Uri uri) {
174 | return "com.google.android.apps.photos.content".equals(uri.getAuthority());
175 | }
176 |
177 | //判断文件是否存在
178 | private static boolean fileIsExists(String filePath) {
179 | try {
180 | File f = new File(filePath);
181 | if (!f.exists()) {
182 | return false;
183 | }
184 | } catch (Exception e) {
185 | return false;
186 | }
187 | return true;
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wt/ocr/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.wt.ocr.utils;
2 |
3 | import android.content.ContentResolver;
4 | import android.content.ContentUris;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.database.Cursor;
8 | import android.graphics.Bitmap;
9 | import android.graphics.Matrix;
10 | import android.graphics.Rect;
11 | import android.net.Uri;
12 | import android.os.Build;
13 | import android.os.Environment;
14 | import android.provider.DocumentsContract;
15 | import android.provider.MediaStore;
16 | import android.util.DisplayMetrics;
17 |
18 | import java.io.File;
19 |
20 | /**
21 | * Created by Administrator on 2016/12/8.
22 | */
23 |
24 | public class Utils {
25 | public static DisplayMetrics getScreenWH(Context context) {
26 | DisplayMetrics dMetrics = new DisplayMetrics();
27 | dMetrics = context.getResources().getDisplayMetrics();
28 | return dMetrics;
29 | }
30 |
31 | public static final int getWidthInPx(Context context) {
32 | final int width = context.getResources().getDisplayMetrics().widthPixels;
33 | return width;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/answer_btn_answered.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/answer_btn_answered.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_close_click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_close_click.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_close_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_close_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_ok_click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_ok_click.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_ok_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_ok_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_takephoto_click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_takephoto_click.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_takephoto_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/ic_takephoto_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icon_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-hdpi/icon_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/to_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-xhdpi/to_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/to_camera_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/drawable-xhdpi/to_camera_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_press.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
6 |
7 | -
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_ok_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
6 |
7 | -
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_takephoto_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
6 |
7 | -
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_cutout_phote.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
15 |
16 |
20 |
21 |
26 |
27 |
36 |
37 |
38 |
42 |
43 |
49 |
50 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_show_croppered.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
14 |
15 |
20 |
21 |
28 |
29 |
34 |
35 |
42 |
43 |
49 |
50 |
58 |
59 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_take_phote.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
14 |
15 |
20 |
21 |
22 |
26 |
27 |
36 |
37 |
42 |
43 |
51 |
52 |
60 |
61 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 文字识别
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | maven { url "https://maven.google.com" }
6 | google()
7 | mavenCentral()
8 | maven { url 'https://jitpack.io' }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:7.1.1'
12 | classpath 'com.google.gms:google-services:4.3.2'
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | maven { url "https://maven.google.com" }
19 | google()
20 | mavenCentral()
21 | maven { url 'https://jitpack.io' }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshot (1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/screenshot (1).jpg
--------------------------------------------------------------------------------
/screenshot (2).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/screenshot (2).jpg
--------------------------------------------------------------------------------
/screenshot (3).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/screenshot (3).jpg
--------------------------------------------------------------------------------
/screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangtaoT/AndroidOCR/a3290b0d487287b11306580c2ce5c126e5f76070/screenshot.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------