From 4906f561995b24eb35ec031f3d349bdb589324f0 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Wed, 10 Jul 2024 15:07:22 +0800 Subject: [PATCH] * optimize app_rtsp --- projects/app_rtsp/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/app_rtsp/main.py b/projects/app_rtsp/main.py index a9b882ad..9ef5aea6 100755 --- a/projects/app_rtsp/main.py +++ b/projects/app_rtsp/main.py @@ -1,4 +1,4 @@ -from maix import app, rtsp, camera, image, display, touchscreen +from maix import app, rtsp, camera, image, display, touchscreen, time # init camera cam = camera.Camera(640, 480, image.Format.FMT_YVU420SP) @@ -19,6 +19,7 @@ img_exit_touch = image.load("./assets/exit_touch.jpg").resize(50, 50) img_eye_open = image.load("./assets/img_eye_open.png").resize(50, 50) img_eye_close = image.load("./assets/img_eye_close.png").resize(50, 50) +img_eye_last_change = time.ticks_ms() def touch_box(t, box, oft = 0): if t[2] and t[0] + oft > box[0] and t[0] < box[0] + box[2] + oft and t[1] + oft > box[1] and t[1] < box[1] + box[3] + oft: @@ -40,7 +41,8 @@ def touch_box(t, box, oft = 0): img.draw_image(box[0], box[1], img_exit) box = [img.width() - img_eye_open.width() - 20, 15, img_eye_open.width(), img_eye_open.height()] - if touch_box(t, box, 20): + if touch_box(t, box, 20) and time.ticks_ms() - img_eye_last_change > 200: + img_eye_last_change = time.ticks_ms() show_urls = not show_urls if show_urls: