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

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

相关内容

热门资讯

有玩家发现!拱趴大菠萝开挂方法... 有玩家发现!拱趴大菠萝开挂方法,wejoker开挂(透视)阶段教程(果然真的有挂)1、许多玩家不知道...
透视有挂!pokemomo辅助... 透视有挂!pokemomo辅助软件(透视)wejoker透视方法,教程步骤(有挂头条)-哔哩哔哩1、...
日前!hhpoker万能辅助器... 日前!hhpoker万能辅助器,德普之星app安卓版破解版(透视)妙招教程(原来是有挂)1、德普之星...
透视分享!wepoker辅助插... 透视分享!wepoker辅助插件功能(透视)hhpkoer辅助器,教程操作(真的有挂)-哔哩哔哩1、...
迎来新发展!wejoker辅助... 迎来新发展!wejoker辅助软件价格,pokemmo辅助脚本(透视)秘籍教程(都是是有挂)1、进入...
透视关于!werplan脚本(... 透视关于!werplan脚本(透视)wpk软件是正规的吗,教程手段(有挂辅助)-哔哩哔哩透视关于!w...
随着!哈糖大菠萝免费辅助器,p... 随着!哈糖大菠萝免费辅助器,pokemmo手机版脚本(透视)机巧教程(其实是有挂)哈糖大菠萝免费辅助...
透视教你!wepoker免费辅... 透视教你!wepoker免费辅助器(透视)来玩app破解版,教程总结(讲解有挂)-哔哩哔哩1、游戏颠...
在玩家背景下!德普之星私人局透... 在玩家背景下!德普之星私人局透视,werplan辅助软件(透视)指南教程(真是存在有挂)1、很好的工...
透视辅助!wepoker轻量版... 透视辅助!wepoker轻量版辅助(透视)德州圈脚本,教程演示(有挂分享)-哔哩哔哩1、许多玩家不知...