logo

OpenMV H7 Plus 运行 AprilTag 时偶发断连(发热+USB异常弹出)

2026-08-31 18:30
2
2txs5ys4mcxq

OpenMV H7 Plus 运行 AprilTag 时偶发断连(发热+USB异常弹出)

故障概述

OpenMV H7 Plus 在持续运行 AprilTag 检测时,初期帧率稳定(约 46 FPS),但运行数分钟至十几分钟后突发断连:IDE 画面冻结、串口停止输出、USB 设备从系统消失(设备管理器出现感叹号/未知设备),伴随板子明显发热,且运行期间 LED 始终熄灭。

硬件与环境信息

  • 型号:OpenMV4 H7 Plus(OPENMV4P,STM32H743)
  • 固件版本:v5.0.0(MicroPython v1.28.0-49)
  • 连接方式:USB 直连 OpenMV IDE
  • 摄像头配置:CSI 接口,GRAYSCALE + QQVGA,手动关闭 AGC/AWB

关键现象线索

  • 运行中板子明显发热
  • LED 始终熄灭(非闪烁或常亮)
  • 断连后 Windows 弹出 USB 设备异常提示,设备管理器显示感叹号/未知设备

故障代码(AprilTag 检测主循环)

import csi, image, time, math, gc

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.QQVGA)
csi0.snapshot(frames=30)
csi0.auto_gain(False)
csi0.auto_whitebal(False)

clock = time.clock()
frame_count = 0
last_id = -1

while True:
    clock.tick()
    img = csi0.snapshot()
    frame_count += 1

    if frame_count % 3 == 0:
        roi = (40, 30, 80, 60)

        # ===== 核心防护:try-except + 边界检查 =====
        try:
            for tag in img.find_apriltags(roi=roi):
                x, y, w, h = tag.rect
                iw, ih = img.width(), img.height()

                # 边界检查:过滤掉越界或异常的检测结果
                if x < 0 or y < 0 or w < 5 or h < 5:
                    continue
                if x + w > iw or y + h > ih:
                    continue
                if tag.cx < 0 or tag.cx >= iw or tag.cy < 0 or tag.cy >= ih:
                    continue

                img.draw_rectangle(tag.rect, color=255)
                img.draw_cross((tag.cx, tag.cy), color=255)

                degrees = 180 * tag.rotation / math.pi
                if tag.id != last_id:
                    print("Tag ID:", tag.id, "角度:", int(degrees))
                    last_id = tag.id

        except Exception as e:
            print("检测异常:", e)
            gc.collect()

    if frame_count % 100 == 0:
        gc.collect()

    if frame_count % 5 == 0:
        img.draw_string((0, 0), "FPS:%.1f" % clock.fps(), color=255)

参考依据

无外部参考文章,为自主实现的 AprilTag 检测逻辑。

附件图片

image
image
image
2
2txs5ys4mcxq

已经尝试将分辨率从QVGA降至 QQVGA (QQQVGA无法识别)

2026-09-01 10:04
Z
星小瞳xs

回退至4.8.1的版本即可