From e67c410325348a339e0cba5e500b612865c91af6 Mon Sep 17 00:00:00 2001 From: linyimin <18316471919@139.com> Date: Tue, 1 Sep 2026 11:45:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=91=84=E5=83=8F=E5=A4=B4=E7=BF=BB?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.yaml | 2 +- camera_manager.py | 27 ++++++++++++++++++++++++++- config.py | 2 ++ version.py | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app.yaml b/app.yaml index 0f84772..8daa9fa 100644 --- a/app.yaml +++ b/app.yaml @@ -1,6 +1,6 @@ id: t11 name: t11 -version: 2.17.14 +version: 2.17.15 author: t11 icon: '' desc: t11 diff --git a/camera_manager.py b/camera_manager.py index 0f28ed4..67b61dc 100644 --- a/camera_manager.py +++ b/camera_manager.py @@ -8,6 +8,15 @@ import threading import config from logger_manager import logger_manager +_USE_CV = False +try: + import cv2 + import numpy as np + from maix import image as _maix_image + _USE_CV = True +except ImportError: + pass + class CameraManager: """相机管理器(单例)""" @@ -101,7 +110,23 @@ class CameraManager: with self._camera_lock: if self._camera is None: self.init_camera() - return self._camera.read() + frame = self._camera.read() + if frame is not None and _USE_CV: + try: + v_flip = getattr(config, 'CAMERA_V_FLIP', False) + h_mirror = getattr(config, 'CAMERA_H_MIRROR', False) + if v_flip or h_mirror: + img_cv = _maix_image.image2cv(frame, False, False) + if v_flip and h_mirror: + img_cv = cv2.flip(img_cv, -1) + elif v_flip: + img_cv = cv2.flip(img_cv, 0) + elif h_mirror: + img_cv = cv2.flip(img_cv, 1) + frame = _maix_image.cv2image(img_cv, False, False) + except Exception: + pass + return frame def show(self, image): """ diff --git a/config.py b/config.py index c1ec5ec..38751a5 100644 --- a/config.py +++ b/config.py @@ -15,6 +15,8 @@ LOCAL_FILENAME = APP_DIR + "/main_tmp.py" # 相机初始化分辨率(CameraManager / main.py 使用) CAMERA_WIDTH = 640 CAMERA_HEIGHT = 480 +CAMERA_V_FLIP = True # 摄像头垂直翻转(上下颠倒时设为 True) +CAMERA_H_MIRROR = True # 摄像头水平镜像(左右反了时设为 True) # 三角形检测缩图比例:默认按相机最长边缩到 1/2(性能更稳;可按需调整) # 取值范围建议 (0.25 ~ 1.0];1.0 表示不缩图 diff --git a/version.py b/version.py index 6aa75c9..1622991 100644 --- a/version.py +++ b/version.py @@ -4,6 +4,6 @@ 应用版本号 每次 OTA 更新时,只需要更新这个文件中的版本号 """ -VERSION = '2.17.14' +VERSION = '2.17.15'