vipul-sharma20 / document-scanner Goto Github PK
View Code? Open in Web Editor NEWAn OpenCV based document scanner
An OpenCV based document scanner
I just tried to debug the scanner.py file and it tells me in line 8, cv2 has no 'imread' member:
Has anyone had the same problem yet? Am I missing a module or package that needs to be installed?
I already installed opencv-python succesfully...
Thanks
Currently, when the code performs the perspective rectification/correction, the code maps the original image to an [800 x 800] image (800 is hardcoded).
As a result, the resulting image looks "squashed" in the x direction.
To improve the output, one could map the image to an image size whose aspect ratio matches the paper size aspect ratio.
For instance, let's assume that the form will come in the A4 paper size:
http://www.papersizes.org/a-paper-sizes.htm
The A4 ratio of height-to-width is 11.7 / 8.3 ~= 1.41.
So, to maintain an A4 aspect ratio when doing the perspective correction, you can map the original image to an image of size [800 x 1128](800 * 1.41 = 1128).
Since your test image is landscape, the dimensions should be:
Height: 800 pixels
Width: 1128 pixels
It'd be neat to also autodetect paper orientation, ie portrait vs landscape.
Hello,
I get the following error with valid arguments and (to the best of my knowledge) satisfied dependencies. Any ideas?
Traceback (most recent call last):
File "/path/to/scanner.py", line 28, in
(contours, _) = cv2.findContours(edged, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
ValueError: too many values to unpack
Thank you!
zelon88
I noticed someone in the HN thread posted about how a blog post from 2014 had the same code as found in this repository.
We should give that pyimagesearch blog post credit in the README
In your blog post:
http://vipulsharma20.blogspot.in/2016/01/document-scanner-using-python-opencv.html
You write that:
"The original image is resized and scaled down as OpenCV's methods may not perform accurately for very large dimensions. (Above image is the scaled down/resized version)"
I think you should consider rewording this sentence. Instead of "accuracy", do you mean performance/efficiency?
For instance, doing contour detection on a 18000 x 18000 image is likely to be extremely slow. Instead, one can downscale the image to a more manageable size -- say, 1800 x 1800 -- and still get comparable results.
Your original phrasing seems to suggest that certain operations will have bad results on very large images, but will somehow get better simply by downsizing the image. This seems odd -- and wrong -- to me.
Otherwise, I liked the writeup!
[Sorry, this issue doesn't deal with your code at all, but I thought I'd put it here to keep things localized. Thanks!]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.