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

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

相关内容

热门资讯

三分钟了解!小程序同城字牌辅助... 三分钟了解!小程序同城字牌辅助脚本(辅助)神皇开挂辅助辅助器-确实是有脚本1、三分钟了解!小程序同城...
透视方式!pokerworld... 透视方式!pokerworld辅助器(透视)aa poker辅助(辅助)总是真的是有教程(哔哩哔哩)...
第1分钟了解!微信蜀山四川修改... 第1分钟了解!微信蜀山四川修改器先测试(辅助)旗圣麻将开挂辅助脚本-都是真的有app1、玩家可以在微...
透视模板!约局吧开挂(透视)哈... 透视模板!约局吧开挂(透视)哈糖大菠萝怎么挂(辅助)竟然真的有神器(哔哩哔哩)1、哈糖大菠萝怎么挂公...
第八分钟了解!山西打锅子技巧(... 第八分钟了解!山西打锅子技巧(辅助)快来飞行棋开挂辅助平台-一贯是真的安装1、很好的工具软件,可以解...
透视诀窍!poker worl... 透视诀窍!poker world辅助器(透视)cloudpoker作必弊(辅助)其实存在有方法(哔哩...
第四分钟了解!欢乐情怀怎么开挂... 第四分钟了解!欢乐情怀怎么开挂(辅助)乐友互娱开挂辅助平台-本来真的有插件1、每一步都需要思考,不同...
透视举措!pokemmo脚本最... 透视举措!pokemmo脚本最新版(透视)拱趴大菠萝辅助神器(辅助)真是一直总是有神器(哔哩哔哩)1...
9分钟了解!南通长牌辅助器(辅... 9分钟了解!南通长牌辅助器(辅助)友谊山西互动开挂辅助脚本-一直是真的app1、用户打开应用后不用登...
透视步骤!约局吧怎么看有没有挂... 透视步骤!约局吧怎么看有没有挂(透视)哈糖大菠萝助手(辅助)切实存在有攻略(哔哩哔哩)约局吧怎么看有...