LiveEdgeDetection is an Android document detection library built on top of OpenCV. It scans documents from camera live mode and allows you to adjust crop using the detected 4 edges and performs perspective transformation of the cropped image. It works best with a dark background.

Related tags

LiveEdgeDetection
Overview

Release

LiveEdgeDetection

LiveEdgeDetection is an Android document detection library built on top of OpenCV. It scans documents from camera live mode and allows you to adjust crop using the detected 4 edges and performs perspective transformation of the cropped image.

It works best with a dark background.

JavaDocs

You can browse the JavaDocs for the latest release

Download apk

Try the sample app

Screenshots

Use darker bg Move closer Move away Adjust angle Hold still Adjust crop Result

Integrating into your project

This library is available in JitPack.io repository. To use it, make sure to add the below inside root build.gradle file

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

and add the repository's url to the app's build.gradle file.

dependencies {
   compile 'com.github.adityaarora1:LiveEdgeDetection:1.0.6'
   
    // Other dependencies your app might use
}

Usage

Out of the box it uses OpenCV.

  1. Start startActivityForResult from your activity
startActivityForResult(new Intent(this, ScanActivity.class), REQUEST_CODE);
  1. Get a file path for cropped image on onActivityResult
String filePath = data.getExtras().getString(ScanConstants.SCANNED_RESULT);
Bitmap baseBitmap = ScanUtils.decodeBitmapFromFile(filePath, ScanConstants.IMAGE_NAME);
  1. Display the image using TouchImageView
<com.adityaarora.liveedgedetection.view.TouchImageView
        android:id="@+id/scanned_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="center" />

Help

Versioning policy

We use Semantic Versioning 2.0.0 as our versioning policy.

Bugs, Feature requests

Found a bug? Something that's missing? Feedback is an important part of improving the project, so please open an issue.

Code

Fork this project and start working on your own feature branch. When you're done, send a Pull Request to have your suggested changes merged into the master branch by the project's collaborators. Read more about the GitHub flow.

License

Copyright 2018 Aditya Arora.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Donation

Donate paypal

Paypal

Issues
  • Patch for improved edge detection

    Patch for improved edge detection

    Just OTSU/Binary thresholding is not enough. Following steps drastically improve the edge detection.

    1. First blur and normalize the image for uniformity,
    2. Truncate light-gray to white and normalize,
    3. Apply canny edge detection,
    4. Cutoff weak edges,
    5. Apply closing(morphology), then proceed to finding contours. Also converting the contours to their Convex Hulls will remove minor nuances in the contour.
    opened by Udayraj123 14
  • java.lang.RuntimeException: takePicture failed

    java.lang.RuntimeException: takePicture failed

    04-13 12:45:29.958 19143-19143/com.adityaarora.liveedgedetection E/AndroidRuntime: FATAL EXCEPTION: main Process: com.adityaarora.liveedgedetection, PID: 19143 java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture(Native Method) at android.hardware.Camera.takePicture(Camera.java:1543) at android.hardware.Camera.takePicture(Camera.java:1485) at com.adityaarora.liveedgedetection.view.ScanSurfaceView.autoCapture(ScanSurfaceView.java:313) at com.adityaarora.liveedgedetection.view.ScanSurfaceView.access$500(ScanSurfaceView.java:43) at com.adityaarora.liveedgedetection.view.ScanSurfaceView$3.onTick(ScanSurfaceView.java:296) at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:133) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6205) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

    opened by anshdiv 5
  • FATAL EXCEPTION: main on Moto Xstyle Running Android 7.0

    FATAL EXCEPTION: main on Moto Xstyle Running Android 7.0

    Process: com.adityaarora.liveedgedetection, PID: 10440 java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture(Native Method) at android.hardware.Camera.takePicture(Camera.java:1461) at android.hardware.Camera.takePicture(Camera.java:1406) at com.adityaarora.liveedgedetection.view.ScanSurfaceView.autoCapture(ScanSurfaceView.java:313) at com.adityaarora.liveedgedetection.view.ScanSurfaceView.access$500(ScanSurfaceView.java:43) at com.adityaarora.liveedgedetection.view.ScanSurfaceView$3.onTick(ScanSurfaceView.java:296) at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:133) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123)

        at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)`
    
    opened by nikunjgundaniya 2
  • Can it be possible to detect edge of document on any surface

    Can it be possible to detect edge of document on any surface

    Currently the edge of document is detecting on only dark background, but it ll be more useful if it can detect on any surface.

    opened by patelranjit 2
  • Is it possible to make it work with white background or else ?

    Is it possible to make it work with white background or else ?

    Hi, Is it possible to make it work with white background or something else ? where should I modify the code to make changes ?

    opened by ManuSynert 1
  • The sample app only shows

    The sample app only shows "Use darker background" and stays there, any hint?

    The sample app only shows "Use darker background" and stays there, any hint? I tryed the sample app and the lib inside in my app with the same result. I don't know if I'm missing something.

    opened by ginomade 1
  • Log activity

    Log activity

    opened by hannesa2 0
  • Parallel ci

    Parallel ci

    opened by hannesa2 0
  • Android Studio 3.6.2

    Android Studio 3.6.2

    opened by hannesa2 0
  • Espresso test

    Espresso test

    opened by hannesa2 0
  • It does not detect any edge if we are in sunlight

    It does not detect any edge if we are in sunlight

    Is there a way to detect the edge when we are in bright light. Right now I am not able to do that in this demo.

    Can anyone please help me with this?

    Thanks in advancee.

    opened by JeetSA 0
  • Crash fix

    Crash fix

    it crashed on my phone every time I opened application. it was because of version of openCV library. So I used another version of opencv in project and it did not crash anymore.

    opened by baharkhd 0
  • Access denied finding property

    Access denied finding property

    Hi, it gives "Access denied finding property "vendor.camera.aux.packagelist" then "No implementation found for void org.opencv.imgproc.Imgproc.Canny_3" can you help me?

    opened by cagataysenturca 0
  • Users/ka05/opencv update 343

    Users/ka05/opencv update 343

    This PR updates OpenCV from version 340 to 343 resolving Issue #39.

    I apologize for the size of this PR as many files were replaced for the openCVLibrary module update. Actual code changes are limited to the gradle files.

    opened by ka05 4
  • App Crashes on Camera Open

    App Crashes on Camera Open

    java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.imgproc.Imgproc.Canny_3(long, long, double, double) (tried Java_org_opencv_imgproc_Imgproc_Canny_13 and Java_org_opencv_imgproc_Imgproc_Canny_13__JJDD)

    java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.imgproc.Imgproc.Canny_3(long, long, double, double) (tried Java_org_opencv_imgproc_Imgproc_Canny_13 and Java_org_opencv_imgproc_Imgproc_Canny_13__JJDD) at org.opencv.imgproc.Imgproc.Canny_3(Native Method) at org.opencv.imgproc.Imgproc.Canny(Imgproc.java:1104) at com.adityaarora.liveedgedetection.util.ScanUtils.detectLargestQuadrilateral(ScanUtils.java:359) at com.adityaarora.liveedgedetection.view.ScanSurfaceView$1.onPreviewFrame(ScanSurfaceView.java:182) at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1438) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6863) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2020-02-01 18:12:45.429 1883-1883/com.jipl.storedge E/UncaughtException: java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.imgproc.Imgproc.Canny_3(long, long, double, double) (tried Java_org_opencv_imgproc_Imgproc_Canny_13 and Java_org_opencv_imgproc_Imgproc_Canny_13__JJDD) at org.opencv.imgproc.Imgproc.Canny_3(Native Method) at org.opencv.imgproc.Imgproc.Canny(Imgproc.java:1104) at com.adityaarora.liveedgedetection.util.ScanUtils.detectLargestQuadrilateral(ScanUtils.java:359) at com.adityaarora.liveedgedetection.view.ScanSurfaceView$1.onPreviewFrame(ScanSurfaceView.java:182) at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1438) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6863) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

    opened by jatankshirsagar 6
  • Does not work Landscape Mode

    Does not work Landscape Mode

    It detect document edge only on Portrait mode I'm trying to make it follow orientation any ideas ?

    opened by zakblacki 0
  • App crash on latest Patch merge

    App crash on latest Patch merge

    Stacktrace I don't know why this is happening this line is causing crash

    // Imgproc.Canny(originalMat, originalMat, ScanConstants.CANNY_THRESH_U, ScanConstants.CANNY_THRESH_L);

    2020-01-20 02:10:49.948 23135-23135/? E/veedgedetectio: Unknown bits set in runtime_flags: 0x8000
    2020-01-20 02:10:50.854 23135-23135/com.adityaarora.liveedgedetection E/veedgedetectio: No implementation found for void org.opencv.imgproc.Imgproc.Canny_3(long, long, double, double) (tried Java_org_opencv_imgproc_Imgproc_Canny_13 and Java_org_opencv_imgproc_Imgproc_Canny_13__JJDD)
    2020-01-20 02:10:50.855 23135-23135/com.adityaarora.liveedgedetection E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.adityaarora.liveedgedetection, PID: 23135
        java.lang.UnsatisfiedLinkError: No implementation found for void org.opencv.imgproc.Imgproc.Canny_3(long, long, double, double) (tried Java_org_opencv_imgproc_Imgproc_Canny_13 and Java_org_opencv_imgproc_Imgproc_Canny_13__JJDD)
            at org.opencv.imgproc.Imgproc.Canny_3(Native Method)
            at org.opencv.imgproc.Imgproc.Canny(Imgproc.java:1104)
            at com.adityaarora.liveedgedetection.util.ScanUtils.detectLargestQuadrilateral(ScanUtils.java:359)
            at com.adityaarora.liveedgedetection.view.ScanSurfaceView$1.onPreviewFrame(ScanSurfaceView.java:182)
            at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1221)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:214)
            at android.app.ActivityThread.main(ActivityThread.java:7356)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    
    
    opened by zakblacki 0
  • How to build timeout for autofocus OCR

    How to build timeout for autofocus OCR

    Sometimes the image saved get blurry because of the autofocus wasn't ready Is there anyway to make constraint for the algorithm to detect OCR image ?

    opened by zakblacki 0
  • Build Error for V1.1 and 1.0.6

    Build Error for V1.1 and 1.0.6

    There is an error on Jitpack.io for ALL builds. But the latest one is also having the same error on the build.log file. Error is stated below: java.lang.IllegalStateException: compileSdkVersion is not specified.

    For more info look at the build log: https://jitpack.io/com/github/adityaarora1/LiveEdgeDetection/v1.1/build.log

    For version 1.0.6 the issue is:

    • What went wrong: Execution failed for task ':liveedgedetection:transformNativeLibsWithStripDebugSymbolForRelease'.

    A problem occurred starting process 'command '/opt/android-sdk-linux/ndk-bundle/toolchains/mips64el-linux-android/prebuilt/linux-x86_64/bin/mips64el-linux-android-strip''

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    • Get more help at https://help.gradle.org

    BUILD FAILED in 2s 30 actionable tasks: 28 executed, 2 up-to-date Build tool exit code: 0 Looking for artifacts... Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2 Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2 Looking for pom.xml in build directory and ~/.m2 2019-06-24T20:26:59.913041838Z Exit code: 0

    ERROR: No build artifacts found

    For more info: https://jitpack.io/com/github/adityaarora1/LiveEdgeDetection/1.0.6/build.log

    opened by japhetlee-ong 2
  • How to use this library

    How to use this library

    Hi, I've tried to use this library with gradle but it cant find any of the artefacts from Jitpack.io, how can I integrate it into my project?

    Thanks

    opened by zeebikenav 1
Releases(1.0.6)
Owner
Aditya Arora
Aditya Arora
Camera Folder: "Take a Photo from Camera" everywhere where you can open a photo file

When "Camera Folder" is installed many Android-Apps that can open jpg files can also take a photo from camera.

k3b 7 Sep 14, 2021
📸 Use Android camera to take pictures and videos, based on `camera2` api.

Camera Use Android camera to take pictures and videos, based on camera2 api. Features Auto filled CameraView for previewing Support both image capture

Hong Duan 112 Aug 15, 2021
Quick photo and video camera with a flash, customizable resolution and no ads.

Simple Camera A camera with flash, zoom and no ads. The camera is usable for both photo taking and video recording. You can switch between front and r

Simple Mobile Tools 562 Oct 12, 2021
📸 A library that allows you to capture images secretly, in background without alerting users.

HiddenCamera A library that allows you to capture images secretly, in background without alerting users. Gradle Dependency Add the dependency to your

Cotta & Cush Limited 105 Sep 18, 2021
Android library to choose image from gallery or camera with option to compress result image

ImagePicker Android library to choose image from gallery or camera with option to compress result image. Download Add this to your project's build.gra

Mayank Nagwanshi 64 Oct 20, 2021
Measures human heart rate using camera and flash light.

Heart-Rate-Ometer Introduction Measures human heart rate using camera and flash light. How-it-works https://github.com/phishman3579/android-heart-rate

Jan Rabe 78 Oct 6, 2021
Powerful custom Android Camera with granular control over the video quality and filesize, restricting recordings to landscape only.

LandscapeVideoCamera Highly flexible Android Camera which offers granular control over the video quality and filesize, while restricting recordings to

Jeroen Mols 1.2k Oct 8, 2021
Image Picker library for Android

Ronnie-Image-Picker Asks for Camera and storage permission and return uri of the images taken or picked from the gallery. Min Api Level: 16 Build Syst

Ronnie Otieno 18 Sep 24, 2021
Pix is a Whatsapp image picker replica. with this, you can integrate an image picker just like WhatsApp.

Pix (WhatsApp Style Image and Video Picker) Pix is a WhatsApp image picker replica. with this you can integrate a image picker just like WhatsApp. Upc

Akshay sharma 630 Oct 9, 2021
Wrapper around the android Camera class that simplifies its usage

EasyCamera Wrapper around the android Camera class that simplifies its usage (read more about the process) Usage: // the surface where the preview wil

Bozhidar Bozhanov 646 Aug 4, 2021
A new camera app for GrapheneOS based on the modern CameraX library.

This is the new GrapheneOS Camera app based on Android's modern CameraX library. It's currently in the alpha phase and isn't yet included in GrapheneO

GrapheneOS 33 Oct 16, 2021
Instagram like Image Picker for Android

ImagePicker A simple Instagram like library to select images from the gallery and camera. Screenshot Usage For full example, please refer to the sampl

Akvelon 17 Oct 6, 2021
Android application to preview, record (MediaRecorder), and fetch each image from both front and rear cameras simultaneously

DuoCamera ?? Overview Android application to preview, record (MediaRecorder) and fetch each image from both front and rear cameras simultaneously. The

Igor Lashkov 1 Oct 17, 2021