首先,你需要准备好你的数据集图片和标签,标签通常是一个包含每个目标框的类别、位置和大小信息的文本文件。接下来,你可以使用如下 Python 代码来创建一个 YOLOv5 数据集标注工具:
```python import cv2 import numpy as np
class YOLOv5AnnotationTool: def init(self, image_folder, labels): self.image_folder = image_folder self.labels = labels self.current_image_index = 0 self.current_image_path = self.image_folder[self.current_image_index] self.current_image = cv2.imread(self.current_image_path) self.current_annotations = [] self.window_name = "YOLOv5 Annotation Tool" cv2.namedWindow(self.window_name) cv2.setMouseCallback(self.window_name, self.draw_bounding_box)
def draw_bounding_box(self, event, x, y, flags, param):