mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 15:28:49 +08:00
Fix the issue with missing images in the Reality Capture data. (#1285)
* Fix issue with missing images in Reality Capture data * remove comment Co-authored-by: Dmytro Korolov <dmytro.korolov@gmail.com>
This commit is contained in:
1 parent
828d6bc893
commit
80ae933811
1 file changed
+18
-2
@@ -32,6 +32,7 @@ def realitycapture_to_json(
|
|||||||
image_filename_map: List[Path],
|
image_filename_map: List[Path],
|
||||||
csv_filename: Path,
|
csv_filename: Path,
|
||||||
output_dir: Path,
|
output_dir: Path,
|
||||||
|
verbose: bool = False,
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""Convert RealityCapture data into a nerfstudio dataset.
|
"""Convert RealityCapture data into a nerfstudio dataset.
|
||||||
|
|
||||||
@@ -58,15 +59,28 @@ def realitycapture_to_json(
|
|||||||
for column, value in row.items():
|
for column, value in row.items():
|
||||||
cameras.setdefault(column, []).append(value)
|
cameras.setdefault(column, []).append(value)
|
||||||
|
|
||||||
img = np.array(Image.open(output_dir / image_filename_map[cameras["#name"][0].split(".")[0]]))
|
for name in cameras["#name"]:
|
||||||
|
camera_label = name.split(".")[0]
|
||||||
|
if camera_label in image_filename_map:
|
||||||
|
img = np.array(Image.open(output_dir / image_filename_map[camera_label]))
|
||||||
|
break
|
||||||
|
|
||||||
height, width, _ = img.shape
|
height, width, _ = img.shape
|
||||||
|
|
||||||
data["h"] = int(height)
|
data["h"] = int(height)
|
||||||
data["w"] = int(width)
|
data["w"] = int(width)
|
||||||
|
|
||||||
|
missing_image_data = 0
|
||||||
|
|
||||||
for i, name in enumerate(cameras["#name"]):
|
for i, name in enumerate(cameras["#name"]):
|
||||||
|
basename = name.split(".")[0]
|
||||||
|
if basename not in image_filename_map:
|
||||||
|
if verbose:
|
||||||
|
CONSOLE.print(f"Missing image for camera data {basename}, Skipping")
|
||||||
|
missing_image_data += 1
|
||||||
|
continue
|
||||||
frame = {}
|
frame = {}
|
||||||
frame["file_path"] = image_filename_map[name.split(".")[0]].as_posix()
|
frame["file_path"] = image_filename_map[basename].as_posix()
|
||||||
frame["fl_x"] = float(cameras["f"][i]) * max(width, height) / 36
|
frame["fl_x"] = float(cameras["f"][i]) * max(width, height) / 36
|
||||||
frame["fl_y"] = float(cameras["f"][i]) * max(width, height) / 36
|
frame["fl_y"] = float(cameras["f"][i]) * max(width, height) / 36
|
||||||
# TODO: Unclear how to get the principal point from RealityCapture, here a guess...
|
# TODO: Unclear how to get the principal point from RealityCapture, here a guess...
|
||||||
@@ -95,6 +109,8 @@ def realitycapture_to_json(
|
|||||||
json.dump(data, f, indent=4)
|
json.dump(data, f, indent=4)
|
||||||
|
|
||||||
summary = []
|
summary = []
|
||||||
|
if missing_image_data > 0:
|
||||||
|
summary.append(f"Missing image data for {missing_image_data} cameras.")
|
||||||
if len(frames) < len(image_filename_map):
|
if len(frames) < len(image_filename_map):
|
||||||
summary.append(f"Missing camera data for {len(image_filename_map) - len(frames)} frames.")
|
summary.append(f"Missing camera data for {len(image_filename_map) - len(frames)} frames.")
|
||||||
summary.append(f"Final dataset is {len(frames)} frames.")
|
summary.append(f"Final dataset is {len(frames)} frames.")
|
||||||
|
|||||||
Reference in new issue
Block a user