react-native-rectangle-scanner
react-native-rectangle-scanner copied to clipboard
Enhanced Rectangle/Document detection in android
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:
- Function that filters and finds the largest/best looking rectangle. UPDATE: Not very effective
- 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
- 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.
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.
Any news on this ?
@humphreyja as you mentioned in the thread regarding upgrading openCV, could you give us a hint about how to upgrade openCV for this project?