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

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

相关内容

热门资讯

透视指南!hh poker透视... 透视指南!hh poker透视器下载,hhpoker德州真的假的(透视)切实有透视脚本(哔哩哔哩)1...
透视步骤!hhpoker到底可... 透视步骤!hhpoker到底可以作必弊吗,wepoker软件安装包(透视)本来是有透视神器(哔哩哔哩...
透视指引!aapoker能控制... 透视指引!aapoker能控制牌吗,aapoker万能辅助器(透视)真是存在有透视插件(哔哩哔哩)1...
透视妙招!来玩app破解,po... 透视妙招!来玩app破解,pokemmo脚本手机版(透视)好像有脚本方法(哔哩哔哩)1、下载好pok...
透视讲义!wepoker模拟器... 透视讲义!wepoker模拟器哪个好用,wepoker透视功能下载(透视)一直有透视app(哔哩哔哩...
透视手筋!aapoker辅助怎... 透视手筋!aapoker辅助怎么用,aapoker脚本(透视)总是有透视器(哔哩哔哩)1、游戏颠覆性...
透视步骤!德普之星辅助器,德普... 透视步骤!德普之星辅助器,德普之星透视软件免费入口官网(透视)其实有透视软件(哔哩哔哩);1、起透看...
透视窍要!hhpoker软件可... 透视窍要!hhpoker软件可以玩吗,hhpoker有没有辅助(透视)竟然存在有脚本攻略(哔哩哔哩)...
透视模板!wepoker到底有... 透视模板!wepoker到底有没有透视,wepoker祈福有用吗(透视)一贯真的是有脚本方法(哔哩哔...
透视总结!哈糖大菠萝攻略,哈糖... 透视总结!哈糖大菠萝攻略,哈糖大菠萝软件下载(透视)其实存在有透视插件(哔哩哔哩)1、哈糖大菠萝软件...