Skip to content

Commit 10119e6

Browse files
committed
MSER区域检测
1 parent f206245 commit 10119e6

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ http://docs.opencv.org/3.2.0/d6/d00/tutorial_py_root.html
4343
-
4444

4545
## 新闻News
46-
- http://www.opencv.org.cn/ http://www.cnros.org/ 被关闭
46+
- http://www.opencv.org.cn/ 被关闭

cv-MSER区域检测/EnA6A.jpg

66.3 KB
Loading

cv-MSER区域检测/MSER_create1.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2017/8/7 19:34
3+
# @Author : play4fun
4+
# @File : MSER_create1.py
5+
# @Software: PyCharm
6+
7+
"""
8+
MSER_create1.py:
9+
https://stackoverflow.com/questions/40443988/python-opencv-ocr-image-segmentation
10+
"""
11+
12+
import cv2
13+
14+
img = cv2.imread('WQbGH.jpg')
15+
img = img[5:-5, 5:-5, :]
16+
17+
mser = cv2.MSER_create()
18+
19+
# Resize the image so that MSER can work better
20+
img2 = cv2.resize(img, (img.shape[1] * 2, img.shape[0] * 2))#扩大
21+
22+
gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
23+
vis = img2.copy()
24+
25+
regions = mser.detectRegions(gray)
26+
hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions[0]]
27+
cv2.polylines(vis, hulls, 1, (0, 255, 0))
28+
29+
img3 = cv2.resize(vis, (img.shape[1], img.shape[0]))
30+
cv2.namedWindow('img', 0)
31+
cv2.imshow('img', img3)
32+
cv2.imwrite('mser-result.jpg', vis)
33+
cv2.waitKey(0)
34+
cv2.destroyAllWindows()
35+

cv-MSER区域检测/WQbGH.jpg

37.3 KB
Loading

cv-MSER区域检测/mser-result.jpg

223 KB
Loading

官方samples/mser.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
'''
44
MSER detector demo
5+
MSER区域检测
56
==================
67
78
Usage:

0 commit comments

Comments
 (0)