main.py 文件源码

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

项目:Nightchord 作者: theriley106 项目源码 文件源码
def Spaces(image=None):
    PrintGood('This returns the number of spaces in a specific image or images')
    if isinstance(image, list) == False:
        image = PromptList('Which image/images to Scan: ', image)
    for image in image:
        image = Image.open(image)
        with PyTessBaseAPI() as api:
            api.SetImage(image)
            boxes = api.GetComponentImages(RIL.TEXTLINE, True)
            Spaces = 0
            for i, (im, box, _, _) in enumerate(boxes):
                im.save('saving{}.jpg'.format(i))
                api.SetRectangle(box['x'], box['y'], box['w'], box['h'])
                ocrResult = api.GetUTF8Text()
                conf = api.MeanTextConf()
                text = str(ocrResult).replace('\n', '').split(' ')
                Spaces = len(text) + Spaces
    return int(Spaces)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号