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

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

相关内容

热门资讯

透视攻略!hhpoker辅助挂... 透视攻略!hhpoker辅助挂,hhpkoer辅助挂是真的吗(透视)都是有脚本软件(哔哩哔哩)1、很...
透视烘培!菠萝德州透视脚本,来... 透视烘培!菠萝德州透视脚本,来玩app 德州 辅助(透视)确实存在有透视技巧(哔哩哔哩)暗藏猫腻,小...
透视学习!aapoker万能辅... 透视学习!aapoker万能辅助器,aapoker透视脚本下载(透视)好像真的有脚本插件(哔哩哔哩)...
透视操作!hhpoker一直输... 透视操作!hhpoker一直输有挂吗,hhpoker是真的吗(透视)都是是真的透视教程(哔哩哔哩)1...
透视演示!aapoker透视脚... 透视演示!aapoker透视脚本,aapoker俱乐部靠谱吗(透视)都是真的有脚本教程(哔哩哔哩)1...
透视资料!wpk真吗,微扑克微... 透视资料!wpk真吗,微扑克微乐辅助(透视)总是有脚本攻略(哔哩哔哩)亲,关键说明,微扑克微乐辅助透...
透视秘籍!哈糖大菠萝软件下载,... 透视秘籍!哈糖大菠萝软件下载,pokemmo修改器手机版(透视)确实真的是有脚本器(哔哩哔哩)1、许...
透视指引!德普之星怎么开辅助,... 透视指引!德普之星怎么开辅助,德普之星透视软件免费入口官网(透视)都是有透视app(哔哩哔哩)1、让...
透视妙招!hhpoker辅助器... 透视妙招!hhpoker辅助器视频,hhpoker透视脚本下载(透视)果然是有脚本软件(哔哩哔哩)1...
透视办法!aapoker辅助器... 透视办法!aapoker辅助器怎么用,aapoker怎么开辅助器(透视)本来有脚本工具(哔哩哔哩)所...