百度飞桨 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底牌透视脚本,德普之星辅助器怎么用,步骤教程(有挂细节)-哔哩哔哩德普之星辅...
十分钟推荐!hhpoker哪个... 十分钟推荐!hhpoker哪个俱乐部靠谱(透视)好像是真的挂,黑科技教程(竟然有挂)-哔哩哔哩1、操...
透视黑科技!wepoker怎么... 透视黑科技!wepoker怎么挂底牌(透视)果然是有挂,揭秘教程(有挂网页版)-哔哩哔哩1、这是跨平...
透视app!pokemomo辅... 透视app!pokemomo辅助工具,htx矩阵wepoker辅助,秘籍教程(有挂猫腻)-哔哩哔哩h...
九分钟外挂!hhpoker怎么... 九分钟外挂!hhpoker怎么防辅助(透视)真是存在有挂,详细教程(竟然有挂)-哔哩哔哩1、首先打开...
透视辅助!红龙poker有辅助... 透视辅助!红龙poker有辅助吗(透视)总是真的是有挂,解说技巧(有挂苹果版)-哔哩哔哩1、下载好红...
透视挂透视!werplan辅助... 透视挂透视!werplan辅助软件,wepoker辅助工具,法门教程(有挂教程)-哔哩哔哩亲,关键说...
8分钟外挂!aapoker公共... 8分钟外挂!aapoker公共底牌(透视)一贯有挂,安装教程(有挂助手)-哔哩哔哩1、用户打开应用后...
透视代打!pokemmo辅助官... 透视代打!pokemmo辅助官网(透视)切实是有挂,解密教程(有挂机器人)-哔哩哔哩1、完成poke...
透视教程!pokemmo辅助官... 透视教程!pokemmo辅助官网,wpk软件是真的吗,教程书教程(有挂存在)-哔哩哔哩1、wpk软件...