Simple Document Scanner

A simple Android app which allows for scanning of documents similar to apps like GeniusScan.

Screenshots

Screenshot Screenshot Screenshot Screenshot

Details

I needed this type of functionality inside of an app I was building recently and I was unable to find exactly what I was looking for anywhere online, so I put something together myself.

I should note that this is not a library. This is just an example meant to demonstrate how to implement a feature like this in your own app.

OpenCV

This app relies on OpenCV for image processing, but integrating it was not a simple task. For this project, I followed these steps. This works fine, but having an extra module in your app may be undesirable. If that's the case, simply build the app and add the compiled AAR into your own app as a dependency.

By default, the app will use OpenCV Manager (availiable on Google Play) in order to link to the OpenCV binary. This is the recommended way to use OpenCV on Android by the OpenCV developers, but I find this a clunky approach and prefer to statically link OpenCV at build time. To do this you will need to follow the following steps:

  1. Download the OpenCV SDK
  2. Unzip and then copy all folders from OpenCV SDK Dir/sdk/native/libs to this project/opencv/src/main/jniLibs (You may need to create the jniLibs folder).
  3. Rebuild

At this point, OpenCV Manager shouldn't be necessary anymore.

TODO

I leave these as an exercise for the reader.

  • Camera support
  • Save the resulting bitmap

Resources

  1. Integrating OpenCV with Android Studio
  2. OpenCV Manager
  3. OpenCV as an AAR
  4. OpenCV Perspective Transform
  5. Document Scanning Algorithm
  6. If you attempt to include the generated AAR from a module your app depends on, this might be helpful