管理对光线条件非常敏感的文本检测器 [英] Manage a text detector which is very sensitive to lighting conditions

查看:60
本文介绍了管理对光线条件非常敏感的文本检测器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一种名为CRAFT的文本检测(您可以在github中查看它),它在我使用的主要图像上做得很好,但是我注意到文本检测对光照条件非常敏感.

要说明这一点,请参见此图片:

  import cv2将numpy导入为np#读取图像img = cv2.imread('truck_id.jpg')#转换为灰色灰色= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)#模糊smooth = cv2.GaussianBlur(gray,(33,33),0)#平滑除以灰色图像除法= cv2.divide(平滑,灰色,比例= 255)#反转除法= 255-除法#保存结果cv2.imwrite('truck_id_division.jpg',部门)#显示结果cv2.imshow(平滑",平滑)cv2.imshow('除法',除法)cv2.waitKey(0)cv2.destroyAllWindows() 

除法结果:

除法结果(全分辨率小节):

I am using a Text Detection called CRAFT (you can check it out in github) which does a good job on major images I have used, but I have noticed that the text detection is very sensitive to lighting conditions.

To ilustrate this, see this image:

Text detected with CRAFT

I am interested in detecting the code part, which is: FBIU0301487. However, it seems that the caracter 'F' cannot be detected even using a threshold equals to zero, i.e. let every bounding box be consired as a valid detection. After seeing more cases like this, I think this happens due to the lighting conditions, i.e areas where there is a high contrast between the parts with shadow and the parts which reflect the light. What's more, this happens in the '22G1' text box as well with the first caracter '2'.

My question is: is there anything I can do try to detect these parts? Maybe I can go with some image preprocessing but I am not pretty sure what kind of preprocessing could help me. I am working in Python but I don't mind the library (OpenCV, scikit-image, ...).

I'd appreciate any idea. Thanks in advance!

解决方案

One possibility would be to do division normalization in Python/OpenCV.

Input:

import cv2
import numpy as np

# read the image
img = cv2.imread('truck_id.jpg')

# convert to gray
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# blur
smooth = cv2.GaussianBlur(gray, (33,33), 0)

# divide smooth by gray image
division = cv2.divide(smooth, gray, scale=255)

# invert
division = 255 - division

# save results
cv2.imwrite('truck_id_division.jpg',division)

# show results
cv2.imshow('smooth', smooth)  
cv2.imshow('division', division)  
cv2.waitKey(0)
cv2.destroyAllWindows()

Division Result:

Division Result (full resolution subsection):

这篇关于管理对光线条件非常敏感的文本检测器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆