From 537a1b8cbb875e7b8f686668f84668f4c3332c4a Mon Sep 17 00:00:00 2001 From: dahanzimin <353767514@qq.com> Date: Fri, 31 Oct 2025 11:26:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0sant=E5=9C=A8=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E8=BF=90=E8=A1=8C=E5=9B=BE=E5=83=8F=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=E7=AD=89=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../origin/build/lib/esp_dl.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/boards/default_src/micropython_esp32s3/origin/build/lib/esp_dl.py b/boards/default_src/micropython_esp32s3/origin/build/lib/esp_dl.py index ad219e79..6835d5df 100644 --- a/boards/default_src/micropython_esp32s3/origin/build/lib/esp_dl.py +++ b/boards/default_src/micropython_esp32s3/origin/build/lib/esp_dl.py @@ -19,32 +19,44 @@ def analyze(results, keys=None, num=0): #简单处理模型运行结果 _onboard_tft = None -def simple_run(molde, camera, keys="len", num=0, color=0xF800, size=2, sync=True): +def simple_run(molde, camera, keys="len", keyx=None, num=0, color=0xF800, size=2, sync=True): global _onboard_tft if _onboard_tft is None: from mixgo_sant import onboard_tft _onboard_tft = onboard_tft + if sync: _onboard_tft.fill(0, sync=False) _img = camera.capture() _onboard_tft.display(_img, sync=False) _result = molde.run(_img.image) _data = None + if _result: + _x_of = (camera.get_pixel_width() - _onboard_tft.width) // 2 + _y_of = (camera.get_pixel_height() - _onboard_tft.height) // 2 + for r in _result: x = 0 y = 0 + if r['box']: - _onboard_tft.rect(r['box'][0], r['box'][1], r['box'][2], r['box'][3], color, sync=False) + _onboard_tft.rect(r['box'][0] - _x_of, r['box'][1] - _y_of, r['box'][2], r['box'][3], color, sync=False) x = r['box'][0] y = r['box'][1] + r['box'][3] + if "person" in r: - _onboard_tft.shows(r['person']['name'], x=x, y=y, size=size, center=0, color=color, sync=False) + _onboard_tft.shows(r['person']['name'], x=x - _x_of, y=y - _y_of, size=size, center=0, color=color, sync=False) else: - _onboard_tft.shows(r['data'], x=x, y=y, size=size, center=0, color=color, sync=False) + if r['box']: + _onboard_tft.shows(r['data'], x=x - _x_of, y=y - _y_of, size=size, center=0, color=color, sync=False) + else: + _onboard_tft.shows(r['data'], y=0, size=size, center=True, color=color, sync=False) + break if keys == "len": _data = len(_result) else: - _data = _result[num][keys] + _data = _result[num][keys] if keyx is None else _result[num][keys][keyx] + if sync: _onboard_tft.show() return _data