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

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

相关内容

热门资讯

透视总结!pokermaste... 透视总结!pokermaster修改器,wepoker脚本,手段教程(其实存在有挂)-哔哩哔哩1)p...
透视透视!拱趴大菠萝万能挂(透... 透视透视!拱趴大菠萝万能挂(透视)开挂辅助挂(原来真的有挂)-哔哩哔哩1)拱趴大菠萝万能挂辅助挂:进...
经调查!人皇大厅控制牌型,约战... 经调查!人皇大厅控制牌型,约战丹东辅助,黑科技教程(本来真的有挂)-哔哩哔哩1、下载好人皇大厅控制牌...
据统计!佛手在线大菠萝智能辅助... 据统计!佛手在线大菠萝智能辅助器,中至余干六副里,确实是真的挂(揭露黑科技教程)-哔哩哔哩佛手在线大...
透视透视挂!德普之星辅助器,w... 透视透视挂!德普之星辅助器,wpk插件,方案教程(竟然有挂)-哔哩哔哩1、实时德普之星辅助器开挂更新...
透视后台!wepoker私人局... 透视后台!wepoker私人局规律(透视)开挂辅助方法(其实真的是有挂)-哔哩哔哩1、用户打开应用后...
最终!闽乐乐510k脚本,九九... 最终!闽乐乐510k脚本,九九山城万州版辅助,玩家教程(好像是有挂)-哔哩哔哩1、很好的工具软件,可...
透视ai!wepoker插件程... 透视ai!wepoker插件程序激活码,epoker有透视吗,手段教程(其实有挂)-哔哩哔哩透视ai...
透视最新!hhpoker透视方... 透视最新!hhpoker透视方法,建德十三道辅助,竟然有挂(详情新2025教程)-哔哩哔哩1、建德十...
透视自建房!wepoker透视... 透视自建房!wepoker透视最简单三个步骤(透视)开挂辅助神器(果然存在有挂)-哔哩哔哩1、进入到...