react-native-rectangle-scanner icon indicating copy to clipboard operation
react-native-rectangle-scanner copied to clipboard

Enhanced Rectangle/Document detection in android

Open humphreyja opened this issue 4 years ago • 3 comments

This is an attempt to address issue #29.

This branch is meant to experiment with a different algorithm to find the best rectangle in the image.

Things being tried:

  1. Function that filters and finds the largest/best looking rectangle. UPDATE: Not very effective
  2. Enhancing the filter before attempting to find the edges (brightening the image if it's too dark, etc). UPDATE: This is showing some promising returns
  3. Updating OpenCV.

Filtering issue: So far, I'm not really liking the solutions. We need to have some sort of check to make sure the ratio isn't too far out of line, as well as something that makes sure it is large enough.

Another thing I will be looking into is the transforms on the image before the contours are found. This may be what is causing issues where the rectangle is just not detected at all.

humphreyja avatar Mar 15 '20 23:03 humphreyja

Latest update. I experimented with changing the alpha and beta channels of the image (gain and brightness) based off of the brightness of the image. This allows for better fitting/high contrast images which makes the edges pop a lot better. In terms of finding rectangles, it looks like it made the android simulator much better at detecting, but maybe no change on my android phone (it's ancient LG G3, so it could be just a weird thing with that). I have one more trick up my sleeve, and that would be to update OpenCV. Maybe it's gotten smarter?

Here's an image (after applying high contrast filters) with a fake receipt that OpenCV is having difficulty finding the receipt/rectangle in. Again, this is on a really old phone, so that could be the issue too.

Cfd41bcc7-808c-49f1-8ff4-fb94dacb9584

humphreyja avatar Mar 23 '20 00:03 humphreyja

Any news on this ?

ScreamZ avatar Sep 26 '20 11:09 ScreamZ

@humphreyja as you mentioned in the thread regarding upgrading openCV, could you give us a hint about how to upgrade openCV for this project?

vsyw avatar Jul 16 '21 15:07 vsyw