hank1996 commited on
Commit
87afa85
·
1 Parent(s): 1b25981

Create new file

Browse files
Files changed (1) hide show
  1. lib/dataset/convert.py +31 -0
lib/dataset/convert.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bdd_labels = {
2
+ # 'unlabeled':0, 'dynamic': 1, 'ego vehicle': 2, 'ground': 3,
3
+ # 'static': 4, 'parking': 5, 'rail track': 6, 'road': 7,
4
+ # 'sidewalk': 8, 'bridge': 9, 'building': 10, 'fence': 11,
5
+ # 'garage': 12, 'guard rail': 13, 'tunnel': 14, 'wall': 15,
6
+ # 'banner': 16, 'billboard': 17, 'lane divider': 18,'parking sign': 19,
7
+ # 'pole': 20, 'polegroup': 21, 'street light': 22, 'traffic cone': 23,
8
+ # 'traffic device': 24, 'traffic light': 25, 'traffic sign': 26, 'traffic sign frame': 27,
9
+ # 'terrain': 28, 'vegetation': 29, 'sky': 30, 'person': 31,
10
+ # 'rider': 32, 'bicycle': 33, 'bus': 34, 'car': 35,
11
+ # 'caravan': 36, 'motorcycle': 37, 'trailer': 38, 'train': 39,
12
+ # 'truck': 40
13
+ # }
14
+ id_dict = {'person': 0, 'rider': 1, 'car': 2, 'bus': 3, 'truck': 4,
15
+ 'bike': 5, 'motor': 6, 'tl_green': 7, 'tl_red': 8,
16
+ 'tl_yellow': 9, 'tl_none': 10, 'traffic sign': 11, 'train': 12}
17
+ id_dict_single = {'car': 0, 'bus': 1, 'truck': 2,'train': 3}
18
+ # id_dict = {'car': 0, 'bus': 1, 'truck': 2}
19
+
20
+ def convert(size, box):
21
+ dw = 1./(size[0])
22
+ dh = 1./(size[1])
23
+ x = (box[0] + box[1])/2.0
24
+ y = (box[2] + box[3])/2.0
25
+ w = box[1] - box[0]
26
+ h = box[3] - box[2]
27
+ x = x*dw
28
+ w = w*dw
29
+ y = y*dh
30
+ h = h*dh
31
+ return (x,y,w,h)