百度飞桨 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)有没有挂:进一步探索有辅...
分享个大家!微乐小程序辅助工具... 分享个大家!微乐小程序辅助工具!微乐陕西麻将破解(果然真的是有辅助脚本)1)辅助插件:进一步探索辅助...
分享一款!微乐小程序自建房辅助... 分享一款!微乐小程序自建房辅助!微乐富足和靠谱吗(果然真的是有辅助技巧)暗藏猫腻,小编详细说明破解器...
实测揭晓!微乐小程序自建房辅助... 实测揭晓!微乐小程序自建房辅助!微信小程序微乐辅助器ios(本来有辅助app)透视方法中分为三种模型...
科普攻略!微乐小程序辅助工具!... 科普攻略!微乐小程序辅助工具!微信微乐辅助器使用教程(总是真的是有辅助插件)亲,关键说明,透视脚本安...
免费测试版!微乐小程序自建房辅... 免费测试版!微乐小程序自建房辅助!微乐麻将自建房app(都是真的是有辅助软件)1、很好的工具软件,可...
每日必看教程!微乐小程序自建房... 每日必看教程!微乐小程序自建房辅助!微乐春天小程序辅助(一直真的有辅助器)1、很好的工具软件,可以解...
科技通报!微乐小程序自建房辅助... 科技通报!微乐小程序自建房辅助!微乐家乡app辅助器(其实有辅助插件)1、打开软件启动之后找到中间准...
必备教程!微乐小程序自建房辅助... 必备教程!微乐小程序自建房辅助!微信小程序四川微乐脚本(总是有辅助工具)1、金币登录送、破产送、升级...
信息共享!微乐小程序辅助工具!... 信息共享!微乐小程序辅助工具!微信小程序游戏辅助器(果然是有辅助脚本)1、下载好透视辅助下载之后点击...