mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
metashape_utils: work with camera groups (#2626)
* 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 <f-dy@users.noreply.github.com> Co-authored-by: J.Y <132313008+jb-ye@users.noreply.github.com>
This commit is contained in:
1 file changed
+5
-4
@@ -55,12 +55,11 @@ def metashape_to_json(
|
|||||||
chunk = root[0]
|
chunk = root[0]
|
||||||
sensors = chunk.find("sensors")
|
sensors = chunk.find("sensors")
|
||||||
|
|
||||||
# TODO Add support for per-frame intrinsics
|
|
||||||
if sensors is None:
|
if sensors is None:
|
||||||
raise ValueError("No sensors found")
|
raise ValueError("No sensors found")
|
||||||
|
|
||||||
calibrated_sensors = [
|
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:
|
if not calibrated_sensors:
|
||||||
raise ValueError("No calibrated sensor found in Metashape XML")
|
raise ValueError("No calibrated sensor found in Metashape XML")
|
||||||
@@ -116,7 +115,7 @@ def metashape_to_json(
|
|||||||
components = chunk.find("components")
|
components = chunk.find("components")
|
||||||
component_dict = {}
|
component_dict = {}
|
||||||
if components is not None:
|
if components is not None:
|
||||||
for component in components:
|
for component in components.iter("component"):
|
||||||
transform = component.find("transform")
|
transform = component.find("transform")
|
||||||
if transform is not None:
|
if transform is not None:
|
||||||
rotation = transform.find("rotation")
|
rotation = transform.find("rotation")
|
||||||
@@ -147,7 +146,7 @@ def metashape_to_json(
|
|||||||
cameras = chunk.find("cameras")
|
cameras = chunk.find("cameras")
|
||||||
assert cameras is not None, "Cameras not found in Metashape xml"
|
assert cameras is not None, "Cameras not found in Metashape xml"
|
||||||
num_skipped = 0
|
num_skipped = 0
|
||||||
for camera in cameras:
|
for camera in cameras.iter("camera"):
|
||||||
frame = {}
|
frame = {}
|
||||||
camera_label = camera.get("label")
|
camera_label = camera.get("label")
|
||||||
assert isinstance(camera_label, str)
|
assert isinstance(camera_label, str)
|
||||||
@@ -156,6 +155,8 @@ def metashape_to_json(
|
|||||||
# (maybe it's just a '.' in the image name)
|
# (maybe it's just a '.' in the image name)
|
||||||
camera_label = camera_label.split(".")[0] # type: ignore
|
camera_label = camera_label.split(".")[0] # type: ignore
|
||||||
if camera_label not in image_filename_map:
|
if camera_label not in image_filename_map:
|
||||||
|
if verbose:
|
||||||
|
CONSOLE.print(f"Missing image for {camera.get('label')}, Skipping")
|
||||||
continue
|
continue
|
||||||
frame["file_path"] = image_filename_map[camera_label].as_posix()
|
frame["file_path"] = image_filename_map[camera_label].as_posix()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user