in code/python/analysis/dataset_generate_scene_labeling_statistics.py [0:0]
def process_scene(s, args):
global df
scene_name = s["name"]
scene_dir = os.path.join(dataset_scenes_dir, scene_name)
detail_dir = os.path.join(scene_dir, "_detail")
mesh_dir = os.path.join(scene_dir, "_detail", "mesh")
metadata_cameras_csv_file = os.path.join(detail_dir, "metadata_cameras.csv")
df_cameras = pd.read_csv(metadata_cameras_csv_file)
cameras = df_cameras.to_records()
# check if scene has been flagged for exclusion
scene_included_in_dataset = False
for c in cameras:
camera_trajectory_name = scene_name + "_" + c["camera_name"]
scene_type = df_camera_trajectories.loc[camera_trajectory_name]["Scene type"]
if scene_type != "OUTSIDE VIEWING AREA (BAD INITIALIZATION)" and scene_type != "OUTSIDE VIEWING AREA (BAD TRAJECTORY)":
scene_included_in_dataset = True
break
if not scene_included_in_dataset:
print("[HYPERSIM: DATASET_GENERATE_SCENE_LABELING_STATISTICS] No good camera trajectories for scene " + scene_name + ", setting scene_included_in_dataset to False...")
log_file = os.path.join(mesh_dir, "metadata_scene_annotation_tool.log")
if os.path.exists(log_file):
with open(log_file, "r") as f:
lines = f.readlines()
num_lines = len(lines)
loaded_prefix_str = "[HYPERSIM: SCENE_ANNOTATION_TOOL] Loaded scene: "
unloaded_prefix_str = "[HYPERSIM: SCENE_ANNOTATION_TOOL] Unloaded scene: "
labeling_time_seconds = 0.0
loaded_line = ""
unloaded_line = ""
for l in lines:
assert loaded_prefix_str in l or unloaded_prefix_str in l
if loaded_prefix_str in l:
loaded_line = l
elif unloaded_prefix_str in l:
unloaded_line = l
if loaded_prefix_str in loaded_line:
loaded_time_str = loaded_line[len(loaded_prefix_str):].strip()
unloaded_time_str = unloaded_line[len(unloaded_prefix_str):].strip()
loaded_time = datetime.datetime.strptime(loaded_time_str, "%a %b %d %H:%M:%S %Y")
unloaded_time = datetime.datetime.strptime(unloaded_time_str, "%a %b %d %H:%M:%S %Y")
labeling_time_seconds += (unloaded_time - loaded_time).total_seconds()
loaded_line = ""
unloaded_line = ""
else:
print("[HYPERSIM: DATASET_GENERATE_SCENE_LABELING_STATISTICS] WARNING: ENCOUNTERED UNLOAD TIME WITHOUT CORRESPONDING LOAD TIME...")
else:
print("[HYPERSIM: DATASET_GENERATE_SCENE_LABELING_STATISTICS] WARNING: UNEXPECTED LINE: " + l)
df_curr = pd.DataFrame(columns=df_columns, data={"scene_name":[scene_name], "labeling_time_seconds":[labeling_time_seconds], "scene_included_in_dataset":[scene_included_in_dataset]})
df = df.append(df_curr, ignore_index=True)
labeling_time_minutes = labeling_time_seconds/60.0
print("[HYPERSIM: DATASET_GENERATE_SCENE_LABELING_STATISTICS] " + scene_name + " (labeling time minutes = " + str(labeling_time_minutes) + ")")
else:
print("[HYPERSIM: DATASET_GENERATE_SCENE_LABELING_STATISTICS] WARNING: LOG FILE DOESN'T EXIST FOR SCENE: " + scene_name)