Skip to content

Commit fa3bf88

Browse files
author
萧研
committed
fix the orientation issue in script/dair2kitti.py
1 parent f1b239f commit fa3bf88

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

scripts/data_converter/gen_kitti/label_json2kitti.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import numpy as np
23
from .utils import mkdir_p, read_json, get_files_path
34

45

@@ -16,10 +17,10 @@ def write_kitti_in_txt(my_json, path_txt):
1617
str(item["2d_box"]["ymax"]),
1718
)
1819
# i9, i10, i11 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["w"]), str(item["3d_dimensions"]["l"])
19-
i9, i11, i10 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["w"]), str(item["3d_dimensions"]["l"])
20+
i9, i11, i10 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["l"]), str(item["3d_dimensions"]["w"])
2021
i12, i13, i14 = str(item["3d_location"]["x"]), str(item["3d_location"]["y"]), str(item["3d_location"]["z"])
2122
# i15 = str(item["rotation"])
22-
i15 = str(-eval(item["rotation"]))
23+
i15 = str(-0.5 * np.pi - float(item["rotation"]))
2324
item_list = [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15]
2425
item_string = " ".join(item_list) + "\n"
2526
wf.write(item_string)

scripts/data_converter/visual_tools.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ def kitti_visual_tool(data_root, demo_dir):
1717
for image_file in os.listdir(image_path):
1818
image_ids.append(image_file.split(".")[0])
1919
for i in range(len(image_ids)):
20-
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".png")
20+
if os.path.exists(os.path.join(image_path, str(image_ids[i]) + ".png")):
21+
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".png")
22+
elif os.path.exists(os.path.join(image_path, str(image_ids[i]) + ".jpg")):
23+
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".jpg")
24+
else:
25+
print("Error: image file not found.")
2126
calib_file = os.path.join(calib_path, str(image_ids[i]) + ".txt")
2227
label_2_file = os.path.join(label_path, str(image_ids[i]) + ".txt")
2328
image = cv2.imread(image_2_file)

scripts/data_converter/visual_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def draw_3d_box_on_image(image, label_2_file, P2, denorm, c=(0, 255, 0)):
9292
for line in f.readlines():
9393
line_list = line.split('\n')[0].split(' ')
9494
object_type = line_list[0]
95+
if object_type not in color_map.keys(): continue
9596
dim = np.array(line_list[8:11]).astype(float)
9697
location = np.array(line_list[11:14]).astype(float)
9798
rotation_y = float(line_list[14])

0 commit comments

Comments
 (0)