加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo_kitti2csv.py 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Mads Dyrmann
"""
import kitti
import CSV
import os
CROPBBOXTOIMAGE = True
kittidir = '/mnt/AU_BrugerDrev/Database/GetThumbnailsFromServerForDetection_242_326_336_249_250_279_2018-05-22/LocalizationAnnotationsOnedir/KittiAnnotations'
exportdir = '/mnt/AU_BrugerDrev/Database/GetThumbnailsFromServerForDetection_242_326_336_249_250_279_2018-05-22/LocalizationAnnotationsOnedir/csvAnnotations'
annotationFiles = []
for root, dirnames, filenames in os.walk(kittidir):
for filename in filenames:
if filename.lower().endswith(('.txt')):
annotationFiles.append(os.path.join(root, filename))
def createIfNotExist(directory):
if not os.path.exists(directory):
os.makedirs(directory)
createIfNotExist(exportdir)
for annotationFile in annotationFiles:
kittianno=kitti.readAnnotationFile(annotationFile)
imagepathparts = annotationFile.split(os.path.sep)
imagepathparts[-2]='JPEGImages' #set image folder
imagepathparts[-1]=os.path.splitext(imagepathparts[-1])[-2] #remove extension
imagepathWithoutext=os.path.sep.join(imagepathparts) #construct imagepath without extension
imagesInDirectory = os.listdir(os.path.sep.join(imagepathparts[:-1]))
imagepathWithExtension =[x for x in imagesInDirectory if os.path.splitext(x)[0]==imagepathWithoutext]
AUanno = kitti.kitti2AU(kittianno,filename=annotationFile)
csvanno = CSV.AU2csv(AUanno)
CSV.csvlist2file(csvAnnotationList=csvanno,outputpath=exportdir)
pass
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化