From a631d74d8778e21bb4d893e085829ec35bc2fd01 Mon Sep 17 00:00:00 2001 From: dahanzimin <353767514@qq.com> Date: Wed, 29 Oct 2025 12:07:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0esp-dl=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=AE=80=E5=8D=95=E6=93=8D=E4=BD=9C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../origin/build/lib/esp_dl.py | 33 +++++++++++++++++++ .../origin/build/lib/st7789_cf.py | 4 +-- 2 files changed, 35 insertions(+), 2 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 c879aad7..ad219e79 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 @@ -15,3 +15,36 @@ def analyze(results, keys=None, num=0): return len(results) else: return results[num][keys] + +#简单处理模型运行结果 +_onboard_tft = None + +def simple_run(molde, camera, keys="len", 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 + + _img = camera.capture() + _onboard_tft.display(_img, sync=False) + _result = molde.run(_img.image) + _data = None + if _result: + 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) + 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) + else: + _onboard_tft.shows(r['data'], x=x, y=y, size=size, center=0, color=color, sync=False) + + if keys == "len": + _data = len(_result) + else: + _data = _result[num][keys] + if sync: _onboard_tft.show() + return _data diff --git a/boards/default_src/micropython_esp32s3/origin/build/lib/st7789_cf.py b/boards/default_src/micropython_esp32s3/origin/build/lib/st7789_cf.py index c67b1464..96f70e55 100644 --- a/boards/default_src/micropython_esp32s3/origin/build/lib/st7789_cf.py +++ b/boards/default_src/micropython_esp32s3/origin/build/lib/st7789_cf.py @@ -48,7 +48,7 @@ class ST7789(uframebuf.FrameBuffer_Uincode): if img.width == self.width and img.height == self.height: self._buffer[:] = img.image #大于屏幕图像 - elif img.width > self.width and img.height > self.height: + elif img.width >= self.width and img.height >= self.height: _x = ((img.width - self.width) // 2) if x is None else max(0, min(x, img.width - self.width)) _y = ((img.height - self.height) // 2) if y is None else max(0, min(y, img.height - self.height)) for line in range(self.height): @@ -56,7 +56,7 @@ class ST7789(uframebuf.FrameBuffer_Uincode): dst_pos = line * self.width * 2 self._buffer[dst_pos:dst_pos + self.width * 2] = img.image[src_pos:src_pos + self.width * 2] #小于屏幕图像 - elif img.width < self.width and img.height < self.height: + elif img.width <= self.width and img.height <= self.height: _x = ((self.width - img.width) // 2) if x is None else max(0, min(x, self.width - img.width)) _y = ((self.height- img.height) // 2) if y is None else max(0, min(y, self.height - img.width)) for line in range(img.height):