diff --git a/scripts/data_converter/gen_kitti/label_json2kitti.py b/scripts/data_converter/gen_kitti/label_json2kitti.py index 2e578de..32516af 100644 --- a/scripts/data_converter/gen_kitti/label_json2kitti.py +++ b/scripts/data_converter/gen_kitti/label_json2kitti.py @@ -1,4 +1,5 @@ import os +import numpy as np from .utils import mkdir_p, read_json, get_files_path @@ -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) diff --git a/scripts/data_converter/visual_tools.py b/scripts/data_converter/visual_tools.py index 3a0d586..ff30406 100644 --- a/scripts/data_converter/visual_tools.py +++ b/scripts/data_converter/visual_tools.py @@ -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) diff --git a/scripts/data_converter/visual_utils.py b/scripts/data_converter/visual_utils.py index f02ac42..c9ad850 100644 --- a/scripts/data_converter/visual_utils.py +++ b/scripts/data_converter/visual_utils.py @@ -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])