flask-document-scanner icon indicating copy to clipboard operation
flask-document-scanner copied to clipboard

UnboundLocalError: local variable 'screenCnt' referenced before assignment

Open zenners opened this issue 7 years ago • 1 comments

[2017-10-02 16:53:56,762] ERROR in app: Exception on / [POST] warped = four_point_transform(orig, screenCnt.reshape(4, 2) * ratio) UnboundLocalError: local variable 'screenCnt' referenced before assignment

for c in cnts:
    	# approximate the contour
    	peri = cv2.arcLength(c, True)
    	approx = cv2.approxPolyDP(c, 0.02 * peri, True)

    	# if our approximated contour has four points, then we
    	# can assume that we have found our screen
    	if len(approx) == 4:
    		screenCnt = approx
    		break

    print ("STEP 2: Find contours of paper")
    warped = four_point_transform(orig, screenCnt.reshape(4, 2) * ratio)

zenners avatar Oct 02 '17 08:10 zenners

Happens when a rectangle cant be form from the image. Maybe the edges aren't clear or are folded

zenners avatar Oct 02 '17 09:10 zenners