import numpy as np
import cv2
import torch
source_directory_img_path= ''
source_directory_label_path= ''
target_directory_path= ''
dic={
}
#坐标转换,原始存储的是YOLOv5格式
# Convert nx4 boxes from [x, y, w, h] normalized to [x1, y1, x2, y2] where xy1=top-left, xy2=bottom-right
def xywhn2xyxy(x, w=640, h=640, padw=0, padh=0):
y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)
y[:, 0] = w * (x[:, 0] - x[:, 2] / 2) + padw # top left x
y[:, 1] = h *
2021-10-28 使用Python从txt中读取YOLO格式标签,OpenCV可视化在对应图片上;并统计各标签出现数量
最新推荐文章于 2024-05-07 20:30:30 发布