今天是发现有这么一个东西MSER,然后搜了一下,用代码实现,在这里记录下:
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('D:/codes/ticket.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
mser = cv2.MSER_create(_min_area=300)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
regions, boxes = mser.detectRegions(gray)
for box in boxes:
x, y, w, h = box
cv2.rectangle(img, (x,y),(x+w, y+h), (255, 0, 0), 2)
plt.imshow(img,'brg')
plt.show()
效果是: