def cropped_image(image, contours, bw=True, show=False):
ratio = image.shape[0] / float(scale_factor)
warped = four_point_transform(image, contours.reshape(4, 2) * ratio)
if bw:
# convert the warped image to grayscale, then threshold it to give it that 'black and white' paper effect
warped = cv2.cvtColor(warped, cv2.COLOR_BGR2GRAY)
warped = threshold_adaptive(warped, 251, offset = 10)
warped = warped.astype("uint8") * 255
if show: #this is for debugging puposes
cv2.imshow("Payload", warped)
cv2.waitKey(0)
cv2.destroyAllWindows()
return warped
评论列表
文章目录