MCPcopy Create free account
hub / github.com/JimmyHHua/opencv_tutorials / process

Function process

python/code_080/opencv_080.py:9–23  ·  view source on GitHub ↗
(image, opt=1)

Source from the content-addressed store, hash-verified

7
8
9def process(image, opt=1):
10 mask = fgbg.apply(frame)
11 line = cv.getStructuringElement(cv.MORPH_RECT, (1, 5), (-1, -1))
12 mask = cv.morphologyEx(mask, cv.MORPH_OPEN, line)
13 cv.imshow("mask", mask)
14 # 轮廓提取, 发现最大轮廓
15 out, contours, hierarchy = cv.findContours(mask, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
16 for c in range(len(contours)):
17 area = cv.contourArea(contours[c])
18 if area < 150:
19 continue
20 rect = cv.minAreaRect(contours[c])
21 cv.ellipse(image, rect, (0, 255, 0), 2, 8)
22 cv.circle(image, (np.int32(rect[0][0]), np.int32(rect[0][1])), 2, (255, 0, 0), 2, 8, 0)
23 return image, mask
24
25
26while True:

Callers 1

opencv_080.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected