Skip to content

Commit

Permalink
feat: Added functional test for seam_blending with the coresponding m…
Browse files Browse the repository at this point in the history
…ock-ups
  • Loading branch information
TechyDaniel committed Dec 15, 2023
1 parent 6d75ba7 commit bc86e8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/readyplayerme/meshops/draw/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ def blend_uv_seams(mesh: mops.Mesh, image: Image) -> Image:
blurred_mask = np.power(blurred_mask, 1.5)

# Blend in average vertex color at the UV seams.
return blend_images(image, raster_image, blurred_mask)
return blend_images(image, raster_image, blurred_mask).astype(np.uint8)
Binary file added tests/mocks/input-img-blended.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions tests/readyplayerme/meshops/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ def mock_image():

filepath = files(tests.mocks).joinpath("input-img.png")
return ski.io.imread(filepath)


@pytest.fixture
def mock_image_blended():
"""Return an image as a numpy array."""
from importlib.resources import files

import tests.mocks

filepath = files(tests.mocks).joinpath("input-img-blended.png")
return ski.io.imread(filepath)
9 changes: 9 additions & 0 deletions tests/readyplayerme/meshops/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import numpy.typing as npt

import readyplayerme.meshops.draw.image as img
import readyplayerme.meshops.mesh as mops


Expand All @@ -28,3 +29,11 @@ def test_access_material_should_fail(gltf_simple_file: str | Path):
"""Test the simple gltf does not have a material."""
mesh = mops.read_mesh(gltf_simple_file)
assert mesh.material is None, "Mesh should not have a material."


def test_seam_blend(gltf_file_with_basecolor_texture: str | Path, mock_image_blended: npt.NDArray[Any]):
"""Test the seam blending."""
local_mesh = mops.read_mesh(gltf_file_with_basecolor_texture)
extracted_image = local_mesh.material.baseColorTexture
blended_image = img.blend_uv_seams(local_mesh, extracted_image)
assert np.array_equal(blended_image, mock_image_blended), "The blended image should match the mock-up"

0 comments on commit bc86e8c

Please sign in to comment.