Skip to content

Commit 26129cf

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 5faa3ec + 1a15cbc commit 26129cf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/optflow/samples/motempl.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
def nothing(dummy):
1212
pass
1313

14-
def draw_motion_comp(vis, (x, y, w, h), angle, color):
14+
def draw_motion_comp(vis, rect, angle, color):
15+
x, y, w, h = rect
1516
cv.rectangle(vis, (x, y), (x+w, y+h), (0, 255, 0))
16-
r = min(w/2, h/2)
17-
cx, cy = x+w/2, y+h/2
17+
r = min(w//2, h//2)
18+
cx, cy = x+w//2, y+h//2
1819
angle = angle*np.pi/180
1920
cv.circle(vis, (cx, cy), r, color, 3)
2021
cv.line(vis, (cx, cy), (int(cx+np.cos(angle)*r), int(cy+np.sin(angle)*r)), color, 3)
@@ -91,4 +92,6 @@ def draw_motion_comp(vis, (x, y, w, h), angle, color):
9192
prev_frame = frame.copy()
9293
if 0xFF & cv.waitKey(5) == 27:
9394
break
95+
# cleanup the camera and close any open windows
96+
cam.release()
9497
cv.destroyAllWindows()

0 commit comments

Comments
 (0)