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

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

相关内容

热门资讯

透视了解!wpk模拟器是什么(... 透视了解!wpk模拟器是什么(透视)wpk德州局透视,教程法子(有挂详情)-哔哩哔哩1、不需要AI权...
透视存在!德普之星辅助工具如何... 透视存在!德普之星辅助工具如何打开,德普之星辅助器怎么用(透视)其实真的有挂(有挂细节)-哔哩哔哩1...
透视讲义!wepokerplu... 透视讲义!wepokerplus到底是挂了吗,wepoker怎么挂飞机(脚本)分享教程(一直是有挂)...
经调查!aapoker辅助软件... 经调查!aapoker辅助软件合法吗,aapoker公共底牌(透视)诀窍教程(总是是真的挂)-哔哩哔...
透视教你!购买的wpk辅助在哪... 透视教你!购买的wpk辅助在哪里下载(透视)微扑克微乐辅助,教程阶段(有挂教程)-哔哩哔哩1、购买的...
透视脚本!德普之星透视辅助软件... 透视脚本!德普之星透视辅助软件下载,德扑圈透视挂(透视)竟然是真的挂(有挂教学)-哔哩哔哩1、每一步...
透视策略!wepoker怎么设... 透视策略!wepoker怎么设置房间,wepoker数据分析工具(脚本)必备教程(切实是真的挂)-哔...
随着!aapoker透视脚本下... 随着!aapoker透视脚本下载,aapoker怎么设置提高好牌几率(透视)学习教程(原来有挂)-哔...
透视揭幕!wpk透视是真的假的... 透视揭幕!wpk透视是真的假的(透视)wpk透视插件,教程技法(有挂分析)-哔哩哔哩在进入wpk透视...
透视软件!德扑之心免费透视,德... 透视软件!德扑之心免费透视,德普之星透视免费(透视)切实是有挂(有挂教程)-哔哩哔哩1、进入游戏-大...