예제 #1
0
sys.path.insert(0, _path.join(_path.dirname(__file__), '..', '..'))
from config import SMPL_FP
sys.path.insert(0, SMPL_FP)
try:
    from smpl.serialization import load_model  # pylint: disable=import-error
except ImportError:
    try:
        from psbody.smpl.serialization import load_model  # pylint: disable=import-error
    except ImportError:
        from smpl_webuser.serialization import load_model

_LOGGER = _logging.getLogger(__name__)
MODEL_NEUTRAL_PATH = _os.path.join(
    _path.dirname(__file__), '..', 'models', '3D',
    'basicModel_neutral_lbs_10_207_0_v1.0.0.pkl')
MODEL_NEUTRAL = load_model(MODEL_NEUTRAL_PATH)
_TEMPLATE_MESH = _Mesh(filename=_os.path.join(_os.path.dirname(
    __file__), '..', 'models', '3D', 'template-bodyparts.ply'))


def _rodrigues_from_seq(angles_seq):
    """Create rodrigues representation of angles."""
    rot = _np.eye(3)
    for angle in angles_seq[::-1]:
        rot = rot.dot(_cv2.Rodrigues(angle)[0])
    return _cv2.Rodrigues(rot)[0].flatten()


def _create_renderer(  # pylint: disable=too-many-arguments
        w=640,
        h=480,
예제 #2
0
>	python hello_smpl.py

"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
import sys

sys.path.append('../')
from smpl.serialization import load_model

# Load SMPL model (here we load the female model)
# Make sure path is correct
m = load_model('../../models/basicModel_f_lbs_10_207_0_v1.0.0.pkl')

# Assign random pose and shape parameters
m.pose[:] = np.random.rand(m.pose.size) * .2
m.betas[:] = np.random.rand(m.betas.size) * .03

# Write to an .obj file
outmesh_path = './hello_smpl.obj'
with open(outmesh_path, 'w') as fp:
    for v in m.r:
        fp.write('v %f %f %f\n' % (v[0], v[1], v[2]))

    for f in m.f + 1:  # Faces are 1-based, not 0-based in obj files
        fp.write('f %d %d %d\n' % (f[0], f[1], f[2]))

# Print message