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:
@@ -4,7 +4,8 @@ import pytest
|
||||
|
||||
|
||||
from anyimage.common.image import premultiplied_rgba
|
||||
from anyimage.operators import frame_tool as frame
|
||||
from anyimage.operators.frame_tool import compositing as frame
|
||||
from anyimage.operators.frame_tool.projection import frame_source_projection
|
||||
|
||||
|
||||
def source(rgba, *, bounds=(-1, 1, -1, 1), depth=1, slope=0, active=True):
|
||||
@@ -13,7 +14,7 @@ def source(rgba, *, bounds=(-1, 1, -1, 1), depth=1, slope=0, active=True):
|
||||
world = np.eye(4)
|
||||
world[2, 3] = -depth
|
||||
world[2, 0] = slope
|
||||
result = frame.frame_source_projection(
|
||||
result = frame_source_projection(
|
||||
np.eye(4), np.eye(4), world, bounds, (1, 1), perspective=False
|
||||
)
|
||||
result.update(
|
||||
@@ -43,7 +44,7 @@ def test_uncovered_canvas_has_no_rgb_to_reveal_with_mask_add():
|
||||
assert np.any(uncovered)
|
||||
np.testing.assert_array_equal(result[uncovered], 0)
|
||||
restored = np.flipud(apply_alpha_mask(
|
||||
result, SelectionMask(np.ones((8, 8)), (0, 0, 8, 8)), "ADD"
|
||||
result, SelectionMask(np.ones((8, 8)), (0, 0, 8, 8)), "EXTEND"
|
||||
).reshape((8, 8, 4)))
|
||||
np.testing.assert_array_equal(restored[..., :3][uncovered], 0)
|
||||
np.testing.assert_array_equal(restored[..., 3], 1)
|
||||
@@ -86,7 +87,7 @@ def test_oblique_boundary_matches_reference_and_chunk_sizes():
|
||||
world = np.eye(4)
|
||||
world[:2, :2] = ((np.cos(angle), -np.sin(angle)), (np.sin(angle), np.cos(angle)))
|
||||
world[2, 3] = -1
|
||||
top.update(frame.frame_source_projection(
|
||||
top.update(frame_source_projection(
|
||||
np.eye(4), np.eye(4), world, (-0.7, 0.7, -0.7, 0.7), (1, 1), perspective=False
|
||||
))
|
||||
bottom = source([[[0, 0, 1, 0]]], depth=2, active=False)
|
||||
@@ -104,7 +105,7 @@ def test_oblique_boundary_matches_reference_and_chunk_sizes():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("background", [0, 1])
|
||||
def test_packed_frame_mask_add_keeps_boundary_color(background):
|
||||
def test_packed_frame_mask_extend_keeps_boundary_color(background):
|
||||
from io import BytesIO
|
||||
import bpy
|
||||
from PIL import Image
|
||||
@@ -122,7 +123,7 @@ def test_packed_frame_mask_add_keeps_boundary_color(background):
|
||||
expected = (np.array([1, 0, 0]) + background) / 2
|
||||
np.testing.assert_allclose(packed[0, 0, :3], expected, atol=1 / 255)
|
||||
restored = apply_alpha_mask(
|
||||
image_rgba(result), SelectionMask(np.ones((1, 1)), (0, 0, 1, 1)), "ADD"
|
||||
image_rgba(result), SelectionMask(np.ones((1, 1)), (0, 0, 1, 1)), "EXTEND"
|
||||
).reshape(1, 1, 4)
|
||||
np.testing.assert_allclose(restored[0, 0, :3], expected, atol=1 / 255)
|
||||
assert restored[0, 0, 3] == 1
|
||||
|
||||
Reference in New Issue
Block a user