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:
@@ -70,16 +70,12 @@ def test_camera_blur_preserves_rays_interior_protection_and_disconnected_surface
|
||||
camera[valid, :2] / camera[valid, 2:3], atol=1e-6)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["definition", "asset"])
|
||||
def test_cutout_fine_outline_blurs_depth_without_moving_projection(source):
|
||||
|
||||
def test_cutout_fine_outline_blurs_depth_without_moving_projection():
|
||||
from tests.support.depth_surface import surface
|
||||
from anyimage.operators.cutout_tool.fine_mesh import build_fine_mesh
|
||||
from anyimage.operators.cutout_tool.object import load_cutout_node_group
|
||||
|
||||
obj, set_value = surface(step=0, resolution=8)
|
||||
if source == "asset":
|
||||
bpy.data.node_groups.remove(obj.modifiers[0].node_group, do_unlink=True)
|
||||
obj.modifiers[0].node_group = load_cutout_node_group("DEPTH_SOLID")
|
||||
yy, xx = np.mgrid[:32, :64]
|
||||
alpha = ((xx - 32)**2 / 27**2 + (yy - 16)**2 / 13**2 < 1).astype(float)
|
||||
points, faces, _, _ = build_fine_mesh(alpha, 3, .9)
|
||||
@@ -111,11 +107,10 @@ def test_cutout_fine_outline_blurs_depth_without_moving_projection(source):
|
||||
np.testing.assert_array_equal(evaluated(obj)[0], before)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["definition", "asset"])
|
||||
def test_plane_validity_hole_blurs_depth_and_protects_rectangle(source):
|
||||
def test_plane_validity_hole_blurs_depth_and_protects_rectangle():
|
||||
from tests.support.planes import create_surface, evaluated as plane_mesh
|
||||
|
||||
obj, set_value, _, _, image = create_surface(source, "DEPTH")
|
||||
obj, set_value, _, _, image = create_surface("DEPTH")
|
||||
pixels = np.array(image.pixels[:], np.float32).reshape(8, 16, 4)
|
||||
pixels[..., 2] = 2
|
||||
pixels[2:6, 6:10, 3] = 0
|
||||
@@ -136,17 +131,15 @@ def test_plane_validity_hole_blurs_depth_and_protects_rectangle(source):
|
||||
np.testing.assert_array_equal(after[outer], before[outer])
|
||||
np.testing.assert_allclose(after[:, :2] / (1.2 - after[:, 2:3]),
|
||||
before[:, :2] / (1.2 - before[:, 2:3]), atol=1e-6)
|
||||
set_value("Valid Only", False)
|
||||
set_value("Depth Mask", False)
|
||||
intact = plane_mesh(obj)[0]
|
||||
set_value("Boundary Smooth", 0)
|
||||
np.testing.assert_array_equal(plane_mesh(obj)[0], intact)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["definition", "asset"])
|
||||
@pytest.mark.parametrize("region", ["seam", "pole"])
|
||||
def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(source, region):
|
||||
def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(region):
|
||||
from tests.tools.nodes.test_image_depth_panorama import panorama, evaluated as panorama_mesh
|
||||
from tools.nodes.build import OUTPUT_PATH
|
||||
|
||||
yy, xx = np.mgrid[:64, :128]
|
||||
distance = np.minimum(xx, 128 - xx)
|
||||
@@ -154,11 +147,6 @@ def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(source, regi
|
||||
spike = ((distance < 4) & (yy > 40) & (yy < 44)) if region == "seam" else ((yy > 50) & (xx < 8))
|
||||
depth = np.where(spike, 10., 3.)
|
||||
obj, set_value = panorama(depth, (~hole).astype(float), subdivide=5)
|
||||
if source == "asset":
|
||||
obj.modifiers[0].node_group.name = "Panorama definition"
|
||||
with bpy.data.libraries.load(str(OUTPUT_PATH)) as (_, target):
|
||||
target.node_groups = ["O Image Depth Panorama"]
|
||||
obj.modifiers[0].node_group = target.node_groups[0]
|
||||
set_value("Smooth Weight", 0)
|
||||
before, faces, uv = panorama_mesh(obj)
|
||||
set_value("Boundary Smooth", 12)
|
||||
@@ -174,7 +162,7 @@ def test_panorama_blurs_opening_radially_and_keeps_invalid_distance(source, regi
|
||||
interior = [i for i in range(len(before)) if i not in band]
|
||||
assert interior
|
||||
np.testing.assert_array_equal(after[interior], before[interior])
|
||||
set_value("Valid Only", False)
|
||||
set_value("Depth Mask", False)
|
||||
near = panorama_mesh(obj)[0]
|
||||
set_value("Invalid Distance", 250)
|
||||
far = panorama_mesh(obj)[0]
|
||||
|
||||
Reference in New Issue
Block a user