Skip to content

Commit 4f524db

Browse files
shaikmoeedalalek
authored andcommitted
Merge pull request #2269 from shaikmoeed:hotfix/samples-motempl-python-update
* Fix bug: Invalid Syntax at line 14(draw_motion_comp method) * Fix bug: TypeError- integer argument expected, got float * Fix bug: clean up the camera by adding .release()
1 parent f5e493b commit 4f524db

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/optflow/samples/motempl.py

+6-3
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)