遥感数据集+YOLOV5

一、数据集准备

  1. OBB和HBB标注方式:
    a. HBB(Horizontal Bounding Box,HBB),通常表示为{x,y,w,h}
    b. OBB(Oriented Bounding Box,OBB),是指标注任意四边形;顶点按顺时针顺序排列;通常表示为 {x,w,h, θ \theta θ }

  2. 现有数据集的标注方式为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

  3. 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

  4. 标注格式转换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
  • 4
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值