scan.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:card-scanner 作者: RFVenter 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号