Author SHA1 Message Date
linyimin 563f76745a pref: clean code 2026-09-01 15:04:04 +08:00
linyimin 48368316d7 fix: 修改版本号 2026-09-01 14:10:47 +08:00
linyimin a6547e5c32 fix: 摄像头翻转 2026-09-01 11:53:15 +08:00
linyimin 2cf223a9da fix 2026-09-01 11:53:09 +08:00
13 changed files with 38 additions and 66 deletions
+1 -5
View File
@@ -1,6 +1,6 @@
id: t11
name: t11
version: 2.17.14
version: 2.18.2
author: t11
icon: ''
desc: t11
@@ -20,10 +20,6 @@ files:
- main.py
- model_317828.cvimodel
- model_317828.mud
- model_317211.cvimodel
- model_317211.mud
- model_270820.cvimodel
- model_270820.mud
- network.py
- ota_curl.sh
- ota_manager.py
+26 -1
View File
@@ -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):
"""
+3 -1
View File
@@ -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 表示不缩图
@@ -239,7 +241,7 @@ TRIANGLE_BLACKHAT_KERNEL_FRAC = 0.018 # 核大小 ≈ min(h,w)*frac,取奇数
# ── YOLO(NPU) 靶环 ROI → 裁剪后再跑三角形(减小 CPU 处理面积)──────────────────
# 日志里 net_in=W×H 来自 .mud 模型(det.input_width/height),不是这里配置的。
TRIANGLE_YOLO_ROI_ENABLE = True
TRIANGLE_YOLO_MODEL_PATH = APP_DIR + "/model_317211.mud"
TRIANGLE_YOLO_MODEL_PATH = APP_DIR + "/model_317828.mud"
# 参与 ROI 的类别:多类时只填「整靶/靶环」的 id;不要填角标类,否则 union 仍可对,但 largest 会偏小。
TRIANGLE_YOLO_RING_CLASS_IDS = (0,)
TRIANGLE_YOLO_CONF_TH = 0.9
+7 -6
View File
@@ -136,6 +136,7 @@ def cmd_str():
sync_system_time_from_4g()
# 2.1 WiFi 热点配网兜底:仅当 STA 与 4G 均不可用时起 AP + HTTP;提交后删 /boot/wifi.ap、建 wifi.sta 并 reboot
_ota_pending_path = f"{config.APP_DIR}/ota_pending.json"
try:
from wifi_config_httpd import maybe_start_wifi_ap_fallback
@@ -293,8 +294,8 @@ def cmd_str():
last_adc_trigger = 0
trigger_adc_val = 0 # 触发时的气压值,气压需降回此值以下才能再次触发
enable_check = True
# 读取一次ADC初始值,防止开机时传感器已有压力导致误触发
enable_check = True
try:
last_adc_val = hardware_manager.adc_obj.read()
except Exception:
@@ -388,15 +389,15 @@ def cmd_str():
pressure_max = adc_val
if len(pressure_buf) >= PRESSURE_BATCH_SIZE:
_flush_pressure_buf("batch")
# 突变增量检测:压力增量大于500时触发
# 触发后需等气压降触发以下才重新允许下一次触发。
if adc_val < trigger_adc_val:
# 突变增量检测:压力增量大于300时触发
# 触发后需等气压降触发以下才重新检测增量
if adc_val < trigger_adc_val :
enable_check = True
if (adc_val - last_adc_val) > 500 and enable_check:
hardware_manager.start_idle_timer() # 重新计时
last_adc_trigger = current_time
trigger_adc_val = adc_val # 记录触发
last_adc_val = adc_val # 更新基准,防止连续增量重复触发
trigger_adc_val = adc_val # 记录触发时的气压值
last_adc_val = adc_val # 更新基准,防止连续增量触发
enable_check = False
_flush_pressure_buf("before_trigger")
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
[basic]
type = cvimodel
model = model_270139.cvimodel
[extra]
model_type = yolov5
input_type = rgb
mean = 0, 0, 0
scale = 0.00392156862745098, 0.00392156862745098, 0.00392156862745098
anchors = 10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326
labels = 黑三角和圆环
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
[basic]
type = cvimodel
model = model_270820.cvimodel
[extra]
model_type = yolov5
input_type = rgb
mean = 0, 0, 0
scale = 0.00392156862745098, 0.00392156862745098, 0.00392156862745098
anchors = 10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326
labels = triangle
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
[basic]
type = cvimodel
model = model_285484.cvimodel
[extra]
model_type = yolov5
input_type = rgb
mean = 0, 0, 0
scale = 0.00392156862745098, 0.00392156862745098, 0.00392156862745098
anchors = 10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326
labels = 20, 40
Binary file not shown.
-13
View File
@@ -1,13 +0,0 @@
[basic]
type = cvimodel
model = model_317211.cvimodel
[extra]
model_type = yolov5
input_type = rgb
mean = 0, 0, 0
scale = 0.00392156862745098, 0.00392156862745098, 0.00392156862745098
anchors = 10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326
labels = circle, triangle
+1 -1
View File
@@ -4,6 +4,6 @@
应用版本号
每次 OTA 更新时,只需要更新这个文件中的版本号
"""
VERSION = '2.17.14'
VERSION = '2.18.2'