Refactor depth reference handling and cleanup
- Unified reference depth calculation to use a single implementation in common/depth.py. - Removed server-side reference depth computation and adjusted depth.json to only include image_size and intrinsics. - Updated depth texture handling to ignore transparent, invalid, and non-positive pixels when calculating reference depth. - Changed reference depth calculation to use the 95th percentile of valid depth values. - Adjusted depth direction fitting to return a flat direction when no samples are available. - Removed cleanup threshold parameters from Cutout and related nodes, simplifying the interface. - Updated tests to verify new reference depth logic and ensure compatibility with existing functionality.
This commit is contained in:
@@ -7,6 +7,7 @@ from tests.support.planes import surface
|
||||
def test_conversion_preserves_offset_world_placement_and_initializes_inputs(surface, monkeypatch):
|
||||
from anyimage.operators.convert_to_plane import object as conversion
|
||||
from anyimage.common.image import image_empty_bounds
|
||||
from anyimage.common.depth import reference_depth
|
||||
from mathutils import Matrix, Vector
|
||||
|
||||
obj, _, _, inputs, image = surface
|
||||
@@ -22,7 +23,7 @@ def test_conversion_preserves_offset_world_placement_and_initializes_inputs(surf
|
||||
bounds = image_empty_bounds(source)
|
||||
matrix = source.matrix_world.copy()
|
||||
material = bpy.data.materials.new("Conversion")
|
||||
metadata = {"image_size": (16, 8), "reference_depth": 2.0,
|
||||
metadata = {"image_size": (16, 8),
|
||||
"intrinsics": ((4, 0, 5), (0, 4, 3), (0, 0, 1))}
|
||||
result = conversion.create_depth_plane_object(
|
||||
bpy.context, source, 2, material, image, metadata, "DEPTH")
|
||||
@@ -40,7 +41,7 @@ def test_conversion_preserves_offset_world_placement_and_initializes_inputs(surf
|
||||
assert modifier[inputs["Depth Image"].identifier] == image
|
||||
assert modifier[inputs["Depth Mask"].identifier] is True
|
||||
assert modifier[inputs["Reference Depth"].identifier] == pytest.approx(
|
||||
2 * modifier[inputs["Uniform Scale"].identifier])
|
||||
reference_depth(image) * modifier[inputs["Uniform Scale"].identifier])
|
||||
assert result.data.materials[0] == material
|
||||
|
||||
|
||||
@@ -60,7 +61,7 @@ def test_failed_modifier_initialization_removes_partial_object(surface, monkeypa
|
||||
raise RuntimeError("input failed")
|
||||
|
||||
monkeypatch.setattr(conversion, "set_modifier_input", fail)
|
||||
metadata = {"image_size": (16, 8), "reference_depth": 2,
|
||||
metadata = {"image_size": (16, 8),
|
||||
"intrinsics": ((4, 0, 5), (0, 4, 3), (0, 0, 1))}
|
||||
with pytest.raises(RuntimeError, match="input failed"):
|
||||
conversion.create_depth_plane_object(bpy.context, source, 2, material, image, metadata, "DEPTH")
|
||||
|
||||
Reference in New Issue
Block a user