Skip to content

Commit

Permalink
fix the orientation issue in script/dair2kitti.py
Browse files Browse the repository at this point in the history
  • Loading branch information
萧研 committed Apr 11, 2023
1 parent f1b239f commit fa3bf88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scripts/data_converter/gen_kitti/label_json2kitti.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import numpy as np
from .utils import mkdir_p, read_json, get_files_path


Expand All @@ -16,10 +17,10 @@ def write_kitti_in_txt(my_json, path_txt):
str(item["2d_box"]["ymax"]),
)
# i9, i10, i11 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["w"]), str(item["3d_dimensions"]["l"])
i9, i11, i10 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["w"]), str(item["3d_dimensions"]["l"])
i9, i11, i10 = str(item["3d_dimensions"]["h"]), str(item["3d_dimensions"]["l"]), str(item["3d_dimensions"]["w"])
i12, i13, i14 = str(item["3d_location"]["x"]), str(item["3d_location"]["y"]), str(item["3d_location"]["z"])
# i15 = str(item["rotation"])
i15 = str(-eval(item["rotation"]))
i15 = str(-0.5 * np.pi - float(item["rotation"]))
item_list = [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15]
item_string = " ".join(item_list) + "\n"
wf.write(item_string)
Expand Down
7 changes: 6 additions & 1 deletion scripts/data_converter/visual_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ def kitti_visual_tool(data_root, demo_dir):
for image_file in os.listdir(image_path):
image_ids.append(image_file.split(".")[0])
for i in range(len(image_ids)):
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".png")
if os.path.exists(os.path.join(image_path, str(image_ids[i]) + ".png")):
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".png")
elif os.path.exists(os.path.join(image_path, str(image_ids[i]) + ".jpg")):
image_2_file = os.path.join(image_path, str(image_ids[i]) + ".jpg")
else:
print("Error: image file not found.")
calib_file = os.path.join(calib_path, str(image_ids[i]) + ".txt")
label_2_file = os.path.join(label_path, str(image_ids[i]) + ".txt")
image = cv2.imread(image_2_file)
Expand Down
1 change: 1 addition & 0 deletions scripts/data_converter/visual_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def draw_3d_box_on_image(image, label_2_file, P2, denorm, c=(0, 255, 0)):
for line in f.readlines():
line_list = line.split('\n')[0].split(' ')
object_type = line_list[0]
if object_type not in color_map.keys(): continue
dim = np.array(line_list[8:11]).astype(float)
location = np.array(line_list[11:14]).astype(float)
rotation_y = float(line_list[14])
Expand Down

0 comments on commit fa3bf88

Please sign in to comment.