diff --git a/main.py b/main.py index 61b0e12ef3bed25d081c545d20979a1e483fd018..9684bb75465b755337541a099157cae7031e8ef3 100644 --- a/main.py +++ b/main.py @@ -53,7 +53,7 @@ if __name__ == '__main__': dataset_name = f"GUIMOD_{choice}" list_categories = ["banana1", "kiwi1", "pear2", "strawberry1", "apricot", "orange2", "peach1", "lemon2", "apple2" ] # frame = "1_600000000" - frame = "1_926000000" + #frame = "1_926000000" Nb_camera = 15 #Nb_world = 2 @@ -85,9 +85,9 @@ if __name__ == '__main__': np.savetxt(f'{dataset_name}/Generated/camera_{choice}.txt', camera) - reform_data(dataset_src, dataset_name, dataset_type, frame, Nb_camera, args.World_begin, args.Nb_worlds) + reform_data(dataset_src, dataset_name, dataset_type, Nb_camera, args.World_begin, args.Nb_worlds) - process_compute(dataset_name, camera, Nb_camera, args.World_begin, args.Nb_worlds, list_categories, occ_target, True) + process_compute(dataset_name, camera, Nb_camera, args.World_begin, args.Nb_worlds, list_categories, occ_target, False) #transform_pose(dataset_name, Nb_camera, Nb_world, list_categories, occ_target) #generate_2d_bbox(dataset_name, Nb_camera, Nb_world, list_categories, occ_target) #generate_instance_mask(dataset_name, Nb_camera, Nb_world, list_categories, occ_target) diff --git a/prepare_data.py b/prepare_data.py index 667436fa8a14bc4031376a593bef7679e2188f93..1641a783bd38f9426a17350c5f62cd2c6f1fca67 100644 --- a/prepare_data.py +++ b/prepare_data.py @@ -1,7 +1,7 @@ import shutil +import os - -def reform_data(src, data_name, data_option, frame, Nb_camera, World_begin, Nb_world): +def reform_data(src, data_name, data_option, Nb_camera, World_begin, Nb_world): for i in range(World_begin, World_begin + Nb_world): # worlds src_meta = f"{src}/{i}/meta.json" dst_meta = f"{data_name}/Meta/{i}.json" @@ -9,38 +9,47 @@ def reform_data(src, data_name, data_option, frame, Nb_camera, World_begin, Nb_w for j in range(1, Nb_camera+1): # cameras count = ((i-1)*Nb_camera) + j if data_option == "ground_truth_rgb": - src_img = f"{src}/{i}/grabber_{j}/color/image/{frame}.png" + files_img = os.listdir(f"{src}/{i}/grabber_{j}/color/image/") + src_img = f"{src}/{i}/grabber_{j}/color/image/{files_img[0]}" dst_img = f"{data_name}/RGB/{count}.png" else: - src_img = f"{src}/{i}/grabber_{j}/depth/image/{frame}.png" + files_img = os.listdir(f"{src}/{i}/grabber_{j}/depth/image/") + src_img = f"{src}/{i}/grabber_{j}/depth/image/{files_img[0]}" dst_img = f"{data_name}/RGB/{count}.png" shutil.copy(src_img, dst_img) - src_id = f"{src}/{i}/grabber_{j}/{data_option}/id_map/{frame}.png" + files_id = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/id_map/") + src_id = f"{src}/{i}/grabber_{j}/{data_option}/id_map/{files_id[0]}" dst_id = f"{data_name}/Instance_Segmentation/{count}.png" shutil.copy(src_id, dst_id) - src_semantic = f"{src}/{i}/grabber_{j}/{data_option}/semantic_map/{frame}.png" + files_semantic = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/semantic_map/") + src_semantic = f"{src}/{i}/grabber_{j}/{data_option}/semantic_map/{files_semantic[0]}" dst_semantic = f"{data_name}/Semantic_Segmentation/{count}.png" shutil.copy(src_semantic, dst_semantic) - src_path_pose = f"{src}/{i}/grabber_{j}/{data_option}/3d_pose/{frame}.json" + files_pose = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/3d_pose/") + src_path_pose = f"{src}/{i}/grabber_{j}/{data_option}/3d_pose/{files_pose[0]}" dst_path_pose = f"{data_name}/Pose/{count}.json" shutil.copy(src_path_pose, dst_path_pose) - src_path_occlusion = f"{src}/{i}/grabber_{j}/{data_option}/occlusion/{frame}.json" + files_occlusion = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/occlusion/") + src_path_occlusion = f"{src}/{i}/grabber_{j}/{data_option}/occlusion/{files_occlusion[0]}" dst_path_occlusion = f"{data_name}/Occlusion/{count}.json" shutil.copy(src_path_occlusion, dst_path_occlusion) - src_depth = f"{src}/{i}/grabber_{j}/depth/depth_map/{frame}.tiff" + files_depth = os.listdir(f"{src}/{i}/grabber_{j}/depth/depth_map/") + src_depth = f"{src}/{i}/grabber_{j}/depth/depth_map/{files_depth[0]}" dst_depth = f"{data_name}/Depth/{count}.tiff" shutil.copy(src_depth, dst_depth) - src_bbox = f"{src}/{i}/grabber_{j}/{data_option}/2d_detection/{frame}.json" + files_bbox = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/2d_detection//") + src_bbox = f"{src}/{i}/grabber_{j}/{data_option}/2d_detection/{files_bbox[0]}" dst_bbox = f"{data_name}/Bbox_2d/{count}.json" shutil.copy(src_bbox, dst_bbox) - src_bbox_loose = f"{src}/{i}/grabber_{j}/{data_option}/2d_detection_loose/{frame}.json" + files_bbox_loose = os.listdir(f"{src}/{i}/grabber_{j}/{data_option}/2d_detection_loose/") + src_bbox_loose = f"{src}/{i}/grabber_{j}/{data_option}/2d_detection_loose/{files_bbox_loose[0]}" dst_bbox_loose = f"{data_name}/Bbox_2d_loose/{count}.json" shutil.copy(src_bbox_loose, dst_bbox_loose)