diff --git a/code/python/tools/dataset_generate_hdf5_from_vrimg.py b/code/python/tools/dataset_generate_hdf5_from_vrimg.py index 252e857..856f17b 100644 --- a/code/python/tools/dataset_generate_hdf5_from_vrimg.py +++ b/code/python/tools/dataset_generate_hdf5_from_vrimg.py @@ -19,6 +19,7 @@ parser.add_argument("--dataset_dir", required=True) parser.add_argument("--scene_names") parser.add_argument("--camera_names") +parser.add_argument("--frames") parser.add_argument("--render_pass") parser.add_argument("--n_jobs", type=int) parser.add_argument("--denoise", action="store_true") @@ -85,7 +86,11 @@ def process_scene(s, args): if args.render_pass is None or args.render_pass == "geometry": - in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_geometry", "*.vrimg")) + '"' + if args.frames is not None: + in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_geometry", "frame." + args.frames + ".vrimg")) + '"' + else: + in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_geometry", "frame.*.vrimg")) + '"' + in_camera_trajectory_dir = os.path.abspath(os.path.join(detail_dir, camera_name)) in_metadata_nodes_file = os.path.abspath(os.path.join(detail_dir, "metadata_nodes.csv")) in_metadata_scene_file = os.path.abspath(os.path.join(detail_dir, "metadata_scene.csv")) @@ -121,7 +126,11 @@ def process_scene(s, args): if args.render_pass is None or args.render_pass == "final": - in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_final", "*.vrimg")) + '"' + if args.frames is not None: + in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_final", "frame." + args.frames + ".vrimg")) + '"' + else: + in_vrimg_files = '"' + os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_final", "frame.*.vrimg")) + '"' + out_hdf5_dir = os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_final_hdf5")) out_preview_dir = os.path.abspath(os.path.join(images_dir, in_scene_fileroot + "_" + camera_name + "_final_preview")) tmp_dir_ = os.path.abspath(tmp_dir) diff --git a/code/python/tools/generate_hdf5_from_vrimg.py b/code/python/tools/generate_hdf5_from_vrimg.py index 86069cd..edb90ab 100644 --- a/code/python/tools/generate_hdf5_from_vrimg.py +++ b/code/python/tools/generate_hdf5_from_vrimg.py @@ -328,14 +328,26 @@ with h5py.File(out_normal_bump_cam_hdf5_file, "w") as f: f.create_dataset("dataset", data=normal_bump_cam.astype(float16), compression="gzip", compression_opts=9) with h5py.File(out_tex_coord_hdf5_file, "w") as f: f.create_dataset("dataset", data=tex_coord.astype(float16), compression="gzip", compression_opts=9) + eps = 0.000001 # amount of numerical slack when checking if normal images are in the range [0,1] + assert all(np.min(normal_world_.reshape(-1,3), axis=0)) > 0.0 - eps + assert all(np.min(normal_cam_.reshape(-1,3), axis=0)) > 0.0 - eps + assert all(np.min(normal_bump_world_.reshape(-1,3), axis=0)) > 0.0 - eps + assert all(np.min(normal_bump_cam_.reshape(-1,3), axis=0)) > 0.0 - eps + assert all(np.max(normal_world_.reshape(-1,3), axis=0)) < 1.0 + eps + assert all(np.max(normal_cam_.reshape(-1,3), axis=0)) < 1.0 + eps + assert all(np.max(normal_bump_world_.reshape(-1,3), axis=0)) < 1.0 + eps + assert all(np.max(normal_bump_cam_.reshape(-1,3), axis=0)) < 1.0 + eps + + # ideally we would normalize depth consistently for each scene, but we don't know a good depth range, so don't try to normalize + # normals are already unit-length, but due to occasional numerical artifacts we need to clip anyway imsave(out_color_jpg_file, clip(rgb_color,0,1)) imsave(out_gamma_jpg_file, clip(rgb_color_gamma,0,1)) imsave(out_render_entity_id_png_file, render_entity_id_, vmin=np.min(color_vals_unique), vmax=np.max(color_vals_unique)) - imsave(out_depth_meters_png_file, depth_meters) # ideally we would normalize depth consistently for each scene, but we don't know a good depth range, so don't try to normalize - imsave(out_normal_world_png_file, normal_world_) # normals are already unit-length so don't need to normalize - imsave(out_normal_cam_png_file, normal_cam_) # normals are already unit-length so don't need to normalize - imsave(out_normal_bump_world_png_file, normal_bump_world_) # normals are already unit-length so don't need to normalize - imsave(out_normal_bump_cam_png_file, normal_bump_cam_) # normals are already unit-length so don't need to normalize + imsave(out_depth_meters_png_file, depth_meters) + imsave(out_normal_world_png_file, clip(normal_world_,0,1)) + imsave(out_normal_cam_png_file, clip(normal_cam_,0,1)) + imsave(out_normal_bump_world_png_file, clip(normal_bump_world_,0,1)) + imsave(out_normal_bump_cam_png_file, clip(normal_bump_cam_,0,1)) imsave(out_tex_coord_png_file, clip(tex_coord,0,1)) if args.render_pass == "final":