百度飞桨 OCR识别
创始人
2024-11-11 05:10:40
0

百度飞桨 OCR识别代码

import warnings import time import cv2 as cv import paddlehub as hub # Load the image img = cv.imread("1.jpg") height, width, channels = img.shape imglist = [img] ocr = hub.Module(name="ch_pp-ocrv3", enable_mkldnn=True)  # mkldnn acceleration is only effective on CPU start_time = time.time() result = ocr.recognize_text(images=imglist) end_time = time.time() elapsed_time = end_time - start_time print(f"执行时间: {elapsed_time} seconds") for data in result[0]['data']:     text = data['text']     confidence = data['confidence']     if confidence > 0.85:         points = data['text_box_position']         left = min(point[0] for point in points)         top = min(point[1] for point in points)         right = max(point[0] for point in points)         bottom = max(point[1] for point in points)         print(f"Text: {text}, Box: ({left}, {top}), ({right}, {bottom})")         cv.rectangle(img, (left, top), (right, bottom), (0,0, 255), 2)         cv.putText(img, text, (left, top - 10), cv.FONT_HERSHEY_SIMPLEX, 2, (0, 0, 255), 2) resize_img = cv.resize(img, [width // 4, height // 4]) cv.imwrite("result.jpg", resize_img) cv.imshow("Result",resize_img) cv.waitKey(0) cv.destroyAllWindows() print(result)  

显示效果图
在这里插入图片描述

相关内容

热门资讯

透视攻略!epoker透视(透... 透视攻略!epoker透视(透视)辅助app(有挂细节)-哔哩哔哩一、epoker透视游戏安装教程牌...
出现新变化!中至赣州小程序怎么... 出现新变化!中至赣州小程序怎么开挂!原来真的有辅助挂(有挂实锤)-哔哩哔哩1、下载好中至赣州小程序怎...
透视系统!wepoker代打辅... 透视系统!wepoker代打辅助机器人(透视)辅助神器(果真有挂)-哔哩哔哩1、金币登录送、破产送、...
近日!微乐江苏小程序游戏破解下... 近日!微乐江苏小程序游戏破解下载!切实有挂辅助神器(有挂存在)-哔哩哔哩1、上手简单,内置详细流程视...
近日!wepoker可以透视码... 近日!wepoker可以透视码(透视)辅助app(有挂详情)-哔哩哔哩1、首先打开wepoker可以...
推出新举措!新天道辅助软件怎么... 推出新举措!新天道辅助软件怎么样!确实是有辅助器(竟然有挂)-哔哩哔哩1、新天道辅助软件怎么样模拟器...
透视科技!pokemmo手机版... 透视科技!pokemmo手机版透视脚本(透视)辅助下载(有挂秘籍)-哔哩哔哩1、pokemmo手机版...
相较于以往!hhpoker辅助... 相较于以往!hhpoker辅助器下载!切实真的是有辅助下载(有挂猫腻)-哔哩哔哩hhpoker辅助器...
针对!拱趴大菠萝万能辅助器(透... 针对!拱趴大菠萝万能辅助器(透视)辅助安装(果真有挂)-哔哩哔哩1、拱趴大菠萝万能辅助器免费脚本咨询...
这一问题亟待解决!鸿狐辅助器!... 这一问题亟待解决!鸿狐辅助器!总是是真的辅助神器(有挂秘籍)-哔哩哔哩1、鸿狐辅助器公共底牌简单,鸿...