├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── User.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── ltapps
│ │ └── textscanner
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── trainneddata
│ │ │ ├── eng.traineddata
│ │ │ └── spa.traineddata
│ ├── java
│ │ └── com
│ │ │ └── ltapps
│ │ │ └── textscanner
│ │ │ ├── Binarization.java
│ │ │ ├── CropAndRotate.java
│ │ │ ├── MainActivity.java
│ │ │ ├── OtsuThresholder.java
│ │ │ └── Recognizer.java
│ └── res
│ │ ├── drawable
│ │ └── camera.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── binarization.xml
│ │ ├── crop_and_rotate.xml
│ │ └── recognizer.xml
│ │ ├── menu
│ │ ├── menu_result.xml
│ │ └── menu_rotate.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_content_copy_white_24dp.png
│ │ ├── ic_done_white_24dp.png
│ │ ├── ic_launcher.png
│ │ ├── ic_open_in_new_white_24dp.png
│ │ ├── ic_rotate_left_white_24dp.png
│ │ └── ic_rotate_right_white_24dp.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_content_copy_white_24dp.png
│ │ ├── ic_done_white_24dp.png
│ │ ├── ic_launcher.png
│ │ ├── ic_open_in_new_white_24dp.png
│ │ ├── ic_rotate_left_white_24dp.png
│ │ └── ic_rotate_right_white_24dp.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_content_copy_white_24dp.png
│ │ ├── ic_done_white_24dp.png
│ │ ├── ic_launcher.png
│ │ ├── ic_open_in_new_white_24dp.png
│ │ ├── ic_rotate_left_white_24dp.png
│ │ └── ic_rotate_right_white_24dp.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_content_copy_white_24dp.png
│ │ ├── ic_done_white_24dp.png
│ │ ├── ic_launcher.png
│ │ ├── ic_open_in_new_white_24dp.png
│ │ ├── ic_rotate_left_white_24dp.png
│ │ └── ic_rotate_right_white_24dp.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_content_copy_white_24dp.png
│ │ ├── ic_done_white_24dp.png
│ │ ├── ic_launcher.png
│ │ ├── ic_open_in_new_white_24dp.png
│ │ ├── ic_rotate_left_white_24dp.png
│ │ └── ic_rotate_right_white_24dp.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── ltapps
│ └── textscanner
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Android ###
2 | # Built application files
3 | *.apk
4 | *.ap_
5 |
6 | # Files for the ART/Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 | out/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # Intellij
37 | *.iml
38 | .idea/workspace.xml
39 | .idea/libraries
40 |
41 | # Keystore files
42 | *.jks
43 |
44 | # External native build folder generated in Android Studio 2.2 and later
45 | .externalNativeBuild
46 |
47 | ### Android Patch ###
48 | gen-external-apklibs
49 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/User.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | umbralization
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Leonardo Testa
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Text Scanner (OCR) []()
2 | OCR Android App using tesseract
3 |
4 |
5 |
6 | ## Features
7 | - Crop
8 | - Rotate
9 | - Binarize
10 | - Recognize Text (English and spanish)
11 | - Search
12 | - Copy to clipboard
13 |
14 | ## Libraries
15 | - [android-image-cropper](https://github.com/ArthurHub/Android-Image-Cropper): for image cropping.
16 | - [tess-two](https://github.com/rmtheis/tess-two): to recognize text (tesseract) and binarize (leptonica).
17 | - [firebase](https://firebase.google.com/docs/android/setup): to report metrics (for development purpose, you can [remove firebase dependencies](https://github.com/testica/text-scanner/pull/5) or add your own google-services.json).
18 | - [admob](https://developers.google.com/admob/android/quick-start): to show google ads (to pay some bills). Check [PR #8](https://github.com/testica/text-scanner/pull/8) to know more about admob environment.
19 |
20 | ## Support
21 | - Android 4.0 +
22 |
23 | ## Planned Features
24 | On [Projects tab](https://github.com/testica/text-scanner/projects/1) you can trace the future possible features and its status.
25 |
26 | **Backlog** → a simple idea
27 |
28 | **Ready** → idea now is a possible feature waiting to be developed
29 |
30 | **In progress** → feature being developed
31 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'io.fabric'
3 |
4 | android {
5 | compileSdkVersion 26
6 | buildToolsVersion '27.0.3'
7 |
8 | defaultConfig {
9 | applicationId "com.ltapps.textscanner"
10 | minSdkVersion 14
11 | targetSdkVersion 26
12 | versionCode 4
13 | versionName "1.3"
14 |
15 | buildConfigField 'String', 'AdMobAppId', '"ca-app-pub-3940256099942544~3347511713"'
16 | resValue 'string', 'admob_app_id', '"ca-app-pub-3940256099942544~3347511713"'
17 | resValue 'string', 'admob_unit_id', '"ca-app-pub-3940256099942544/6300978111"'
18 | }
19 | buildTypes {
20 | release {
21 | minifyEnabled true
22 | shrinkResources true
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | buildConfigField 'String', 'AdMobAppId', TextScanner_AdMobAppId
25 | resValue 'string', 'admob_app_id', TextScanner_AdMobAppId
26 | resValue 'string', 'admob_unit_id', TextScanner_AdMobUnitId
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation 'junit:junit:4.12'
34 | implementation 'com.android.support:appcompat-v7:26.1.0'
35 | implementation 'com.android.support:design:26.1.0'
36 | implementation 'com.google.firebase:firebase-core:16.0.3'
37 | implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
38 | implementation 'com.rmtheis:tess-two:6.0.4'
39 | implementation 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
40 | implementation 'com.google.firebase:firebase-ads:15.0.1'
41 | }
42 |
43 | apply plugin: 'com.google.gms.google-services'
44 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\User\Documents\sdk-update/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -dontwarn android.test.**
20 |
21 |
22 | -keep class org.junit.** { *; }
23 | -dontwarn org.junit.**
24 |
25 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/ltapps/textscanner/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
30 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/assets/trainneddata/eng.traineddata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/assets/trainneddata/eng.traineddata
--------------------------------------------------------------------------------
/app/src/main/assets/trainneddata/spa.traineddata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/assets/trainneddata/spa.traineddata
--------------------------------------------------------------------------------
/app/src/main/java/com/ltapps/textscanner/Binarization.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.support.design.widget.FloatingActionButton;
8 | import android.support.v4.view.ViewCompat;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.AppCompatSeekBar;
11 | import android.support.v7.widget.Toolbar;
12 | import android.view.View;
13 | import android.widget.AdapterView;
14 | import android.widget.ArrayAdapter;
15 | import android.widget.ImageView;
16 | import android.widget.LinearLayout;
17 | import android.widget.SeekBar;
18 | import android.widget.Spinner;
19 | import android.widget.TextView;
20 |
21 | import com.googlecode.leptonica.android.GrayQuant;
22 | import com.googlecode.leptonica.android.Pix;
23 |
24 | import java.util.Arrays;
25 |
26 |
27 | public class Binarization extends AppCompatActivity implements View.OnClickListener, AppCompatSeekBar.OnSeekBarChangeListener {
28 | private ImageView img;
29 | private Toolbar toolbar;
30 | private AppCompatSeekBar seekBar;
31 | private Pix pix;
32 | private FloatingActionButton fab;
33 | public static Bitmap umbralization;
34 | private Spinner spinner;
35 | public static int language;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.binarization);
41 | toolbar = (Toolbar) findViewById(R.id.toolbar);
42 | setSupportActionBar(toolbar);
43 | ViewCompat.setElevation(toolbar,10);
44 | ViewCompat.setElevation((LinearLayout) findViewById(R.id.extension),10);
45 | spinner = (Spinner) findViewById(R.id.language);
46 |
47 | img = (ImageView) findViewById(R.id.croppedImage);
48 | fab = (FloatingActionButton) findViewById(R.id.nextStep);
49 | fab.setOnClickListener(this);
50 | pix = com.googlecode.leptonica.android.ReadFile.readBitmap(CropAndRotate.croppedImage);
51 |
52 | final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, Arrays.asList("English", "Spanish"));
53 | spinner.setAdapter(adapter);
54 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
55 | @Override
56 | public void onItemSelected(AdapterView> adapterView, View view, int i, long l) {
57 | ((TextView) view).setTextColor(Color.WHITE);
58 | language = i;
59 | }
60 |
61 | @Override
62 | public void onNothingSelected(AdapterView> adapterView) {
63 |
64 | }
65 | });
66 | OtsuThresholder otsuThresholder = new OtsuThresholder();
67 | int threshold = otsuThresholder.doThreshold(pix.getData());
68 | /* increase threshold because is better*/
69 | threshold += 20;
70 | umbralization = com.googlecode.leptonica.android.WriteFile.writeBitmap(GrayQuant.pixThresholdToBinary(pix,threshold));
71 | img.setImageBitmap(umbralization);
72 | seekBar = (AppCompatSeekBar) findViewById(R.id.umbralization);
73 | seekBar.setProgress(Integer.valueOf((50 * threshold)/254));
74 | seekBar.setOnSeekBarChangeListener(this);
75 |
76 | }
77 |
78 | @Override
79 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
80 | }
81 |
82 | @Override
83 | public void onStartTrackingTouch(SeekBar seekBar) {
84 |
85 | }
86 |
87 | @Override
88 | public void onStopTrackingTouch(SeekBar seekBar) {
89 |
90 | umbralization = com.googlecode.leptonica.android.WriteFile.writeBitmap(
91 | GrayQuant.pixThresholdToBinary(pix,Integer.valueOf(((254 * seekBar.getProgress())/50)))
92 | );
93 | img.setImageBitmap(umbralization);
94 |
95 | }
96 |
97 |
98 | @Override
99 | public void onClick(View view) {
100 | if(view.getId() == R.id.nextStep) {
101 | Intent intent = new Intent(Binarization.this, Recognizer.class);
102 | startActivity(intent);
103 | }
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ltapps/textscanner/CropAndRotate.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.design.widget.FloatingActionButton;
8 | import android.support.v4.view.ViewCompat;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 |
15 | import com.theartofdev.edmodo.cropper.CropImageView;
16 |
17 |
18 | public class CropAndRotate extends AppCompatActivity implements View.OnClickListener, Toolbar.OnMenuItemClickListener{
19 | private Toolbar toolbar;
20 | private FloatingActionButton mFab;
21 | public static Bitmap croppedImage;
22 | private String message;
23 | CropImageView cropImageView;
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.crop_and_rotate);
28 | toolbar = (Toolbar) findViewById(R.id.toolbar);
29 | setSupportActionBar(toolbar);
30 | ViewCompat.setElevation(toolbar,10);
31 | toolbar.setOnMenuItemClickListener(this);
32 | Intent intent = getIntent();
33 | message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
34 | cropImageView = (CropImageView) findViewById(R.id.cropImageView);
35 |
36 | cropImageView.setImageUriAsync(Uri.parse(message));
37 | mFab = (FloatingActionButton) findViewById(R.id.nextStep);
38 | mFab.setOnClickListener(this);
39 |
40 | }
41 |
42 |
43 |
44 | @Override
45 | public void onClick(View view) {
46 | if(view.getId() == R.id.nextStep){
47 | cropImageView.setOnCropImageCompleteListener(new CropImageView.OnCropImageCompleteListener() {
48 | @Override
49 | public void onCropImageComplete(CropImageView view, CropImageView.CropResult result) {
50 | croppedImage = result.getBitmap();
51 | Intent intent = new Intent(CropAndRotate.this, Binarization.class);
52 | startActivity(intent);
53 | }
54 | });
55 | cropImageView.getCroppedImageAsync();
56 | }
57 | }
58 |
59 |
60 | @Override
61 | public boolean onCreateOptionsMenu(Menu menu) {
62 | // Inflate the menu; this adds items to the action bar if it is present.
63 | getMenuInflater().inflate(R.menu.menu_rotate, menu);
64 | return super.onCreateOptionsMenu(menu);
65 | }
66 |
67 |
68 | @Override
69 | public boolean onMenuItemClick(MenuItem item) {
70 | switch (item.getItemId()) {
71 | case R.id.rotate_left:
72 | cropImageView.rotateImage(-90);
73 | break;
74 | case R.id.rotate_right:
75 | cropImageView.rotateImage(90);
76 | break;
77 | }
78 | return false;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ltapps/textscanner/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import android.Manifest;
4 | import android.content.ComponentName;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.content.pm.ResolveInfo;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.os.Environment;
11 | import android.os.Parcelable;
12 | import android.provider.MediaStore;
13 | import android.support.v4.app.ActivityCompat;
14 | import android.support.v4.content.ContextCompat;
15 | import android.support.v4.view.ViewCompat;
16 | import android.support.v7.app.AppCompatActivity;
17 | import android.support.v7.widget.Toolbar;
18 | import android.view.View;
19 |
20 | import com.google.android.gms.ads.AdRequest;
21 | import com.google.android.gms.ads.AdView;
22 | import com.google.android.gms.ads.MobileAds;
23 |
24 | import java.io.File;
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
29 |
30 | private Uri outputFileUri;
31 | private View mView;
32 | public final static String EXTRA_MESSAGE = "com.ltapps.textscanner.message";
33 | private AdView mAdView;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_main);
39 | Toolbar toolbar = findViewById(R.id.toolbar);
40 | //Toolbar will now take on default Action Bar characteristics
41 | setSupportActionBar(toolbar);
42 | ViewCompat.setElevation(toolbar,10);
43 | mView = findViewById(R.id.mainView);
44 | mView.setOnClickListener(this);
45 |
46 | // AdMob App ID
47 | MobileAds.initialize(this, BuildConfig.AdMobAppId);
48 | mAdView = findViewById(R.id.adView);
49 | AdRequest adRequest = new AdRequest.Builder().build();
50 | mAdView.loadAd(adRequest);
51 |
52 | if (ContextCompat.checkSelfPermission(this,
53 | Manifest.permission.WRITE_EXTERNAL_STORAGE)
54 | != PackageManager.PERMISSION_GRANTED) {
55 |
56 | // Should we show an explanation?
57 | if (ActivityCompat.shouldShowRequestPermissionRationale(this,
58 | Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
59 |
60 | // Show an explanation to the user *asynchronously* -- don't block
61 | // this thread waiting for the user's response! After the user
62 | // sees the explanation, try again to request the permission.
63 |
64 | } else {
65 |
66 | // No explanation needed, we can request the permission.
67 |
68 | ActivityCompat.requestPermissions(this,
69 | new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
70 | 1);
71 |
72 | // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
73 | // app-defined int constant. The callback method gets the
74 | // result of the request.
75 | }
76 | }
77 |
78 |
79 | }
80 |
81 | private void selectImage() {
82 | final String fname = "img_"+ System.currentTimeMillis() + ".jpg";
83 | final File sdImageMainDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), fname);
84 | outputFileUri = Uri.fromFile(sdImageMainDirectory);
85 |
86 | // Camera.
87 | final List cameraIntents = new ArrayList<>();
88 | final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
89 | final PackageManager packageManager = getPackageManager();
90 | final List listCam = packageManager.queryIntentActivities(captureIntent, 0);
91 | for(ResolveInfo res : listCam) {
92 | final String packageName = res.activityInfo.packageName;
93 | final Intent intent = new Intent(captureIntent);
94 | intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
95 | intent.setPackage(packageName);
96 | intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
97 | cameraIntents.add(intent);
98 | }
99 | // Filesystem.
100 | final Intent galleryIntent = new Intent();
101 | galleryIntent.setType("image/*");
102 | galleryIntent.setAction(Intent.ACTION_PICK);
103 |
104 | // Chooser of filesystem options.
105 | final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");
106 |
107 | // Add the camera options.
108 | chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
109 |
110 | startActivityForResult(chooserIntent, 1);
111 | }
112 |
113 | @Override
114 | public void onClick(View view) {
115 | if(mView == view) {
116 | selectImage();
117 | }
118 | }
119 |
120 | @Override
121 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
122 | if (resultCode == RESULT_OK) {
123 | if (requestCode == 1) {
124 | final boolean isCamera;
125 | if (data == null || data.getData() == null) {
126 | isCamera = true;
127 | } else {
128 | final String action = data.getAction();
129 | isCamera = action != null && action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
130 | }
131 | Uri selectedImageUri;
132 | if (isCamera) {
133 | selectedImageUri = outputFileUri;
134 | if (selectedImageUri == null) return;
135 | nextStep(selectedImageUri.toString());
136 |
137 | } else {
138 | selectedImageUri = data.getData();
139 | if (selectedImageUri == null) return;
140 | nextStep(selectedImageUri.toString());
141 | }
142 | }
143 | }
144 | }
145 |
146 | private void nextStep(String file) {
147 | Intent intent = new Intent(this, CropAndRotate.class);
148 | intent.putExtra(EXTRA_MESSAGE, file);
149 | startActivity(intent);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ltapps/textscanner/OtsuThresholder.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | public class OtsuThresholder
4 | {
5 | private int histData[];
6 | private int maxLevelValue;
7 | private int threshold;
8 |
9 | public OtsuThresholder()
10 | {
11 | histData = new int[256];
12 | }
13 |
14 | public int[] getHistData()
15 | {
16 | return histData;
17 | }
18 |
19 | public int getMaxLevelValue()
20 | {
21 | return maxLevelValue;
22 | }
23 |
24 | public int getThreshold()
25 | {
26 | return threshold;
27 | }
28 |
29 | public int doThreshold(byte[] srcData)
30 | {
31 | int ptr;
32 |
33 | // Clear histogram data
34 | // Set all values to zero
35 | ptr = 0;
36 | while (ptr < histData.length) histData[ptr++] = 0;
37 |
38 | // Calculate histogram and find the level with the max value
39 | // Note: the max level value isn't required by the Otsu method
40 | ptr = 0;
41 | maxLevelValue = 0;
42 | while (ptr < srcData.length)
43 | {
44 | int h = 0xFF & srcData[ptr];
45 | histData[h] ++;
46 | if (histData[h] > maxLevelValue) maxLevelValue = histData[h];
47 | ptr ++;
48 | }
49 |
50 | // Total number of pixels
51 | int total = srcData.length;
52 |
53 | float sum = 0;
54 | for (int t=0 ; t<256 ; t++) sum += t * histData[t];
55 |
56 | float sumB = 0;
57 | int wB = 0;
58 | int wF = 0;
59 |
60 | float varMax = 0;
61 | threshold = 0;
62 |
63 | for (int t=0 ; t<256 ; t++)
64 | {
65 | wB += histData[t]; // Weight Background
66 | if (wB == 0) continue;
67 |
68 | wF = total - wB; // Weight Foreground
69 | if (wF == 0) break;
70 |
71 | sumB += (float) (t * histData[t]);
72 |
73 | float mB = sumB / wB; // Mean Background
74 | float mF = (sum - sumB) / wF; // Mean Foreground
75 |
76 | // Calculate Between Class Variance
77 | float varBetween = (float)wB * (float)wF * (mB - mF) * (mB - mF);
78 |
79 | // Check if new maximum found
80 | if (varBetween > varMax) {
81 | varMax = varBetween;
82 | threshold = t;
83 | }
84 | }
85 |
86 |
87 | return threshold;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ltapps/textscanner/Recognizer.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.ClipData;
5 | import android.content.ClipboardManager;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.res.AssetManager;
9 | import android.os.AsyncTask;
10 | import android.os.Bundle;
11 | import android.os.Environment;
12 | import android.support.v4.content.ContextCompat;
13 | import android.support.v4.view.ViewCompat;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.support.v7.widget.Toolbar;
16 | import android.text.Editable;
17 | import android.text.Spannable;
18 | import android.text.SpannableString;
19 | import android.text.TextWatcher;
20 | import android.text.method.ScrollingMovementMethod;
21 | import android.text.style.BackgroundColorSpan;
22 | import android.util.Log;
23 | import android.view.Menu;
24 | import android.view.MenuItem;
25 | import android.widget.EditText;
26 | import android.widget.LinearLayout;
27 | import android.widget.TextView;
28 | import android.widget.Toast;
29 |
30 | import com.google.android.gms.ads.AdRequest;
31 | import com.google.android.gms.ads.AdView;
32 | import com.google.android.gms.ads.MobileAds;
33 | import com.googlecode.tesseract.android.TessBaseAPI;
34 |
35 | import java.io.File;
36 | import java.io.FileOutputStream;
37 | import java.io.IOException;
38 | import java.io.InputStream;
39 | import java.io.OutputStream;
40 |
41 | public class Recognizer extends AppCompatActivity implements Toolbar.OnMenuItemClickListener {
42 | private Toolbar toolbar;
43 | private EditText search;
44 | private TextView textView;
45 | private String textScanned;
46 | ProgressDialog progressCopy, progressOcr;
47 | TessBaseAPI baseApi;
48 | AsyncTask copy = new copyTask();
49 | AsyncTask ocr = new ocrTask();
50 | private AdView mAdView;
51 |
52 | private static final String DATA_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/com.ltapps.textscanner/";
53 |
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | setContentView(R.layout.recognizer);
58 |
59 | // AdMob App ID
60 | MobileAds.initialize(this, BuildConfig.AdMobAppId);
61 | mAdView = findViewById(R.id.adView);
62 | AdRequest adRequest = new AdRequest.Builder().build();
63 | mAdView.loadAd(adRequest);
64 |
65 | toolbar = (Toolbar) findViewById(R.id.toolbar);
66 | setSupportActionBar(toolbar);
67 | toolbar.setOnMenuItemClickListener(this);
68 | ViewCompat.setElevation(toolbar,10);
69 | ViewCompat.setElevation((LinearLayout) findViewById(R.id.extension),10);
70 | textView = (TextView) findViewById(R.id.textExtracted);
71 | textView.setMovementMethod(new ScrollingMovementMethod());
72 | search = (EditText) findViewById(R.id.search_text);
73 | // Setting progress dialog for copy job.
74 | progressCopy = new ProgressDialog(Recognizer.this);
75 | progressCopy.setProgressStyle(ProgressDialog.STYLE_SPINNER);
76 | progressCopy.setIndeterminate(true);
77 | progressCopy.setCancelable(false);
78 | progressCopy.setTitle("Dictionaries");
79 | progressCopy.setMessage("Copying dictionary files");
80 | // Setting progress dialog for ocr job.
81 | progressOcr = new ProgressDialog(this);
82 | progressOcr.setProgressStyle(ProgressDialog.STYLE_SPINNER);
83 | progressOcr.setIndeterminate(true);
84 | progressOcr.setCancelable(false);
85 | progressOcr.setTitle("OCR");
86 | progressOcr.setMessage("Extracting text, please wait");
87 | textScanned = "";
88 |
89 | search.addTextChangedListener(new TextWatcher() {
90 | @Override
91 | public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
92 | @Override
93 | public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
94 |
95 | }
96 | @Override
97 | public void afterTextChanged(Editable editable) {
98 | String ett = search.getText().toString().replaceAll("\n"," ");
99 | String tvt = textView.getText().toString().replaceAll("\n"," ");
100 | textView.setText(textView.getText().toString());
101 | if(!ett.toString().isEmpty()) {
102 | int ofe = tvt.toLowerCase().indexOf(ett.toLowerCase(), 0);
103 | Spannable WordtoSpan = new SpannableString(textView.getText());
104 | for (int ofs = 0; ofs < tvt.length() && ofe != -1; ofs = ofe + 1) {
105 | ofe = tvt.toLowerCase().indexOf(ett.toLowerCase(), ofs);
106 | if (ofe == -1)
107 | break;
108 | else {
109 | WordtoSpan.setSpan(new BackgroundColorSpan(ContextCompat.getColor(Recognizer.this, R.color.colorAccent)), ofe, ofe + ett.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
110 | textView.setText(WordtoSpan, TextView.BufferType.SPANNABLE);
111 | }
112 |
113 | }
114 | }
115 | }
116 | });
117 |
118 | copy.execute();
119 | ocr.execute();
120 |
121 |
122 | }
123 |
124 | private void recognizeText(){
125 | String language = "";
126 | if (Binarization.language == 0)
127 | language = "eng";
128 | else
129 | language= "spa";
130 |
131 | baseApi = new TessBaseAPI();
132 | baseApi.init(DATA_PATH, language,TessBaseAPI.OEM_TESSERACT_ONLY);
133 | baseApi.setImage(Binarization.umbralization);
134 | textScanned = baseApi.getUTF8Text();
135 |
136 | }
137 |
138 |
139 | private void copyAssets() {
140 | AssetManager assetManager = getAssets();
141 | String[] files = null;
142 | try {
143 | files = assetManager.list("trainneddata");
144 | } catch (IOException e) {
145 | Log.e("tag", "Failed to get asset file list.", e);
146 | }
147 | for(String filename : files) {
148 | Log.i("files",filename);
149 | InputStream in = null;
150 | OutputStream out = null;
151 | String dirout= DATA_PATH + "tessdata/";
152 | File outFile = new File(dirout, filename);
153 | if(!outFile.exists()) {
154 | try {
155 | in = assetManager.open("trainneddata/"+filename);
156 | (new File(dirout)).mkdirs();
157 | out = new FileOutputStream(outFile);
158 | copyFile(in, out);
159 | in.close();
160 | in = null;
161 | out.flush();
162 | out.close();
163 | out = null;
164 | } catch (IOException e) {
165 | Log.e("tag", "Error creating files", e);
166 | }
167 | }
168 | }
169 | }
170 | private void copyFile(InputStream in, OutputStream out) throws IOException {
171 | byte[] buffer = new byte[1024];
172 | int read;
173 | while((read = in.read(buffer)) != -1){
174 | out.write(buffer, 0, read);
175 | }
176 | }
177 |
178 | private class copyTask extends AsyncTask {
179 |
180 | @Override
181 | protected void onPreExecute() {
182 | super.onPreExecute();
183 | progressCopy.show();
184 | }
185 |
186 | @Override
187 | protected void onPostExecute(Void aVoid) {
188 | super.onPostExecute(aVoid);
189 | progressCopy.cancel();
190 | progressOcr.show();
191 |
192 | }
193 |
194 | @Override
195 | protected Void doInBackground(Void... params) {
196 | Log.i("CopyTask","copying..");
197 | copyAssets();
198 | return null;
199 | }
200 | }
201 |
202 | private class ocrTask extends AsyncTask {
203 |
204 | @Override
205 | protected void onPreExecute() {
206 | super.onPreExecute();
207 | }
208 |
209 | @Override
210 | protected void onPostExecute(Void aVoid) {
211 | super.onPostExecute(aVoid);
212 | progressOcr.cancel();
213 | textView.setText(textScanned);
214 |
215 | }
216 |
217 | @Override
218 | protected Void doInBackground(Void... params) {
219 | Log.i("OCRTask","extracting..");
220 | recognizeText();
221 | return null;
222 | }
223 | }
224 |
225 | @Override
226 | public boolean onCreateOptionsMenu(Menu menu) {
227 | // Inflate the menu; this adds items to the action bar if it is present.
228 | getMenuInflater().inflate(R.menu.menu_result, menu);
229 | return super.onCreateOptionsMenu(menu);
230 | }
231 |
232 |
233 | @Override
234 | public boolean onMenuItemClick(MenuItem item) {
235 | switch (item.getItemId()) {
236 | case R.id.copy_text:
237 | ClipboardManager clipboard = (ClipboardManager)
238 | getSystemService(Context.CLIPBOARD_SERVICE);
239 | ClipData clip = ClipData.newPlainText("TextScanner", textView.getText());
240 | clipboard.setPrimaryClip(clip);
241 | Toast.makeText(Recognizer.this,"Text has been copied to clipboard", Toast.LENGTH_LONG).show();
242 | break;
243 | case R.id.new_scan:
244 | Intent i = getBaseContext().getPackageManager()
245 | .getLaunchIntentForPackage( getBaseContext().getPackageName() );
246 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
247 | startActivity(i);
248 | break;
249 | }
250 | return false;
251 | }
252 | }
253 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/drawable/camera.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
25 |
26 |
32 |
33 |
38 |
39 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/binarization.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
24 |
25 |
26 |
34 |
41 |
46 |
47 |
48 |
53 |
54 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/crop_and_rotate.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recognizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
25 |
36 |
37 |
38 |
45 |
46 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_result.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_rotate.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_content_copy_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_content_copy_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_open_in_new_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_open_in_new_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_rotate_left_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_rotate_left_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_rotate_right_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-hdpi/ic_rotate_right_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_content_copy_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_content_copy_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_open_in_new_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_open_in_new_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_rotate_left_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_rotate_left_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_rotate_right_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-mdpi/ic_rotate_right_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_content_copy_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_content_copy_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_open_in_new_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_open_in_new_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_rotate_left_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_rotate_left_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_rotate_right_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xhdpi/ic_rotate_right_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_content_copy_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_content_copy_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_open_in_new_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_open_in_new_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_rotate_left_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_rotate_left_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_rotate_right_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxhdpi/ic_rotate_right_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_content_copy_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_content_copy_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_done_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_done_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_open_in_new_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_open_in_new_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_rotate_left_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_rotate_left_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_rotate_right_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/app/src/main/res/mipmap-xxxhdpi/ic_rotate_right_white_24dp.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 | #e53935
4 | #D32F2F
5 | #FFC107
6 | #FFFFFF
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Text Scanner
3 | Upload an image
4 | camera
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/ltapps/textscanner/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.ltapps.textscanner;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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 | jcenter()
6 | google()
7 | maven {
8 | url 'https://maven.fabric.io/public'
9 | }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.1.4'
13 | classpath 'com.google.gms:google-services:3.2.0'
14 | classpath 'io.fabric.tools:gradle:1.25.2'
15 |
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | jcenter()
24 | google()
25 | maven {
26 | url 'https://maven.google.com/'
27 | }
28 | }
29 | }
30 |
31 | task clean(type: Delete) {
32 | delete rootProject.buildDir
33 | }
34 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/testica/text-scanner/49c2219b392a34399ef646d0493e5571f2a92c95/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 30 20:48:32 VET 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------