Skip to content

Commit

Permalink
metashape_utils: work with camera groups (nerfstudio-project#2626)
Browse files Browse the repository at this point in the history
* metashape_utils: work with camera groups

* metashape_utils: console message when skipping a camera due to a missing image

---------

Co-authored-by: Frédéric Devernay <[email protected]>
Co-authored-by: J.Y <[email protected]>
  • Loading branch information
3 people authored Apr 30, 2024
1 parent 759fda8 commit e232227
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nerfstudio/process_data/metashape_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ def metashape_to_json(
chunk = root[0]
sensors = chunk.find("sensors")

# TODO Add support for per-frame intrinsics
if sensors is None:
raise ValueError("No sensors found")

calibrated_sensors = [
sensor for sensor in sensors if sensor.get("type") == "spherical" or sensor.find("calibration")
sensor for sensor in sensors.iter("sensor") if sensor.get("type") == "spherical" or sensor.find("calibration")
]
if not calibrated_sensors:
raise ValueError("No calibrated sensor found in Metashape XML")
Expand Down Expand Up @@ -116,7 +115,7 @@ def metashape_to_json(
components = chunk.find("components")
component_dict = {}
if components is not None:
for component in components:
for component in components.iter("component"):
transform = component.find("transform")
if transform is not None:
rotation = transform.find("rotation")
Expand Down Expand Up @@ -147,7 +146,7 @@ def metashape_to_json(
cameras = chunk.find("cameras")
assert cameras is not None, "Cameras not found in Metashape xml"
num_skipped = 0
for camera in cameras:
for camera in cameras.iter("camera"):
frame = {}
camera_label = camera.get("label")
assert isinstance(camera_label, str)
Expand All @@ -156,6 +155,8 @@ def metashape_to_json(
# (maybe it's just a '.' in the image name)
camera_label = camera_label.split(".")[0] # type: ignore
if camera_label not in image_filename_map:
if verbose:
CONSOLE.print(f"Missing image for {camera.get('label')}, Skipping")
continue
frame["file_path"] = image_filename_map[camera_label].as_posix()

Expand Down

0 comments on commit e232227

Please sign in to comment.