Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android page/edge detect and transform page. Convert to B/W tiff

Probably not looking for solution, but looking for guidance on this. This is to implement "document scanner" in our Android app.

I need to do precisely this:

  1. Take image with camera (no problem)
  2. Detect page edges/corners (???)
  3. Allow user to move/adjust corners (no problem)
  4. Transform image to make it rectangle (???)
  5. Convert image to B/W TIFF or some other appropriate format for transmission over mobile network (compact, bit per pixel) (???)

What I tried. We tried to use Open CV. It's huge, there is NDK. Setup and infrastructure pretty complex.

Is there anything that's lighter and designed for exactly this task? Even commercial might be fine.

Just looking for suggestions on how to approach this.. Main problem is to detect edges and transform I think..

like image 303
katit Avatar asked Aug 04 '16 15:08

katit


1 Answers

I do not know of any libraries that will handle this for you, but I have come across few open source projects that achieve a similar result. Most are based on the OpenCV library and/or the OpenCV4Android SDK. Here are a few noteworthy projects:

  • Android Scanner Demo
  • Simple Document Scanner
  • Document Scanner

Another similar library is Google's Mobile Vision API, which contains a Text Recognition API. Though this will not enable you to convert a document into a black and white image, it would enable you to convert a document into plain text.

As for converting the image for transmission over a network; Android does not natively support the TIFF file format, though there is at least one library that will handle this conversion for you. Android does natively support compressing an image as JPEG, PNG or WEBP, which you can use to send data over the network as an encoded string:

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
byte[] bytes = outputStream.toByteArray();
String encodedImage = Base64.encodeToString(bytes, Base64.DEFAULT);
like image 126
Bryan Avatar answered Oct 16 '22 06:10

Bryan