From 1af71f2fffddf68180d03921ba1f50463118a47e Mon Sep 17 00:00:00 2001 From: Tamir Cohen <41875509+TamirCohen@users.noreply.github.com> Date: Fri, 28 Jun 2024 22:50:35 +0300 Subject: [PATCH] Fix parsing of non ascii image names in colmap's images.bin (#3256) Co-authored-by: Justin Kerr --- nerfstudio/data/utils/colmap_parsing_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nerfstudio/data/utils/colmap_parsing_utils.py b/nerfstudio/data/utils/colmap_parsing_utils.py index 818798ec8..0eeaf6911 100644 --- a/nerfstudio/data/utils/colmap_parsing_utils.py +++ b/nerfstudio/data/utils/colmap_parsing_utils.py @@ -235,11 +235,12 @@ def read_images_binary(path_to_model_file): qvec = np.array(binary_image_properties[1:5]) tvec = np.array(binary_image_properties[5:8]) camera_id = binary_image_properties[8] - image_name = "" + image_name = b"" current_char = read_next_bytes(fid, 1, "c")[0] while current_char != b"\x00": # look for the ASCII 0 entry - image_name += current_char.decode("utf-8") + image_name += current_char current_char = read_next_bytes(fid, 1, "c")[0] + image_name = image_name.decode("utf-8") num_points2D = read_next_bytes(fid, num_bytes=8, format_char_sequence="Q")[0] x_y_id_s = read_next_bytes(fid, num_bytes=24 * num_points2D, format_char_sequence="ddq" * num_points2D) xys = np.column_stack([tuple(map(float, x_y_id_s[0::3])), tuple(map(float, x_y_id_s[1::3]))])