百度飞桨 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)  

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

相关内容

热门资讯

出现新变化!青龙大厅挂什么价格... 出现新变化!青龙大厅挂什么价格,越乡游嵊州辅助器,步骤教程(有挂头条)-哔哩哔哩1、青龙大厅挂什么价...
出乎意料的是!德州来玩辅助器,... 出乎意料的是!德州来玩辅助器,中至上饶打炸漏洞,演示教程(揭秘有挂)-哔哩哔哩1、中至上饶打炸漏洞辅...
专业透视!wepoker透视脚... 专业透视!wepoker透视脚本视频,微乐小程序免费黑科技5个玩家常用方法,方针教程(有挂技巧)-哔...
据报道!新众亿挂机,微乐自建房... 据报道!新众亿挂机,微乐自建房辅助,法子教程(真是有挂)-哔哩哔哩1、下载好微乐自建房辅助透视辅助下...
透视讲解!大菠萝免费辅助,so... 透视讲解!大菠萝免费辅助,sohoopoker辅助,大纲教程(有挂方略)-哔哩哔哩1、让任何用户在无...
曝光透视!wepoker轻量版... 您好,wepoker轻量版有透视吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【1367043...
现就发布提示!潮汕来物局透视平... 现就发布提示!潮汕来物局透视平台使用方法,心悦辅助器,办法教程(有挂细节)-哔哩哔哩一、潮汕来物局透...
近日!德州真人透视脚本,指尖四... 近日!德州真人透视脚本,指尖四川辅助脚本,诀窍教程(有挂分享)-哔哩哔哩亲,关键说明,德州真人透视脚...
开挂透视!pokerworld... 开挂透视!pokerworld软件,微乐江西小程序辅助器免费,手册教程(有挂攻略)-哔哩哔哩1、po...
长期以来!博雅红河西元红河破解... 长期以来!博雅红河西元红河破解版,牵手跑得软件,策略教程(有挂技巧)-哔哩哔哩1、该软件可以轻松地帮...