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



已经尝试将分辨率从QVGA降至 QQVGA (QQQVGA无法识别)
回退至4.8.1的版本即可