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

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

相关内容

热门资讯

发现一款!wepoker透视脚... 《发现一款!wepoker透视脚本网页(透视)原本有开挂辅助挂》 wepoker透视脚本网页软件透明...
每日必看推荐!欢聚水鱼智能辅助... 每日必看推荐!欢聚水鱼智能辅助教程(透视)wpk私人辅助(解迷开挂辅助插件)相信很多朋友都在电脑上玩...
实操分享!aapoker辅助软... 实操分享!aapoker辅助软件合法吗(透视)往昔有开挂辅助安装;aapoker辅助软件合法吗软件透...
一分钟秒懂!epoker底牌透... 您好,德州之星扫描器这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这...
一分钟了解!hhpoker透视... 一分钟了解!hhpoker透视脚本下载(透视)起初有开挂辅助插件;相信小伙伴都知道这个hhpoker...
发现玩家!财神13辅助器下载(... 发现玩家!财神13辅助器下载(透视)hhpoker脚本下载(揭露开挂辅助下载);财神13辅助器下载最...
如何分辨真伪!pokemomo... 如何分辨真伪!pokemomo辅助软件(透视)从来有开挂辅助神器是一款可以让一直输的玩家,快速成为一...
我来教大家!边锋斗地主插件辅助... 我来教大家!边锋斗地主插件辅助脚本(透视)德州透视hhpoker(解谜开挂辅助插件)相信很多朋友都在...
必备攻略!购买的wpk辅助在哪... 必备攻略!购买的wpk辅助在哪里下载(透视)往昔有开挂辅助黑科技;1、不需要AI权限,帮助你快速的进...
来一盘!微信小程序辅助器免费下... 您好:微信小程序辅助器免费下载这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多...