scan.py 文件源码

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

项目:card-scanner 作者: RFVenter 项目源码 文件源码
def crop_image(image, contours, min_aspect_ratio=0.5):
    ratio = image.shape[0] / float(scale_factor)
    warped = four_point_transform(image, contours.reshape(4, 2) * ratio)
    # test to see if the box ratio is correct
    height, width, channels = warped.shape
    if height > width:
        aspect_ratio = width / height
    else:
        aspect_ratio = height / width
    if aspect_ratio < min_aspect_ratio:
        raise ImageNotReadable()
    # test to see if the orientation is correct, if not flip it
    if height > width:
        warped = cv2.transpose(warped)
        warped = cv2.flip(warped, 0)
    return warped
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号