Ask Your Question

Revision history [back]

How scan document without edges?

Hello. I would like to make a document scanner but unfortunately, in my images don't have edge of paper.

I tried find edges, but it inst enough.

Someone have any idea how it's possible?

image = cv2.imread('2.jpg')
image = cv2.resize(image, (1500, 880))
orig = image.copy()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (30,30))
closed = cv2.morphologyEx(blurred, cv2.MORPH_CLOSE, kernel)
edged = cv2.Canny(closed, 0, 100)
orig_edged = edged.copy()

(_,contours, _) = cv2.findContours(edged, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
contours = sorted(contours, key=cv2.contourArea, reverse=True)

...

this image description