-
Notifications
You must be signed in to change notification settings - Fork 167
Home
This library helps you to scan any document like CamScanner.
You need to implement openCV to run this library via import module on Android Studio. Use OpenCV library on this repository. Follow the lines below:
-
File → New → Import Module
-
Select " openCVLibrary " you’ve downloaded from this repository.
-
Click finish
-
Sync gradle
-
File → Project Structure → Select app under modules (this is your app module) → Go to dependencies tab
-
Click + button → Module dependency → Select openCVLibrary → Click ok → Click ok
-
Sync gradle
Add line below to your top level build.gradle
allprojects {
repositories {
/// ....
maven { url "https://jitpack.io" }
}
}
Add lines below to your app level build.gradle
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'com.github.mayuce:AndroidDocumentScanner:1.3'
And Sync the gradle
To start ImageCrop process
ScannerConstants.selectedImageBitmap=btimap
startActivityForResult(Intent(MainActivity@this, ImageCropActivity::class.java),Constants.REQUEST_CROP)
Catch the cropped image
if (requestCode==Constants.REQUEST_CROP && resultCode== Activity.RESULT_OK )
{
if (ScannerConstants.selectedImageBitmap!=null)
imgBitmap.setImageBitmap(ScannerConstants.selectedImageBitmap)
else
Toast.makeText(MainActivity@this,"Something wen't wrong.",Toast.LENGTH_LONG).show()
}
On above Android 9.0 there is magnifier to help user to see zoomed image to crop.
You can customize something in layout via ScannerConstants.
// ScannerConstants.java
public static String cropText="CROP",
backText="CLOSE",
loadingDescription="Please wait",
imageError="Can't picked image,
please try again.",
cropError="You have not selected a valid field. Please make corrections until the lines are blue.";
public static String cropColor="#6666ff",backColor="#ff0000";
public static boolean saveStorage=true; // Make it false if you don't need image in your storage.
There was an error about progress dialog when doing the process. That’s why I’ve removed it, I’ll add something to disable user interract while doing process.
-
Thanks RX library to improve this project.
-
Thanks OpenCV for this awesome library. - https://opencv.org/ and
-
Inspiration from aashari . Thanks him for his source codes. - https://github.com/aashari/android-opencv-camera-scanner