Remove obsolete implementation and simplify project structure
This commit is contained in:
35
src/anyimage/server/outputs/surface.py
Normal file
35
src/anyimage/server/outputs/surface.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def write_surface_archive(mesh, output_path):
|
||||
import numpy as np
|
||||
|
||||
output_path = Path(output_path)
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
np.savez_compressed(
|
||||
output_path,
|
||||
vertices=mesh.vertices,
|
||||
faces=mesh.faces,
|
||||
uv=mesh.uv,
|
||||
intrinsics=mesh.intrinsics,
|
||||
image_size=np.asarray(mesh.image_size, dtype=np.int32),
|
||||
reference_depth=np.asarray(mesh.reference_depth, dtype=np.float32),
|
||||
**mesh.point_attributes,
|
||||
**mesh.face_attributes,
|
||||
)
|
||||
return output_path
|
||||
|
||||
|
||||
def write_normal_texture(normal, output_path):
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
normal_rgb = np.clip(
|
||||
(normal * np.array([1.0, -1.0, -1.0], dtype=np.float32) + 1.0)
|
||||
* 127.5,
|
||||
0.0,
|
||||
255.0,
|
||||
).astype(np.uint8)
|
||||
output_path = Path(output_path)
|
||||
Image.fromarray(normal_rgb, mode="RGB").save(output_path)
|
||||
return output_path
|
||||
Reference in New Issue
Block a user