Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle uncalibrated Metashape sensor #1359

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions nerfstudio/process_data/metashape_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ def metashape_to_json( # pylint: disable=too-many-statements
sensors = chunk.find("sensors")

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

calibrated_sensors = [sensor for sensor in sensors if sensor.find("calibration")]
if len(calibrated_sensors) != 1:
raise ValueError("Only one sensor is supported for now")

sensor = sensors.find("sensor")
sensor = calibrated_sensors[0]

data = {}

Expand Down Expand Up @@ -98,6 +102,14 @@ def metashape_to_json( # pylint: disable=too-many-statements
if camera_label not in image_filename_map:
continue
frame["file_path"] = image_filename_map[camera_label].as_posix()

if camera.get("sensor_id") != sensor.get("id"):
# this should only happen when we have a sensor that doesn't have calibration
if verbose:
CONSOLE.print(f"Missing sensor calibration for {camera.get('label')}, Skipping")
num_skipped += 1
continue

if camera.find("transform") is None:
if verbose:
CONSOLE.print(f"Missing transforms data for {camera.get('label')}, Skipping")
Expand Down