Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
hnuzhy authored Aug 23, 2024
1 parent 7c0d416 commit 727a1d8
Show file tree
Hide file tree
Showing 18 changed files with 8,371 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Sim3DR/Sim3DR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding: utf-8

from . import _init_paths
import numpy as np
import Sim3DR_Cython


def get_normal(vertices, triangles):
normal = np.zeros_like(vertices, dtype=np.float32)
Sim3DR_Cython.get_normal(normal, vertices, triangles, vertices.shape[0], triangles.shape[0])
return normal


def rasterize(vertices, triangles, colors, bg=None,
height=None, width=None, channel=None,
reverse=False):
if bg is not None:
height, width, channel = bg.shape
else:
assert height is not None and width is not None and channel is not None
bg = np.zeros((height, width, channel), dtype=np.uint8)

buffer = np.zeros((height, width), dtype=np.float32) - 1e8

if colors.dtype != np.float32:
colors = colors.astype(np.float32)
Sim3DR_Cython.rasterize(bg, vertices, triangles, colors, buffer, triangles.shape[0], height, width, channel,
reverse=reverse)
return bg
Binary file not shown.
4 changes: 4 additions & 0 deletions Sim3DR/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# coding: utf-8

from .Sim3DR import get_normal, rasterize
from .lighting import RenderPipeline
14 changes: 14 additions & 0 deletions Sim3DR/_init_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# coding: utf-8

import os.path as osp
import sys


def add_path(path):
if path not in sys.path:
sys.path.insert(0, path)


this_dir = osp.dirname(__file__)
lib_path = osp.join(this_dir, '.')
add_path(lib_path)
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Sim3DR/build_sim3dr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python3 setup.py build_ext --inplace
Loading

0 comments on commit 727a1d8

Please sign in to comment.