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

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

相关内容

热门资讯

详情透视!拱趴大菠萝挂怎么安装... 详情透视!拱趴大菠萝挂怎么安装,fishpoker透视底牌(透视)真是存在有辅助软件(哔哩哔哩)1、...
有了最新消息!wepoker究... 有了最新消息!wepoker究竟有没有透视,潮友潮汕木虱辅助,竟然存在有辅助脚本(哔哩哔哩)1、完成...
透视课程!拱趴大菠萝挂(透视)... 透视课程!拱趴大菠萝挂(透视)真是有辅助神器(哔哩哔哩)1、拱趴大菠萝挂模拟器是什么优化,拱趴大菠萝...
教你透视!红龙poker辅助平... 教你透视!红龙poker辅助平台,约局吧游戏挂(透视)其实存在有辅助神器(哔哩哔哩)1)红龙poke...
据权威媒体报道!wepoker... 据权威媒体报道!wepoker怎么提高运气,打两圈泰兴辅助,果然是真的有辅助脚本(哔哩哔哩)打两圈泰...
透视绝活!wepoker插件下... 透视绝活!wepoker插件下载(透视)原来真的有辅助辅助器(哔哩哔哩)wepoker插件下载是不是...
有挂透视!pokemmo脚本最... 有挂透视!pokemmo脚本最新版,poker红龙辅助(透视)果然一直总是有辅助脚本(哔哩哔哩)1、...
透视阶段!wepoker透视破... 透视阶段!wepoker透视破解版(透视)总是是真的辅助修改器(哔哩哔哩)1、该软件可以轻松地帮助玩...
据相关数据显示!德扑HHpok... 据相关数据显示!德扑HHpoker有挂吗,微乐山西小程序破解器,切实是真的有辅助攻略(哔哩哔哩)一、...
总结透视!菠萝德普辅助器免费版... 总结透视!菠萝德普辅助器免费版在哪里,智星德州插件2024最新版(透视)确实有辅助软件(哔哩哔哩)1...