Add new functionality for image rectification and depth metadata handling

- Implemented a preview tool for rectifying images with interactive aspect controls in `preview.py`.
- Added tests for depth metadata loading to ensure consistent schema usage in `test_depth_metadata.py`.
- Developed comprehensive tests for cutout calibration processes in `test_cutout_calibration.py`, including stability checks and depth calibration.
- Created tests for frame compositing operations in `test_frame_compositing.py`, ensuring correct handling of depth and transparency.
- Introduced material slot inheritance functionality in `material_slots.py` to manage geometry material assignments.
- Built shared shader nodes for material processing in `shader.py`, including roughness and bump mapping setups.
This commit is contained in:
2026-09-12 19:20:06 +08:00
parent e8268504c2
commit 938d95db0f
175 changed files with 3812 additions and 6864 deletions

View File

@@ -84,7 +84,7 @@ class RectifyToolTest(BlenderTestCase):
colorspace_settings=SimpleNamespace(name="Non-Color"),
)
try:
result = self.rectify.create_perspective_preview_image(
result = self.rectify_preview.create_perspective_preview_image(
source, pixels
)
finally:
@@ -99,10 +99,10 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_preview_skips_cursor_at_last_clicked_point(self):
points = ((10.0, 10.0), (80.0, 10.0), (70.0, 60.0))
stationary = self.rectify.interactive_preview_polygon(
stationary = self.rectify_preview.interactive_preview_polygon(
points, points[-1]
)
moving = self.rectify.interactive_preview_polygon(
moving = self.rectify_preview.interactive_preview_polygon(
points, (20.0, 70.0)
)
@@ -111,7 +111,7 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_draws_scene_linear_texture_as_srgb_in_blender_5(self):
draw_options = self.rectify.preview_texture_draw_options
draw_options = self.rectify_preview.preview_texture_draw_options
self.assertEqual(draw_options((4, 5, 3)), {})
self.assertEqual(
@@ -126,7 +126,7 @@ class RectifyToolTest(BlenderTestCase):
top_down = np.zeros((4, 4, 4), dtype=np.float32)
top_down[1:3, 1:3] = (0.2, 0.4, 0.6, 1.0)
pixels, output_size, placement_bounds = (
self.rectify.extract_perspective_pixels(
self.rectify_geometry.extract_perspective_pixels(
np.flipud(top_down).ravel(),
(4, 4),
((0, 0), (4, 0), (4, 4), (0, 4)),
@@ -142,7 +142,7 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_rejects_non_convex_corners(self):
with self.assertRaisesRegex(ValueError, "convex"):
self.rectify.validate_perspective_quad(
self.rectify_geometry.validate_perspective_quad(
((0, 0), (10, 0), (4, 4), (0, 10))
)
@@ -153,16 +153,16 @@ class RectifyToolTest(BlenderTestCase):
import numpy as np
corners = ((10, 20), (80, 15), (90, 70), (5, 75))
ordered = self.rectify.canonical_perspective_quad(corners)
ordered = self.rectify_geometry.canonical_perspective_quad(corners)
for permutation in itertools.permutations(corners):
np.testing.assert_allclose(
self.rectify.canonical_perspective_quad(permutation),
self.rectify_geometry.canonical_perspective_quad(permutation),
ordered,
)
def test_rectify_detects_source_image_overlap(self):
overlaps = self.rectify.perspective_quad_overlaps_image
overlaps = self.rectify_geometry.perspective_quad_overlaps_image
self.assertFalse(overlaps(((20, 20), (30, 20), (30, 30), (20, 30)), (10, 10)))
self.assertTrue(overlaps(((5, 5), (15, 5), (15, 15), (5, 15)), (10, 10)))
@@ -182,22 +182,22 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_mouse_adjusts_preview_aspect_exponentially(self):
adjust = self.rectify.aspect_ratio_from_mouse
adjust = self.rectify_preview.aspect_ratio_from_mouse
self.assertAlmostEqual(adjust(1.5, 240.0), 3.0)
self.assertAlmostEqual(adjust(1.5, -240.0), 0.75)
self.assertEqual(
adjust(1.0, 100000.0),
self.rectify.MAX_INTERACTIVE_ASPECT,
self.rectify_geometry.MAX_INTERACTIVE_ASPECT,
)
self.assertEqual(
self.rectify.snapped_aspect_ratio(1.7),
self.rectify_preview.snapped_aspect_ratio(1.7),
(16.0 / 9.0, "16 : 9"),
)
def test_rectify_preview_is_centered_at_requested_aspect(self):
left, bottom, width, height = self.rectify.preview_draw_bounds(
left, bottom, width, height = self.rectify_preview.preview_draw_bounds(
(1000, 800), 2.0
)
@@ -207,7 +207,7 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_uses_quad_edges_for_initial_aspect(self):
ratio = self.rectify.perspective_quad_aspect(
ratio = self.rectify_geometry.perspective_quad_aspect(
((0, 0), (8, 0), (8, 4), (0, 4))
)
@@ -228,7 +228,7 @@ class RectifyToolTest(BlenderTestCase):
def test_rectify_maps_crop_to_source_plane_bounds(self):
bounds = self.rectify.perspective_placement_bounds(
bounds = self.rectify_geometry.perspective_placement_bounds(
((10, 20), (30, 20), (30, 40), (10, 40)),
(100, 50),
(-10, -5, 110, 55),