v1.2.2
This commit is contained in:
23
main.py
23
main.py
@@ -23,7 +23,7 @@ from logger_manager import logger_manager
|
||||
from time_sync import sync_system_time_from_4g
|
||||
from power import init_ina226, get_bus_voltage, voltage_to_percent
|
||||
from laser_manager import laser_manager
|
||||
from vision import detect_circle_v3, estimate_distance, save_shot_image, save_calibration_image
|
||||
from vision import detect_circle_v3, estimate_distance, enqueue_save_shot, start_save_shot_worker
|
||||
from network import network_manager
|
||||
from ota_manager import ota_manager
|
||||
from hardware import hardware_manager
|
||||
@@ -111,6 +111,9 @@ def cmd_str():
|
||||
|
||||
# 2. 从4G模块同步系统时间(需要 at_client 已初始化)
|
||||
sync_system_time_from_4g()
|
||||
|
||||
# 2.5. 启动存图 worker 线程(队列 + worker,避免主循环阻塞)
|
||||
start_save_shot_worker()
|
||||
|
||||
# 3. 启动时检查:是否需要恢复备份
|
||||
pending_path = f"{config.APP_DIR}/ota_pending.json"
|
||||
@@ -327,19 +330,17 @@ def cmd_str():
|
||||
if logger:
|
||||
logger.info(f"[MAIN] 射箭ID: {shot_id}")
|
||||
|
||||
# 保存图像(无论是否检测到靶心都保存)
|
||||
# save_shot_image 函数会确保绘制激光十字线和检测标注(如果有)
|
||||
# 如果未检测到靶心,文件名会包含 "no_target" 标识
|
||||
save_shot_image(
|
||||
result_img,
|
||||
center,
|
||||
radius,
|
||||
method,
|
||||
# 保存图像(无论是否检测到靶心都保存):放入队列由 worker 异步保存,不阻塞主循环
|
||||
enqueue_save_shot(
|
||||
result_img,
|
||||
center,
|
||||
radius,
|
||||
method,
|
||||
ellipse_params,
|
||||
(x, y),
|
||||
(x, y),
|
||||
distance_m,
|
||||
shot_id=shot_id,
|
||||
photo_dir=config.PHOTO_DIR if config.SAVE_IMAGE_ENABLED else None
|
||||
photo_dir=config.PHOTO_DIR if config.SAVE_IMAGE_ENABLED else None,
|
||||
)
|
||||
|
||||
# 构造上报数据
|
||||
|
||||
Reference in New Issue
Block a user