首页 > 其他 > 详细

文本检测-2-SelectiveSearch

时间:2021-04-02 17:38:06      阅读:27      评论:0      收藏:0      [点我收藏+]

技术分享图片

# -*- encoding: utf-8 -*-
"""
@date: 2021/4/2 1:14 下午
@author: xuehuiping
"""
import selectivesearch
import cv2
from PIL import Image, ImageDraw

img = cv2.imread(‘WechatIMG92.jpeg‘)

img_label, regions = selectivesearch.selective_search(img, scale=500, sigma=0.9, min_size=100)
print(regions[:10])

im = Image.open(‘WechatIMG92.jpeg‘)
draw = ImageDraw.Draw(im)  # 实例化一个对象

for region in regions:
    rect = region[‘rect‘]
    # ‘rect‘: (left, top, width, height)
    x1, y1, x2, y2 = rect
    x2 = x1 + x2
    y2 = y1 + y2
    draw.polygon([(x1, y1), (x1, y2), (x2, y2), (x2, y1)], outline=(255, 0, 0))

im.show()

所有结果

技术分享图片

去除篇幅过大的

# 太大的框,不要了
    if width > width_all / 10:
        continue
    if height > height_all / 10:
        continue

技术分享图片

再去除过长过宽的

# 不方正的,不要了
    if width / height > 2 or height / width > 2:
        continue

技术分享图片

思考

若是能提前将蓝色、绿色、黑色的去掉,效果能更好一些

文本检测-2-SelectiveSearch

原文:https://www.cnblogs.com/xuehuiping/p/14610332.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!