python opencv 文字识别_python通过EAST文本检测器使用OpenCV检测图像中的文本

本文介绍了如何在Python环境下利用EAST文本检测器和OpenCV来检测自然图像和视频中的文字。首先,通过EAST算法定位文字区域,然后可以进一步使用OCR技术识别文字。文章提供了代码示例,包括图片和视频的文字检测,并列出了所需依赖库和源码链接。
摘要由CSDN通过智能技术生成

1 场景

在python环境下,使用EAST文本检测器使用OpenCV检测自然场景图像中的文本。

即通过算法,检测标识出来自然图像中的文字区域。

可以检测图像中的文字区域和视频中的文字区域。

之后可以截取文字区域图像,再通过OCR算法,检测出文字的内容。

检测效果如下:

0ff218b6a894

1.png

2 官网

(1)英文官方地址

(2)中文译文地址

(3)源码地址(百度网盘)

源码项目结构:

.

├── images

│ ├── car_wash.png

│ ├── lebron_james.jpg

│ └── sign.jpg

├── frozen_east_text_detection.pb

├── text_detection.py

└── text_detection_video.py

3 依赖

(1)CV2

pip install opencv-python

(2)numpy

pip install numpy

(3)argparse

pip install argparse

4 代码

4.1 识别图片

(1)识别代码text_detection.py

# USAGE

# python text_detection.py --image images/lebron_james.jpg --east frozen_east_text_detection.pb

# import the necessary packages

from imutils.object_detection import non_max_suppression

import numpy as np

import argparse

import time

import cv2

# construct the argument parser and parse the arguments

ap = argparse.ArgumentParser()

ap.add_argument("-i", "--image", type=str,

help="path to input image")

ap.add_argument("-east", "--east", type=str,

help="path to input EAST text detector")

ap.add_argument("-c", "--min-confidence", type=float, default=0.5,

help="minimum probability required to inspect a region")

ap.add_argument("-w", "--width", type=int, default=320,

help="resized image width (should be multiple of 32)")

ap.add_argument("-e", "--height", type=int, default=320,

help="resized image height (should be multiple of 32)")

args = vars(ap.parse_args())

# load the input image and grab the image dimensions

image = cv2.imread(args["image"])

orig = image.copy()

(H, W) = image.shape[:2]

# set the new width and height and then determine the ratio in change

# for both the width and height

(newW, newH) = (args["width"], args["height"])

rW = W / float(newW)

rH = H / float(newH)

# resize the image and grab the new image dimensions

image = cv2.resize(image, (newW, newH))

(H, W) = image.shape[:2]

# define the two output layer names for the EAST detector model that

# we are interested -- the first is the output probabilities and the

# second can be used to derive the bounding box coordi

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值