【发布时间】:2017-07-19 00:51:45
【问题描述】:
【问题讨论】:
-
您为示例和输出提供了相同的链接。
-
@frederick99 对不起..现在请再检查一次....
标签: python-2.7 opencv image-processing
【问题讨论】:
标签: python-2.7 opencv image-processing
Amitay 精彩回答的简短补充。您应该使用
否定图像cv2.THRESH_BINARY_INV
在白纸上捕捉黑色字母。
另一个想法可能是这样的 MSER blob 检测器:
img = cv2.imread('path to image')
(h, w) = img.shape[:2]
image_size = h*w
mser = cv2.MSER_create()
mser.setMaxArea(image_size/2)
mser.setMinArea(10)
gray = cv2.cvtColor(filtered, cv2.COLOR_BGR2GRAY) #Converting to GrayScale
_, bw = cv2.threshold(gray, 0.0, 255.0, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
regions, rects = mser.detectRegions(bw)
# With the rects you can e.g. crop the letters
for (x, y, w, h) in rects:
cv2.rectangle(img, (x, y), (x+w, y+h), color=(255, 0, 255), thickness=1)
这也会导致全字母识别。
【讨论】:
您可以执行以下操作(opencv 3.0 及以上)
【讨论】: