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

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

相关内容

热门资讯

技术分享!aapoker透明挂... 技术分享!aapoker透明挂微扑克脚本代写(透明黑科技)原来真的有挂(wpk教程);1、aapok...
分享认知!wpk有外挂线上德州... 分享认知!wpk有外挂线上德州后台可以操控吗(辅助)其实真的有挂(爆料教程)1、让任何用户在无需wp...
热门推荐!we辅助poker德... 热门推荐!we辅助poker德之星wpk微扑克真的有辅助插件吗(透视辅助)其实真的有挂(透明教程)1...
科技通报!德扑之星有猫腻微扑克... 科技通报!德扑之星有猫腻微扑克有没有挂(透视辅助)其实真的有挂(wepoke教程)1、下载好德扑之星...
实测交流!wepower辅助器... 实测交流!wepower辅助器wepoke辅助插件(辅助)原来真的有挂(解密教程)1、下载好wepo...
玩家必看秘籍!wepokeai... 玩家必看秘籍!wepokeai机器人扑克世界牌局设置(透视辅助)原来真的有挂(解密教程)1、操作简单...
玩家必看科普!wepoke a... 玩家必看科普!wepoke ai辅助aapoker安卓版辅助(辅助)原来真的有挂(攻略方法)1、we...
教程辅助!wepoke辅助德州... 教程辅助!wepoke辅助德州ai辅助代理(透视辅助)其实真的有挂(安装教程)1、德州ai辅助ai辅...
每日必看推荐!aapoker透... 每日必看推荐!aapoker透视辅助德扑之星隐藏功能(辅助挂)其实真的有挂(系统教程)1、游戏颠覆性...
玩家亲测!wepoke辅助技巧... 玩家亲测!wepoke辅助技巧wepoke辅助插件(透视辅助)其实真的有挂(新2025版);1、we...