@@ -430,7 +430,7 @@ class TartanAirFlowCustomizer(TartanAirCustomizer):
430430 def __init__ (self , tartanair_data_root ):
431431 super ().__init__ (tartanair_data_root )
432432
433- def customize_flow (self , env , difficulty = [], trajectory_id = [], cam_sides = [], frame_sep = 1 , num_workers = 1 , device = 'cpu' ):
433+ def customize_flow (self , env , difficulty = [], trajectory_id = [], camera_name = [], frame_sep = 1 , num_workers = 1 , device = 'cpu' ):
434434 ###############################
435435 # Check the input arguments.
436436 ###############################
@@ -449,6 +449,9 @@ def customize_flow(self, env, difficulty = [], trajectory_id = [], cam_sides = [
449449 if not isinstance (trajectory_id , list ):
450450 trajectory_id = [trajectory_id ]
451451
452+ if not self .check_camera_valid (camera_name ):
453+ return False
454+
452455 # Keep track of requested device.
453456 self .device = device
454457
@@ -464,9 +467,9 @@ def customize_flow(self, env, difficulty = [], trajectory_id = [], cam_sides = [
464467 else :
465468 self .data_folders = difficulty
466469
467- # check that all images exists
468- for cam_side in cam_sides :
469- self .check_six_images_exist (env , difficulty , trajectory_id , ['depth' ], raw_side = cam_side )
470+ # # check that all images exists
471+ # for cam_side in cam_sides:
472+ # self.check_six_images_exist(env, difficulty, trajectory_id, ['depth'], raw_side=cam_side)
470473
471474 # Number of processes to used.
472475 self .num_workers = num_workers
@@ -475,7 +478,7 @@ def customize_flow(self, env, difficulty = [], trajectory_id = [], cam_sides = [
475478 # Prepare argument list for the flow resampling workers.
476479 ###############################
477480
478- required_cam_sides = set (cam_sides )
481+ # required_cam_sides = set(cam_sides)
479482
480483 # The path to the directory that has been populated with TartanAir data. Immediately in this directory are environment-named directories.
481484 tartanair_path = self .data_root
@@ -491,10 +494,10 @@ def customize_flow(self, env, difficulty = [], trajectory_id = [], cam_sides = [
491494
492495 traj_path = os .path .join (tartanair_path , env_name , rel_traj_path )
493496
494- for cam_side in cam_sides :
497+ for camname in camera_name :
495498
496499 # Create directory.
497- new_data_dir_path = os .path .join (tartanair_path , env_name , rel_traj_path , f"flow_{ cam_side [ 0 ] } cam_front " )
500+ new_data_dir_path = os .path .join (tartanair_path , env_name , rel_traj_path , f"flow_{ camname } " )
498501 print ("Creating directory" , new_data_dir_path ) # Of form Data_easy/env/P001/image_lcam_custom0
499502
500503 # Does not overwrite older directories if those exist.
@@ -506,22 +509,22 @@ def customize_flow(self, env, difficulty = [], trajectory_id = [], cam_sides = [
506509
507510 # Enumerate the frames.
508511 # For each frame, get number of resampled images. The number of frames is the same for all modalities so just check it for one.
509- files = os .listdir (os .path .join (tartanair_path , env_name , rel_traj_path , f"depth_{ cam_side [ 0 ] } cam_front " ))
512+ files = os .listdir (os .path .join (tartanair_path , env_name , rel_traj_path , f"depth_{ camname } " ))
510513 num_frames = len ([f for f in files if f .endswith (".png" ) and not f .startswith ("." )])
511514
512515 # Now, we will prepare argument lists for the flow resampling workers.
513516 # We enumerate all the pairs with "frame_sep" separation.
514517 frame_pairs = [(frame_ix , frame_ix + frame_sep ) for frame_ix in range (0 , num_frames - frame_sep )]
515518
516519 # read the poses
517- pose_fp = os .path .join (tartanair_path , env_name , rel_traj_path , f"pose_{ cam_side [ 0 ] } cam_front .txt" )
520+ pose_fp = os .path .join (tartanair_path , env_name , rel_traj_path , f"pose_{ camname } .txt" )
518521 poses = np .loadtxt (pose_fp )
519522
520523 job_args = [
521524 {
522525 "source_path" : os .path .join (tartanair_path , env_name , rel_traj_path ),
523526 "output_path" : new_data_dir_path ,
524- "cam_side " : cam_side ,
527+ "cam_name " : camname ,
525528 "cam0" : {
526529 "frame_index" : first_frame_index ,
527530 "pose_raw_ta" : poses [first_frame_index ]
@@ -559,7 +562,7 @@ def sample_flow_worker(self, argslist):
559562
560563 source_path = argslist ["source_path" ]
561564 output_path = argslist ["output_path" ]
562- cam_side = argslist ["cam_side " ]
565+ cam_name = argslist ["cam_name " ]
563566 cam0 = argslist ["cam0" ]
564567 cam1 = argslist ["cam1" ]
565568
@@ -568,7 +571,7 @@ def sample_flow_worker(self, argslist):
568571 for cam_info in [cam0 , cam1 ]:
569572 frame_index = cam_info ["frame_index" ]
570573
571- cam_name = f"{ cam_side [0 ]} cam_front"
574+ # cam_name = f"{cam_side[0]}cam_front"
572575
573576 depth_filepath = os .path .join (source_path , f"depth_{ cam_name } " , f"{ frame_index :06d} _{ cam_name } _depth.png" )
574577
@@ -620,7 +623,7 @@ def sample_flow_worker(self, argslist):
620623 )
621624
622625 # write flow and occlusion to the output path (npz)
623- flow_filepath = os .path .join (output_path , f"{ cam0 ['frame_index' ]:06d} _{ cam1 ['frame_index' ]:06d} _{ cam_side } _flow.npz" )
626+ flow_filepath = os .path .join (output_path , f"{ cam0 ['frame_index' ]:06d} _{ cam1 ['frame_index' ]:06d} _{ cam_name } _flow.npz" )
624627
625628 content = {
626629 "flow_fwd" : views [0 ]["flow" ].cpu ().numpy (),
0 commit comments