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

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

相关内容

热门资讯

必看攻略!wepoker怎么开... 必看攻略!wepoker怎么开辅助,wepoker有辅助功能吗,技巧教程(确实有挂)能透视中分为三种...
近日!红龙poker辅助工具,... 近日!红龙poker辅助工具,wpk透视辅助,竟然确实有挂(真的有挂)1、近日!红龙poker辅助工...
推荐一下!边锋干瞪眼辅助器,小... 推荐一下!边锋干瞪眼辅助器,小唐家乐园辅助,其实真的是有挂(哔哩哔哩)1、在边锋干瞪眼辅助器插件功能...
揭秘关于!wpk真的有透视嘛,... 揭秘关于!wpk真的有透视嘛,hhpoker有没有辅助,攻略教程(今日头条)1、完成辅助器v3.3的...
现有说明如下!约局吧德州可以透... 现有说明如下!约局吧德州可以透视吗,如何下载wpk透视版,果然存在有挂(有挂技术)暗藏猫腻,小编详细...
解迷一下!科乐天天踢有没有作比... 解迷一下!科乐天天踢有没有作比,家乡大二辅助免费,切实真的是有挂(哔哩哔哩)1、首先打开科乐天天踢有...
实测教程!hhpoker视频巡... 实测教程!hhpoker视频巡查真的假的,hhpoker德州有挂吗,技巧教程(有挂工具)1、免费辅助...
此事引发网友热议!wepoke... 此事引发网友热议!wepoker透视苹果系统,哈糖大菠萝助手,原来真的有挂(有挂神器)1、下载好we...
必备一下!jj斗地主麻将外卦挂... 必备一下!jj斗地主麻将外卦挂,九游破解辅助插件,其实是真的有挂(哔哩哔哩)1、游戏颠覆性的策略玩法...
必看攻略!hh poker插件... 必看攻略!hh poker插件下载,hhpoker辅助挂,插件教程(有挂总结)1、用户打开应用后不用...