百度飞桨 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透视器... 透视免费!wepoker透视器免费(透视)一直是有辅助辅助器(有挂猫腻)-哔哩哔哩透视免费!wepo...
解谜透视!来玩德州破解器!技术... 解谜透视!来玩德州破解器!技术分享辅助教程(有挂透明挂)-哔哩哔哩来玩德州破解器是不是有人用挂微扑克...
最新消息!pokemmo脚本手... 最新消息!pokemmo脚本手机版(透视)一贯是真的辅助辅助器(发现有挂)-哔哩哔哩1)pokemm...
教你透视!德州局HHpoker... 教你透视!德州局HHpoker透视脚本!总算了解辅助脚本(了解有挂)-哔哩哔哩德州局HHpoker透...
在玩家背景下!德普之星辅助工具... 在玩家背景下!德普之星辅助工具如何打开(透视)总是存在有辅助软件(有挂讲解)-哔哩哔哩1、打开软件启...
详细透视!德州局HHpoker... 详细透视!德州局HHpoker透视脚本!一分钟快速了解辅助脚本(有挂规律)-哔哩哔哩1)德州局HHp...
出乎意料的是!wepoker养... 出乎意料的是!wepoker养号规律(透视)一贯真的有辅助工具(有挂教程)-哔哩哔哩运wepoker...
分享透视!aa poker辅助... 分享透视!aa poker辅助!发现玩家辅助器(有挂方略)-哔哩哔哩1、该软件可以轻松地帮助玩家将a...
透视总结!哈糖大菠萝能开挂吗(... 透视总结!哈糖大菠萝能开挂吗(透视)竟然是真的辅助下载(有挂技巧)-哔哩哔哩1、全新机制【哈糖大菠萝...