MCPcopy
hub / github.com/makelove/OpenCV-Python-Tutorial / rnd_warp

Function rnd_warp

官方samples/mosse.py:37–47  ·  view source on GitHub ↗
(a)

Source from the content-addressed store, hash-verified

35import video
36
37def rnd_warp(a):
38 h, w = a.shape[:2]
39 T = np.zeros((2, 3))
40 coef = 0.2
41 ang = (np.random.rand()-0.5)*coef
42 c, s = np.cos(ang), np.sin(ang)
43 T[:2, :2] = [[c,-s], [s, c]]
44 T[:2, :2] += (np.random.rand(2, 2) - 0.5)*coef
45 c = (w/2, h/2)
46 T[:,2] = c - np.dot(T[:2, :2], c)
47 return cv2.warpAffine(a, T, (w, h), borderMode = cv2.BORDER_REFLECT)
48
49def divSpec(A, B):
50 Ar, Ai = A[...,0], A[...,1]

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected