当前位置:网站首页>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
边栏推荐
- Consumer goods enterprises, four pain points of member marketing
- 十大券商有哪些?手机开户安全么?
- HUST網絡攻防實踐|6_物聯網設備固件安全實驗|實驗二 基於 MPU 的物聯網設備攻擊緩解技術
- 11、 Box styles and user interface
- 开通证券账户需要注意事项 开户安全吗
- File decryption in webgame development
- Which is safer and better for great wisdom to open an account
- 房租是由什么决定的
- Using the methods in the repository to solve practical problems
- 菜鸟实战UML——活动图
猜你喜欢

Installing MySQL under Linux (RPM package installation)

HUST network attack and defense practice | 6_ IOT device firmware security experiment | Experiment 2 MPU based IOT device attack mitigation technology

Build Pikachu shooting range and introduction
![[solved] data duplication or data loss after laravel paginate() paging](/img/68/7bf51bbf893a91bee24f5f7d4a369f.jpg)
[solved] data duplication or data loss after laravel paginate() paging

国际美妆业巨头押注中国

Xiaolong 888 was released, Xiaomi 11 was launched, and 14 manufacturers carried it in the first batch!

1、 MySQL introduction

Mysql8 master-slave replication

AD - 将修改后的 PCB 封装更新到当前 PCB 中

"Pinduoduo and short video speed version", how can I roast!
随机推荐
Leetcode 78. Subset and 90 Subset II
How to do well in member marketing three steps to teach you to understand member management
Generate JDE dot train
Vscode solves the problem of Chinese garbled code
Question B of 2016 Sichuan Ti Cup Electronic Design Competition
The laravel dingo API returns a custom error message
The loss of female scientists
2022 edition of China's energy and chemical industry market in-depth investigation and investment feasibility analysis report
Five problems and solutions of member operation
环形队列php
What should I do from member labels to portraits?
Investment planning and forecast report on the future direction of China's smart agriculture during the 14th five year plan (2022)
SQL injection
VMware虚拟机 桥接模式 无法上网 校园网「建议收藏」
Scala-day01- companion objects and HelloWorld
dried food! Yiwen will show you SD card, TF card and SIM card!
一个初级多线程服务器模型
Omnichannel membership - tmall membership 1: opening tutorial
leetcode 715. Range module (hard)
[probability theory] conditional probability, Bayesian formula, correlation coefficient, central limit theorem, parameter estimation, hypothesis test