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

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

相关内容

热门资讯

开挂透视!hhpoker到底可... 开挂透视!hhpoker到底可以作弊码,微乐贵阳捉鸡麻将挂软件,要领教程(有挂方法)-哔哩哔哩1、全...
昨日!上饶中至辅助软件怎么用,... 昨日!上饶中至辅助软件怎么用,四川麻将血战智能辅助,攻略教程(确实有挂)-哔哩哔哩该软件可以轻松地帮...
黑科技攻略!红龙poker有辅... 黑科技攻略!红龙poker有辅助吗,闲聚app辅助软件,诀窍教程(有挂总结)-哔哩哔哩1、每一步都需...
辅助透视!steampoker... 辅助透视!steampokermaster辅助,微信小程序游戏充值破解,经验教程(有挂透视)-哔哩哔...
据公告内容!微信小游戏修改器,... 据公告内容!微信小游戏修改器,福建微乐小程序修改器,大纲教程(详细教程)-哔哩哔哩1、下载好福建微乐...
透视了解!哈糖大菠萝破解器,宁... 透视了解!哈糖大菠萝破解器,宁德钓螃蟹有没有挂,攻略教程(真实有挂)-哔哩哔哩1、不需要AI权限,帮...
辅助透视!hhpoker真的有... 辅助透视!hhpoker真的有透视吗,微乐小程序游戏破解器苹果系统,窍要教程(了解有挂)-哔哩哔哩1...
据相关数据显示!同乡有辅助,凑... 据相关数据显示!同乡有辅助,凑一桌小程序辅助器,绝活儿教程(有挂实锤)-哔哩哔哩1、上手简单,内置详...
透视系统!poker红龙辅助,... 透视系统!poker红龙辅助,樱花之盛能不能开挂,指引教程(有挂方法)-哔哩哔哩1、完成樱花之盛能不...
辅助透视!pokermaste... 辅助透视!pokermaster辅助器,微信微乐游戏辅助器,妙招教程(详细教程)-哔哩哔哩1、金币登...