shuishen
5 days ago fbb068ec702338d609c1ca6eddbdb9f182d8f211
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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()