Foggy_driving数据集官方下载地址
百度网盘下载链接:https://pan.baidu.com/s/1q4dhnlX-doxlt13Mi-uFZQ
提取码:2ap3
VOC格式的Foggy_driving数据集百度网盘下载链接:https://pan.baidu.com/s/14bIND62U0wyhXLvUy5nJFQ
提取码:ekrn
将Foggy_driving数据集转换成VOC数据格式的python代码如下:
###Foggy_driving中的gtbox标注为txt格式,现工作需要将目标检测标注转为pascal voc格式的标注格式
###Foggy_driving数据集的图片在leftImg8bit中(且分为了test:pedestrian、public和test_extra:pedestrain、web)
###目标检测的标注在bboxGt中(且分为了test:pedestrian、public和test_extra:pedestrain、web)
####所以需要将bounding_box标注放到同一个文件夹中,方便读取
import os, sys
import glob
from PIL import Image
# 图像存储位置
src_img_dir = "D:/XUEXI/CODES/Detections/DATASET/Foggy_Driving/Foggy_Driving/VOC2007/JPEGImages"
# 图像的 ground truth 的 txt 文件存放位置
src_txt_dir = "D:/XUEXI/CODES/Detections/DATASET/Foggy_Driving/bboxGt"
###生成的xml文件想要保存的位置
src_xml_dir = "D:/XUEXI/CODES/Detections/DATASET/Foggy_Driving/Foggy_Driving/VOC2007/Annotations"
### - `bboxGt`
###the bounding box annotations induced from the above semantic annotations, available for all 101 images of the dataset.
# Annotations are encoded as `txt` files, in which each line corresponds to a single object and is formatted as
# ```
# {class} {xmin} {ymin} {xmax} {ymax}
# ```
# `class` stands for the ID of the class this object belongs to, and the rest four elements encode the extent of
# its bounding box in 1-based integer pixel coordinates. The 8 relevant classes are encoded with the following IDs:
# - *car*: 0
# - *person*: 1
# - *bicycle*: 2
# - *bus*: 3
# - *truck*: 4
# - *train*: 5
# - *motorcycle*: 6
# - *rider*: 7
classes = {
'0': 'car','1': 'person','2'