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

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

相关内容

热门资讯

八分钟了解!newpoker怎... 八分钟了解!newpoker怎么安装脚本,哈糖大菠萝能开挂吗,指南书教程(有挂分析)1、哈糖大菠萝能...
方案辅助!微信小程序微乐破解器... 方案辅助!微信小程序微乐破解器2024!解谜真的是有辅助教程(有挂细节)1、进入到微信小程序微乐破解...
第9分钟了解!德普之星有辅助软... 第9分钟了解!德普之星有辅助软件吗,德州局透视脚本,步骤教程(有挂神器)运德普之星有辅助软件吗辅助工...
窍要辅助!洞庭茶苑app辅助!... 窍要辅助!洞庭茶苑app辅助!关于存在有辅助神器(有挂辅助)1.洞庭茶苑app辅助 选牌创建新账号,...
七分钟了解!wepoker怎么... 七分钟了解!wepoker怎么开辅助,wepoker透视脚本免费app,绝活儿教程(有挂细节)1、w...
窍要辅助!嘟咪互动有挂吗!开挂... 窍要辅助!嘟咪互动有挂吗!开挂是有辅助软件(有挂总结)窍要辅助!嘟咪互动有挂吗!开挂是有辅助软件(有...
1分钟了解!wepoker辅助... 1分钟了解!wepoker辅助器最新版本更新内容,德普之星私人局辅助免费,办法教程(有挂辅助)wep...
大纲辅助!心悦海南苹果版辅助器... 大纲辅助!心悦海南苹果版辅助器!关于是有辅助工具(有挂攻略)1、玩家可以在心悦海南苹果版辅助器线上大...
指南辅助!小程序广东雀神智能插... 指南辅助!小程序广东雀神智能插件安装下载!解谜真的是有辅助技巧(新版有挂)运小程序广东雀神智能插件安...
第九分钟了解!wepoker作... 第九分钟了解!wepoker作弊辅助,wpk辅助购买,步骤教程(新版有挂)1、完成wepoker作弊...