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.

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

Comments
  • 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
  • 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
  • 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
Releases(1.0.6)
Owner
Aditya Arora
Aditya Arora
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 73 May 20, 2022
📸 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 116 Dec 29, 2022
An Android App that uses Machine Learning to recognize the objects in an image captured from the phone's camera

Camera App ?? Description An Android App that uses Machine Learning (ML) to recognize the objects in an image captured from the phone's camera. • Allo

Shikeya Anderson 1 Dec 31, 2022
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 742 Jan 4, 2023
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 81 Jun 29, 2022
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 513 Jan 1, 2023
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 Nov 22, 2022
📸 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 119 Nov 25, 2022
Android camera and serial communication utility that interacts with another device via a USB connection.

PVIT-Payload-Source Android camera and serial communication utility that interacts with another device via a USB connection. PVIT = Palos Verdes Insti

Zeroz & Onez 1 Nov 10, 2021
NguyenThienAn06105 - This repository consist of the code to read camera data on ESP8266 and a simple Android application to visualize the …

MLX90640-HeatCamera This repository consist of the code to read camera data on ESP8266 and a simple Android application to visualize the result. There

Christian Hein 0 Jan 1, 2022
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 644 Jan 7, 2023
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 642 Nov 27, 2022
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 33 Nov 19, 2022
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 5 Nov 28, 2022
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 21 Sep 28, 2022
Snappy - an android camerax library for taking snapshot fast & simple

Snappy is an android camerax library for taking snapshot fast & simple. Easy to integrate, 100% Kotlin & jetpack compose driven.

Nils Druyen 16 Dec 15, 2022
A library to take picture easy, transform your data in different format and save photos in your device

A Magic library to take photos and select pictures in Android. In a simple way and if you need it also save the pictures in device, and facial recogni

Fabian Rosales (Frosquivel Developer) 331 Nov 20, 2022
Bootcamp - Digital Innovation One e NTT Data - Aula de Recursos Nativos do Android

Recursos-Nativos-Android -Foto e Camera Bootcamp - Digital Innovation One e NTT Data - Aula de Recursos Nativos do Android Tutorial de uso da bibliote

Anne Nicolle Zimmermann 0 Jan 3, 2022
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

Darwin Francis 58 Nov 1, 2022
A sample Grocery Store app built using the Room, MVVM, Live Data, Rx Java, Dependency Injection (Kotlin Injection) and support Dark Mode

Apps Intro A sample Grocery Store app built using the Room, MVVM, Live Data, Rx Java, Dependency Injection (Kotlin Injection) and support Dark Mode In

Irsyad Abdillah 25 Dec 9, 2022