Document scanner using OpenCV (3.2.0) and Python (2.7.12).
A very thanks to author of article http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/ for great explanations to learn from.
Image is -
1.Converted to greayscale -
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
2.Blurred to smooth -
blurr = cv2.GaussianBlur(grey, (5,5),0)
3.Now we find edges in blurred image-
edge = cv2.Canny(blurr, 0, 50)
4.Next is to find contours-
_, contours, _ = cv2.findContours(edge, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
5.After contour approximation -
6.Image after prespective transform (This particular part is very well explained in article at pyimagesearch)-
`