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

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

相关内容

热门资讯

揭幕透视!werplan脚本,... 揭幕透视!werplan脚本,newpoker脚本(透视)切实是有辅助软件(哔哩哔哩)1、游戏颠覆性...
透视项目!佛手大菠萝有挂吗(透... 透视项目!佛手大菠萝有挂吗(透视)一贯有辅助安装(哔哩哔哩)1、下载好佛手大菠萝有挂吗脚本下载之后点...
分享透视!德州之星扫描器,德州... 分享透视!德州之星扫描器,德州局透视脚本下载安装最新版本(透视)一贯存在有辅助插件(哔哩哔哩)1、上...
透视资料!pokemmo脚本辅... 透视资料!pokemmo脚本辅助器下载(透视)好像有辅助神器(哔哩哔哩)1、pokemmo脚本辅助器...
解谜透视!epoker透视底牌... 解谜透视!epoker透视底牌,uupoker透视(透视)切实是有辅助插件(哔哩哔哩)1、每一步都需...
透视方案!wepoker可以开... 透视方案!wepoker可以开透视吗(透视)本来是有辅助插件(哔哩哔哩)1、起透看视 wepoker...
曝光透视!拱趴大菠萝有挂吗,h... 曝光透视!拱趴大菠萝有挂吗,hardrock透视工具(透视)切实真的有辅助工具(哔哩哔哩)1、许多玩...
透视演示!德普之星辅助器怎么用... 透视演示!德普之星辅助器怎么用(透视)一直是真的辅助神器(哔哩哔哩)德普之星辅助器怎么用破解侠是真的...
详情透视!德州透视脚本,佛手在... 详情透视!德州透视脚本,佛手在线是不是有挂(透视)果然一直总是有辅助神器(哔哩哔哩)1、佛手在线是不...
透视举措!wepoker有透视... 透视举措!wepoker有透视吗(透视)确实是真的辅助工具(哔哩哔哩)1、操作简单,无需wepoke...