flask-document-scanner
flask-document-scanner copied to clipboard
UnboundLocalError: local variable 'screenCnt' referenced before assignment
[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)
Happens when a rectangle cant be form from the image. Maybe the edges aren't clear or are folded