From c180047bc1dd55af0768d0421945d8cfea87fbb6 Mon Sep 17 00:00:00 2001 From: Muhammad Abdullah <32646935+mabdullahrafique@users.noreply.github.com> Date: Wed, 8 Nov 2017 15:46:35 -0800 Subject: [PATCH] update digits_video.py Following were the errors in the digits_video.py 1 ) The code was not working because data type of x was float however in "cv2.rectangle" we require integer . 2 ) After pressing the "esc" button the image windows did not destroy So I amended following things: 1 ) ~converted data type of x to int.~ Used Python integer division (//) 2 ) used cv2.destroyAllWindows() to close all windows after the press of "esc" by user. --- samples/python/digits_video.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/python/digits_video.py b/samples/python/digits_video.py index b9f7aef459..9f9c42cc99 100755 --- a/samples/python/digits_video.py +++ b/samples/python/digits_video.py @@ -55,7 +55,7 @@ def main(): if not (16 <= h <= 64 and w <= 1.2*h): continue pad = max(h-w, 0) - x, w = x-pad/2, w+pad + x, w = x - (pad // 2), w + pad cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0)) bin_roi = bin[y:,x:][:h,:w] @@ -98,3 +98,4 @@ def main(): if __name__ == '__main__': main() + cv2.destroyAllWindows()