赞
踩
基本思想:为了给BBAVectors-Oriented-Object-Detection 提供数据,所以记录一下操作,搞了旋转,但是旋转影响图片大小,所以先写个镜像方法,进行训练和使扩充数据集
一、labelme转dota数据集 ,并做了顺时针排序处理
- import json
- import os
- from glob import glob
- import argparse
- import numpy as np
- import shutil
- from PIL import Image
-
-
- # convert labelme json to DOTA txt format
- # convert DOTA json to lableme txt format
- def custombasename(fullname):
- return os.path.basename(os.path.splitext(fullname)[0])
-
-
- def order_points_new(pts): # clock -https://zhuanlan.zhihu.com/p/10643062
- # sort the points based on their x-coordinates
- xSorted = pts[np.argsort(pts[:, 0]), :]
-
- # grab the left-most and right-most points from the sorted
- # x-roodinate points
- leftMost = xSorted[:2, :]
- rightMost = xSorted[2:, :]
- if leftMost[0,1]!=leftMost[1,1]:
- leftMost=leftMost[np.argsort(leftMost[:,1]),:]
- else:
- leftMost=leftMost[np.argsort(leftMost[:,0])[::-1],:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。