当前位置:网站首页>KITTI Detection dataset whose format is letf_top_right_bottom to JDE normalied xc_yc_w_h
KITTI Detection dataset whose format is letf_top_right_bottom to JDE normalied xc_yc_w_h
2022-06-26 12:32:00 【大别山伧父】
Transform KITTI detection to normalized format which is adapt to JDE
- 本质上就是 txt 版本的yolo 格式
- JDE 方法是当前的主流,类似于SOT的Siamese,平衡精度与速度
- 本代码是KITTIDetection数据集的转换,如要改成KITTI Tracking则需要改变图像尺寸以及筛选标签
from PIL import Image
from glob2 import glob
import os
# 测试数据集中某张图片的尺寸,KITTI的检测数据集尺寸为 1224x370
detection_kitti_imtemp = r"E:\8_DataSet\KITTI_detection\VOCKitti\JPEGImages\000000.png"
# 原始数据标签存放文件夹
''' training/label_2 - 000000.txt person x x x left top right bottom x ... car x x x left top right bottom x ... ... - 000001.txt - ... '''
label_path = r"E:\8_DataSet\KITTI_detection\KITTIObjectdata_object_label_2\training\label_2"
dst_label_path_human = r"E:\8_DataSet\KITTI_detection\KITTIObjectdata_object_label_2\training\label_2_jde_with_ids_human"
dst_label_path_car = r"E:\8_DataSet\KITTI_detection\KITTIObjectdata_object_label_2\training\label_2_jde_with_ids_car"
''' training/label_2_jde_with_ids_car - 000000.txt 0 -1 xc yc width height ... - 000001.txt - ... '''
# kitti_xywh = "{} {} {} {} {} {}".format(0, -1, x, )
# left_top right_bottom to normalized center x, y and width, height
def convert(size, box):
dw = 1. / size[0]
dh = 1. / size[1]
for _, item in enumerate(box):
box[_] = float(item)
x = (box[0] + box[2]) / 2.0 # (x1+x2)/ 2
y = (box[1] + box[3]) / 2.0 # (y1+y2)/ 2
w = box[2] - box[0] # x2 - x1 or l-r = w
h = box[3] - box[1] # y2 - y1 or b-t = h
x = x * dw
w = w * dw
y = y * dh
h = h * dh
kitti_xywh = "{} {} {} {} {} {}".format(0, -1, x, y, w, h)
# xywh = (x, y, w, h)
return kitti_xywh
def get_img_size(img_path):
# img_path = detection_kitti_imtemp
im = Image.open(img_path)
w = int(im.size[0])
h = int(im.size[1])
image_size = (w, h)
# print("Image Size: width->{}, height->{}".format(image_size[0], image_size[1]))
return image_size
# 1223, 370
image_size_det = get_img_size(img_path=detection_kitti_imtemp)
def write_txt_file(xywh, dst_directory, file_name):
path = os.path.join(dst_directory, file_name)
with open(path, "a") as f:
f.write(xywh)
f.write("\n")
def get_txt_list(label_path):
# label_list = os.listdir(label_path)
label_list = glob(label_path + "/*.txt")
for txt_file in label_list:
txt_file_name = os.path.split(txt_file)[-1]
with open(txt_file, "r") as f:
lines = f.readlines()
for line in lines:
line = line.split(" ")
if line[0] == "person": # 筛选出标签为 person的bbox并正则化
bbox = line[4:8]
n_xywh = convert(image_size_det, bbox)
write_txt_file(xywh=n_xywh, dst_directory=dst_label_path_human, file_name=txt_file_name)
if line[0] == "car": # 筛选出标签为 car 的bbox并正则化
bbox = line[4:8]
n_xywh = convert(image_size_det, bbox)
write_txt_file(xywh=n_xywh, dst_directory=dst_label_path_car, file_name=txt_file_name)
# print(line)
# print 和 break 为测试专用
# break
return label_list
get_txt_list(label_path)
# label_list = get_txt_list(label_path=label_path)
# for txt_file in label_list:
# pass
边栏推荐
- Thinkphp5 query report: sqlstate[hy093]: invalid parameter number
- 2022 China smart bathroom cabinet Market Research and investment Competitiveness Analysis Report
- Investment planning and forecast report on the future direction of China's smart agriculture during the 14th five year plan (2022)
- PHP get directory size
- JMeter response time and TPS listener tutorial
- Ctfshow web getting started command execution web75-77
- 环形队列php
- Ubuntu安装配置PostgreSQL(18.04)
- Polarismesh series articles - concept series (I)
- Scala-day06- pattern matching - Generic
猜你喜欢

Laravel subdomain accesses different routing files and different modules

4. N queen problem

Ad - update the modified PCB package to the current PCB

PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)

TP5 thinkphp5 report serialization of'closure'is not allowed

International beauty industry giants bet on China
![[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]](/img/13/c2c63333a9e5ac08b339449ea17654.jpg)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]

Ctfshow web getting started command execution web75-77

【Redis 系列】redis 学习十六,redis 字典(map) 及其核心编码结构

Installing MySQL under Linux (RPM package installation)
随机推荐
MS17_ 010 utilization summary
"Pinduoduo and short video speed version", how can I roast!
Five trends of member management in 2022
Refined operation, extending the full life cycle value LTV
Several problems encountered in setting up the environment in the past two days
What software is flush? Is online account opening safe?
Five problems and solutions of member operation
webgame开发中的文件解密
UDP protocol details [easy to understand]
[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test
Scala-day03- operators and loop control
HUST network attack and defense practice | 6_ IOT device firmware security experiment | Experiment 2 MPU based IOT device attack mitigation technology
Scala problem solving the problem of slow SBT Download
Investment planning and forecast report on the future direction of China's smart agriculture during the 14th five year plan (2022)
Laravel uses find_ IN_ The set() native MySQL statement accurately queries whether a special string exists in the specified string to solve the problem that like cannot be accurately matched. (resolve
Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)
我想知道同花顺是炒股的么?在线开户安全么?
SQL injection in Pikachu shooting range
Assembly language (7) operation instruction
TSMC Samsung will mass produce 3nm chips in 2022: will the iPhone be the first?