from __future__ import annotations
|
|
import tempfile
|
import unittest
|
from pathlib import Path
|
|
from PIL import Image
|
|
import sys
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
from run_photo_reconstruction import collect_images, reconstruct_photos, validate_camera_configuration, validate_matching_configuration # noqa: E402
|
|
|
class PhotoReconstructionTests(unittest.TestCase):
|
def test_collect_images_requires_two_jpegs(self) -> None:
|
with tempfile.TemporaryDirectory() as directory:
|
root = Path(directory)
|
Image.new("RGB", (32, 32), "white").save(root / "one.jpg")
|
with self.assertRaises(ValueError):
|
collect_images(root)
|
Image.new("RGB", (32, 32), "black").save(root / "two.jpeg")
|
self.assertEqual([item.name for item in collect_images(root)], ["one.jpg", "two.jpeg"])
|
|
def test_invalid_processing_limits_fail_before_sfm(self) -> None:
|
with tempfile.TemporaryDirectory() as directory:
|
root = Path(directory)
|
Image.new("RGB", (32, 32), "white").save(root / "one.jpg")
|
Image.new("RGB", (32, 32), "black").save(root / "two.jpg")
|
with self.assertRaises(ValueError):
|
reconstruct_photos(root, root / "result", max_image_size=320)
|
|
def test_matching_configuration_rejects_unknown_or_empty_pairing(self) -> None:
|
with self.assertRaises(ValueError):
|
validate_matching_configuration("unsupported", 4)
|
with self.assertRaises(ValueError):
|
validate_matching_configuration("spatial", 0)
|
|
def test_opencv_camera_model_rejects_simple_radial_focal_override(self) -> None:
|
with self.assertRaises(ValueError):
|
validate_camera_configuration("OPENCV", 2795.0)
|
|
|
if __name__ == "__main__":
|
unittest.main()
|