赞
踩
OBB和HBB标注方式:
a. HBB(Horizontal Bounding Box,HBB),通常表示为{x,y,w,h}
b. OBB(Oriented Bounding Box,OBB),是指标注任意四边形;顶点按顺时针顺序排列;通常表示为 {x,w,h, θ \theta θ }
现有数据集的标注方式为OBB,在数据集中,每个对象都由一个定向边界框 (OBB) 注释,该边界框可以表示 ( x 1 , y 1 , x 2 , y 2 , x 3 , y 3 , x 4 , y 4 ) (x_1,y_1,x_2,y_2,x_3,y_3,x_4,y_4) (x1,y1,x2,y2,x3,y3,x4,y4) , 其中 ( x i , y i ) (x_i,y_i) (xi,yi) 表示 OBB 的第 i 个顶点。顶点按顺时针顺序排列。如图1所示,黄色点表示起点,表示:(a) 平面的左上角,(b) 大型车辆钻石的左上角,(c) 棒球钻石的中心。 除了 OBB 之外,每个实例还标有类别和困难,指示实例是否难以检测(1 表示困难,0 表示不困难)。图像的批注保存在具有相同文件名的文本文件中。每行表示一个实例。以下是图像的示例批注:
x1, y1, x2, y2, x3, y3, x4, y4, category, difficult
x1, y1, x2, y2, x3, y3, x4, y4, category, difficult
...
图1
YOLO标注格式
1 0.339041 0.215267 0.426941 0.210687
1 0.339041 0.215267 0.426941 0.210687
分别指所标注内容的类别标签(从0开始)、归一化后的中心点x坐标,归一化后的中心点y坐标,归一化后的目标框宽度w,归一化后的目标况高度h(此处归一化指的是除以图片宽和高)
具体计算方式可参考https://blog.csdn.net/m0_56654441/article/details/120959449
标注格式转换OBB→YOLO
参考:
https://zhuanlan.zhihu.com/p/356416158
https://github.com/hukaixuan19970627/DOTA_devkit_YOLO (YOLO_Transform.py,dota_utils.py )
HBB: id x y w h
import dota_utils as util import os import numpy as np from PIL import Image import cv2 import random import shutil import matplotlib.pyplot as plt from shapely.geometry import Polygon, MultiPoint # 多边形 import time import argparse ## trans dota format to format YOLO(darknet) required def dota2Darknet(imgpath, txtpath, dstpath, extractclassname): """ :param imgpath: the path of images :param txtpath: the path of txt in dota format :param dstpath: the path of txt in YOLO format :param extractclassname: the category you selected :return: txt format: id x y w h """ if os.path.exists(dstpath): shutil
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。