当前位置: 首页 > news >正文

珠海建设局网站查公司业绩专业h5网站建设教程

珠海建设局网站查公司业绩,专业h5网站建设教程,网站友链查询源码,百度关键词价格计算文章目录 一、效果图 二、库安装 三、使用示例 四、完整代码 一、效果图 使用的图片: 返回文字: 二、库安装 pip install easyocr opencv-python numpy 三、使用示例 ocr EasyOCRProcessor() results ocr.extract_text("test.png",&…

文章目录

一、效果图

二、库安装

三、使用示例

四、完整代码


一、效果图

使用的图片:

返回文字:

二、库安装

pip install easyocr opencv-python numpy  

三、使用示例

ocr = EasyOCRProcessor()
results = ocr.extract_text("test.png","output.png",confidence_threshold=0.6
)

四、完整代码

import easyocr
import cv2
import numpy as npclass EasyOCRProcessor:def __init__(self, languages=['ch_sim', 'en']):"""初始化EasyOCR处理器参数:languages: 需要识别的语言列表"""self.reader = easyocr.Reader(languages)def enhance_image(self, image):"""图像增强处理参数:image: OpenCV图像对象返回:处理后的图像"""# 亮度和对比度调整alpha = 1.2  # 对比度beta = 10  # 亮度adjusted = cv2.convertScaleAbs(image, alpha=alpha, beta=beta)# 锐化kernel = np.array([[-1, -1, -1],[-1, 9, -1],[-1, -1, -1]])sharpened = cv2.filter2D(adjusted, -1, kernel)return sharpeneddef extract_text(self, image_path, output_path=None, confidence_threshold=0.5):"""提取图片中的文字参数:image_path: 图片路径output_path: 可选,输出处理后图片的路径confidence_threshold: 置信度阈值返回:提取的文字内容和位置信息"""try:# 读取图片image = cv2.imread(image_path)if image is None:raise ValueError("无法读取图片")# 图像增强enhanced = self.enhance_image(image)# 使用EasyOCR识别文字results = self.reader.readtext(enhanced)# 处理结果text_results = []for bbox, text, confidence in results:if confidence > confidence_threshold:text_results.append({'text': text,'confidence': confidence,'position': bbox})# 在图片上标记文字区域if output_path:points = np.array(bbox, np.int32)cv2.polylines(image, [points], True, (0, 255, 0), 2)cv2.putText(image, f"{text} ({confidence:.2f})",(int(bbox[0][0]), int(bbox[0][1]) - 10),cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)# 保存处理后的图片if output_path:cv2.imwrite(output_path, image)return text_resultsexcept Exception as e:print(f"错误: {str(e)}")return None# 使用示例
ocr = EasyOCRProcessor()
results = ocr.extract_text("test.png","output.png",confidence_threshold=0.6
)# 打印结果
if results:for result in results:print(f"文字: {result['text']}")print(f"置信度: {result['confidence']}")print(f"位置: {result['position']}")print("---")

http://www.dtcms.com/a/436010.html

相关文章:

  • 136、【OS】【Nuttx】【周边】效果呈现方案解析:strace 日志解析(二)
  • 呼市做网站建设的公司哪家好一个网站成本
  • 洛阳制作网站公司吗wordpress设置内存
  • wordpress vip会员主题企业seo顾问服务公司
  • 《进程概念(1)》
  • 北京企业模板建站南京今天重大新闻事件
  • Pulsar适配AI场景:从技术原理到实战落地
  • 石景山广州网站建设医院网站建设官网
  • 成都做网站的公司弄个小程序要多少钱
  • 手机报价网站大全宣传片拍摄内容
  • BTS7960 四轮前进测试 workable solution
  • 网站架设流程专门app软件制作费用
  • 计算机网站建设维护的目的wordpress 系统需求
  • 无形资产 网站建设官方网站建设与维护好处
  • 程序员用来做笔记的网站网站源码绑定域名
  • 网站建设开发ppt模板德州建设街小学网站
  • 【代码随想录day 34】 力扣 62.不同路径II
  • 哪些公司做网站好河南营销型网站建设
  • 做网站需要写程序绿色营销案例100例
  • 【Linux】进程间通信(1)
  • 域名所有人是网站名不能转出用凡科做网站要钱吗
  • asp.net网站开发上网站开发哪家公司电话
  • 个人做的网站有什么危险吗万网官网域名注册多少钱
  • 网站机房建设成本某公司网络营销现状分析
  • 服务器主机 网站安阳企业网站优化外包
  • DS container adapters <B> priority_queue in Huffman Algorithm 2/99
  • 英语学习-Saints042
  • 建立网站条件一级域名如何分发二级域名
  • wordpress发布失败手机网站优化需要注意什么
  • 北京模板网站建设wordpress远程本地化