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

Function process

python/code_083/opencv_083.py:5–30  ·  view source on GitHub ↗
(image, opt=1)

Source from the content-addressed store, hash-verified

3
4
5def process(image, opt=1):
6 # Detecting corners
7 gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
8 corners = cv.goodFeaturesToTrack(gray, 100, 0.05, 10)
9 print(len(corners))
10 for pt in corners:
11 print(pt)
12 b = np.random.random_integers(0, 256)
13 g = np.random.random_integers(0, 256)
14 r = np.random.random_integers(0, 256)
15 x = np.int32(pt[0][0])
16 y = np.int32(pt[0][1])
17 cv.circle(image, (x, y), 5, (int(b), int(g), int(r)), 2)
18
19 # detect sub-pixel
20 winSize = (3, 3)
21 zeroZone = (-1, -1)
22
23 # Stop condition
24 criteria = (cv.TERM_CRITERIA_EPS + cv.TermCriteria_COUNT, 40, 0.001)
25 # Calculate the refined corner locations
26 corners = cv.cornerSubPix(gray, corners, winSize, zeroZone, criteria)
27 # display
28 for i in range(corners.shape[0]):
29 print(" -- Refined Corner [", i, "] (", corners[i, 0, 0], ",", corners[i, 0, 1], ")")
30 return image
31
32src = cv.imread("tyt.png")
33cv.imshow("input", src)

Callers 1

opencv_083.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected