logo

OpenMV Cam部署YOLO V8模型后运行main程序自动断连

2026-06-02 09:03
N
n2uu3zb3wrs9

OpenMV Cam部署YOLO V8模型后运行main程序自动断连

故障描述

按照教程制作并部署YOLO V8模型,连接N6硬件后运行main程序时自动断连,无报错信息。

故障类型

其他

硬件信息

  • 硬件型号:其他(非标准OpenMV4 H7 / H7 Plus / RT)
  • 固件版本:4.8.1

故障代码

# This work is licensed under the MIT license.

# Copyright (c) 2013-2025 OpenMV LLC. All rights reserved.

# <https://github.com/openmv/openmv/blob/master/LICENSE>

#

# TensorFlow Lite YOLO V8 Example

#

# This example runs a YOLO V8 person detection model.

#

# NOTE: This exaxmple requires an OpenMV Cam with an NPU like the AE3 or N6 to run real-time.

import csi
import time
import ml
from ml.postprocessing.ultralytics import YoloV8

# Initialize the sensor.

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((416, 416))

# Load YOLO V8 model from ROM FS.

model = ml.Model("/rom/trained.tflite", postprocess=YoloV8(threshold=0.4))
print(model)

# Visualization parameters.

n = len(model.labels)
model_class_colors = [(int(255 *i // n), int(255 *(n - i - 1) // n), 255) for i in range(n)]

clock = time.clock()
while True:
    clock.tick()
    img = csi0.snapshot()

# boxes is a list of list per class of ((x, y, w, h), score) tuples
    boxes = model.predict([img])

    # Draw bounding boxes around the detected objects
    for i, class_detections in enumerate(boxes):
        rects = [r for r, score in class_detections]
        for rect in rects:
            img.draw_rectangle(rect)
        labels = [model.labels[i] for j in range(len(rects))]
        colors = [model_class_colors[i] for j in range(len(rects))]
        ml.utils.draw_predictions(img, rects, labels, colors, format=None)

    print(clock.fps(), "fps")

参考来源

AI云服务生成

硬件图片

image
image
2026-06-02 09:30
Z
星小瞳xs

使用最新版本OpenMV IDE 使用此固件:Release Development Release · openmv/openmv 在IDE的工具栏烧录此固件即可