From 63b9d10424b123ec26568013854d34323e03d28c Mon Sep 17 00:00:00 2001
From: simon wu <wswday@sina.com>
Date: Fri, 9 Aug 2019 13:32:12 +0800
Subject: [PATCH] Press key to exit (#1155)

---
 tools/webcam_demo.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/webcam_demo.py b/tools/webcam_demo.py
index c1ef27a..33d23d1 100644
--- a/tools/webcam_demo.py
+++ b/tools/webcam_demo.py
@@ -27,9 +27,15 @@ def main():
 
     camera = cv2.VideoCapture(args.camera_id)
 
+    print('Press "Esc", "q" or "Q" to exit.')
     while True:
         ret_val, img = camera.read()
         result = inference_detector(model, img)
+
+        ch = cv2.waitKey(1)
+        if ch == 27 or ch == ord('q') or ch == ord('Q'):
+            break
+
         show_result(
             img, result, model.CLASSES, score_thr=args.score_thr, wait_time=1)
 
-- 
GitLab