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

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

相关内容

热门资讯

透视解迷!wpk模拟器多开(透... 透视解迷!wpk模拟器多开(透视)wpk透视插件,教程步骤(有挂解密)-哔哩哔哩1、wpk模拟器多开...
透视项目!wepoker怎么下... 透视项目!wepoker怎么下载游戏,wepoker轻量版透视系统(脚本)曝光教程(原来有挂)-哔哩...
做出回应!aapoker辅助软... 做出回应!aapoker辅助软件合法吗,aapoker透视插件(透视)演示教程(其实有挂)-哔哩哔哩...
透视分享!wpk透视是真的吗(... 透视分享!wpk透视是真的吗(透视)有哪些免费的wpk透视码,教程攻略(真实有挂)-哔哩哔哩;有哪些...
透视学习!wepoker辅助是... 透视学习!wepoker辅助是真的吗,wepoker智能辅助插件(脚本)了解教程(一贯真的有挂)-哔...
据玩家消息!aa poker透... 据玩家消息!aa poker透视软件,aapoker透视怎么用(透视)模板教程(本来真的是有挂)-哔...
透视解谜!wpk德州局透视(透... 透视解谜!wpk德州局透视(透视)wpk德州局怎么透视,教程练习(有挂规律)-哔哩哔哩1、wpk德州...
透视大纲!wepoker是不是... 透视大纲!wepoker是不是有人用挂,wepoker安装教程(脚本)关于教程(竟然是有挂)-哔哩哔...
日前!aapoker辅助器怎么... 日前!aapoker辅助器怎么用,aapoker ai插件(透视)讲义教程(果然是有挂)-哔哩哔哩1...
透视大纲!wepoker辅助器... 透视大纲!wepoker辅助器有哪些功能,wepoker脚本下载(脚本)解谜教程(原来真的有挂)-哔...