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

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

相关内容

热门资讯

透视插件!德普之星app安卓版... 透视插件!德普之星app安卓版破解版(透视)外挂透明挂辅助脚本(一向是真的有挂);玩家必备必赢加哟《...
透视安卓版!wpk模拟器多开,... 透视安卓版!wpk模拟器多开,越悦游戏字牌攻略,实用技巧(有挂攻略);1、下载好越悦游戏字牌攻略辅助...
透视好牌!红龙poker有辅助... 透视好牌!红龙poker有辅助吗(透视)可靠教程(切实是真的有挂)该软件可以轻松地帮助玩家将红龙po...
透视软件!aapoker透视脚... 透视软件!aapoker透视脚本下载(透视)外挂透明挂辅助脚本(原来是真的有挂);支持2-10人实时...
透视安装!wepoker数据分... 透视安装!wepoker数据分析,新西部解析辅助,必赢教程(有挂工具)1、下载好新西部解析辅助辅助软...
透视真的!hhpoker透视脚... 透视真的!hhpoker透视脚本安卓(透视)微扑克教程(总是是有挂)hhpoker透视脚本安卓软件透...
透视ai代打!wepoker透... 1、透视ai代打!wepoker透视脚本免费下载(透视)外挂透明挂辅助插件(往昔是真的有挂);详细教...
透视总结!hhpoker软件安... 透视总结!hhpoker软件安装包,四川血战到底攻略,玩家教你(有挂攻略)1、超多福利:超高返利,海...
透视攻略!德普之星辅助器(透视... 透视攻略!德普之星辅助器(透视)技巧教程(确实真的是有挂);亲,关键说明,德普之星辅助器赛季回归,德...
透视透视挂!aapoker俱乐... 透视透视挂!aapoker俱乐部靠谱吗(透视)外挂透明挂辅助神器(竟然是真的有挂)是一款可以让一直输...