先贴代码,后面再补充解析。
这个篇章主要是对标注好的标签进行可视化,虽然比较简单,但是可以从可视化代码中学习到YOLOv8是如何对标签进行解析的。

下面直接贴代码:
import cv2
import numpy as np
import os
def read_det_labels(label_file_path):
    with open(label_file_path, 'r') as file:
        lines = file.readlines()
    
    labels = []
    for line in lines:
        parts = line.strip().split()
        class_id = int(parts[0])
        x_center = float(parts[1])
        y_center = float(parts[2])
        width = float(parts[3])
        height = float(parts[4])
        labels.append((class_id, x_center, y_center, width, height))
    
    return labels
def det_label(label_file,img_file,save_file):
    img=cv2.imread(img_file)
    image=img.copy()
    img_height,img_width,_=image.s


















