首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发行环比特斯拉和Opencv?

发行环比特斯拉和Opencv?
EN

Stack Overflow用户
提问于 2019-03-20 08:10:28
回答 1查看 123关注 0票数 0

我正在尝试做一个循环tessract和opencv来识别一个操作。但是当运行一些时候,opencv仍然会给出正常的图像,而tessract不会正常运行(输出不正确)。这个问题在我使用多图像运行时真的发生了。

在这里输入图像描述

EN

回答 1

Stack Overflow用户

发布于 2019-03-22 04:26:35

代码语言:javascript
复制
with mss.mss() as sct:
        # Grab the data
        sct_img = sct.grab(monitor)

        # Save to the picture file
        mss.tools.to_png(sct_img.rgb, sct_img.size, output=path)

    # load the image 
    ap = argparse.ArgumentParser(description='bot')
    ap.add_argument("-i", "--image", required=False,default=path,help="path to input image to be OCR'd")
    ap.add_argument("-p", "--preprocess", type=str, default="thresh", help="type of preprocessing to be done")
    args = vars(ap.parse_args())

    # load the image 
    image = cv2.imread(args["image"])
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    if args["preprocess"] == "thresh":
        gray = cv2.threshold(gray, 0, 255,
            cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]

# make a check to see if median blurring should be done to remove
# noise
    elif args["preprocess"] == "blur":
        gray = cv2.medianBlur(gray, 3)

# write the grayscale image to disk as a temporary file so we can
# apply OCR to it
    filename = ("Scripts/Screens/" +str(i) +".png").format(os.getpid())
    cv2.imwrite(filename, gray)
    cv2.waitKey(1)
    text = pytesseract.image_to_string(Image.open(filename),config='--psm 7', lang ="eng+equ")

我对此感到很抱歉

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55256136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档