百度飞桨 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万能辅助器,wejoker辅助器怎么卖,法子教程(一直透视真的是有挂)-哔哩...
记者获悉!互游辅助脚本(辅助挂... 记者获悉!互游辅助脚本(辅助挂)原来是有挂的(盘点开挂辅助脚本)-哔哩哔哩;1、完成互游辅助脚本的残...
最终!拱趴大菠萝技巧,四川途游... 最终!拱趴大菠萝技巧,四川途游小程序辅助,举措教程(果然真的有挂的)-哔哩哔哩【无需打开直接搜索加薇...
此事迅速冲上热搜!aapoke... 此事迅速冲上热搜!aapoker真的假的,wepoker怎么开辅助,大纲教程(果然透视是有挂)-哔哩...
此事引发网友热议!科乐天天踢辅... 此事引发网友热议!科乐天天踢辅助视频(辅助挂)一直真的有挂(曝光开挂辅助平台)-哔哩哔哩;是一款可以...
目前来看!威信茶馆透视挂,三哥... 三哥玩摆头可以控制开挂教程视频分享装挂详细步骤在当今的网络游戏中,三哥玩摆头可以控制作为一种经典的娱...
随着!hhpoker德州挂真的... 您好:这款hhpoker德州挂真的有吗游戏是可以开挂的,确实是有挂的,很多玩家在这款hhpoker德...
现场直击!蛮王大厅辅助(辅助挂... 现场直击!蛮王大厅辅助(辅助挂)一直真的是有挂(详细开挂辅助神器)-哔哩哔哩;1、让任何用户在无需A...