Exemple #1
0
def main():
    import tenon.logging as L
    import tenon.util as U

    L.setLevel(L.DEBUG)
    cachedir = os.path.abspath(os.path.join(rootdir, 'cache/examples/camera_track'))

    # Set up the camera tracking constraint
    # The object will be out of the view without setting a proper tracking constraint
    camera = tenon.obj.get('Camera')
    target = tenon.obj.get('Suzanne')
    # tenon.constraint.TrackConstraint()

    # Track_to constraint
    U.camera_track(camera, target) # Setup camera tracking constraint

    # Set up the light configuration
    for count in range(10):
        camera.location.x -= 0.5

        filename = os.path.join(cachedir, 'camera_track_%d.png' % count)
        tenon.render.write(filename)


    radius = camera.location.length # Keep the radius fixed
    el = 0
    for az in range(0, 360, 30):
        loc = U.sphere_location(radius, az, el)
        camera.location = loc

        filename = os.path.join(cachedir, 'circular_az%d.png' % az)
        tenon.render.write(filename)
Exemple #2
0
def main():
    out_folders = {
        'image': './lsp/images',
        'depth': './lsp/depth',
        'semantic': './lsp/semantic',
        '2dpose': './lsp/2dpose'
    }
    for path in out_folders.values():
        if not os.path.exists(path):
            os.makedirs(path)

    util = lsppose.Util()
    models = lsppose.Models()

    L.setLevel(tenon.logging.INFO)
    L.info('Switch logging level to INFO')
    L.info('Write a test image to init.png')
    tenon.render.write('lsp/init.png')

    camera = tenon.obj.get('Camera') # Unused in this demo
    scene = util.setup_scene()

    objs = [
        # models.humanModel(),
        models.bodyMesh(),
        models.upperCloth(),
        models.lowerCloth(),
        models.hair(),
        models.eye()
        ]

    schedule_idx = range(1, 2001)
    schedule_idx = [73]
    for pose_id in schedule_idx:
        posefolder = '../data/2015101415_v2'
        util.update_scene(posefolder, scene, pose_id)

        imgfilename = os.path.join(out_folders['image'], '%04d.png' % pose_id)
        tenon.render.write(imgfilename)
        L.info('Synthetic image: %s' % L.prettify_filename(imgfilename))

        depth_filename = os.path.join(out_folders['depth'], '%04d.png' % pose_id)
        tenon.render.DepthMode.enable()
        tenon.render.write(depth_filename)
        L.info('Depth: %s' % L.prettify_filename(depth_filename))
        tenon.render.DepthMode.disable()

        paint_filename = os.path.join(out_folders['semantic'], '%04d.png' % pose_id)
        for obj in objs:
            tenon.render.PaintMode.enable(obj)
        tenon.render.write(paint_filename)
        L.info('Semantic parts: %s' % L.prettify_filename(paint_filename))
        for obj in objs:
            tenon.render.PaintMode.disable(obj)

        # Also save the joint annotation and part annotation
        joint_filename = os.path.join(out_folders['2dpose'], '%04d.csv' % pose_id)
        joints = lsppose.JointInfo.export()
        lsppose.JointInfo.serializeJointInfo(joint_filename, joints)
        L.info('2D joint location: %s' % L.prettify_filename(joint_filename))
Exemple #3
0
def main():
    import tenon.logging as L
    import tenon.util as U

    L.setLevel(L.DEBUG)
    cachedir = os.path.abspath(
        os.path.join(rootdir, 'cache/examples/camera_track'))

    # Set up the camera tracking constraint
    # The object will be out of the view without setting a proper tracking constraint
    camera = tenon.obj.get('Camera')
    target = tenon.obj.get('Suzanne')
    # tenon.constraint.TrackConstraint()

    # Track_to constraint
    U.camera_track(camera, target)  # Setup camera tracking constraint

    # Set up the light configuration
    for count in range(10):
        camera.location.x -= 0.5

        filename = os.path.join(cachedir, 'camera_track_%d.png' % count)
        tenon.render.write(filename)

    radius = camera.location.length  # Keep the radius fixed
    el = 0
    for az in range(0, 360, 30):
        loc = U.sphere_location(radius, az, el)
        camera.location = loc

        filename = os.path.join(cachedir, 'circular_az%d.png' % az)
        tenon.render.write(filename)
Exemple #4
0
def main():
    import tenon.logging as L
    L.setLevel(L.DEBUG)
    cachedir = os.path.abspath(os.path.join(rootdir, 'cache/examples/render_mode'))

    tenon.render.write(os.path.join(cachedir, 'normal_mode.png'))

    tenon.render.DepthMode.enable()
    tenon.render.write(os.path.join(cachedir, 'depth_mode.png'))
    tenon.render.DepthMode.disable()

    tenon.render.PaintMode.enable(tenon.obj.get('Suzanne'))
    tenon.render.write(os.path.join(cachedir, 'paint_mode.png'))
Exemple #5
0
def main():
    util = lsppose.Util()
    models = lsppose.Models()
    util.rootdir = rootdir

    import tenon.logging as L
    # outputdir = '//../cache/lsp_synthesized'
    L.setLevel(tenon.logging.INFO)
    L.info('Switch logging level to INFO')
    tenon.render.write('init.png')

    camera = tenon.obj.get('Camera')  # Unused in this demo
    scene = util.setup_scene()

    objs = [
        # models.humanModel(),
        models.bodyMesh(),
        models.upperCloth(),
        models.lowerCloth(),
        models.hair(),
        models.eye()
    ]

    schedule_idx = range(1, 20001)
    schedule_idx = [73, 2]
    for i in schedule_idx:
        util.update_scene(scene, i)

        imgfilename = os.path.join(outputdir, 'imgs/%04d.png' % i)
        tenon.render.write(imgfilename)
        L.info('Synthetic image: %s' % L.prettify_filename(imgfilename))

        depth_filename = os.path.join(outputdir, 'depth/%04d.png' % i)
        tenon.render.DepthMode.enable()
        tenon.render.write(depth_filename)
        L.info('Depth: %s' % L.prettify_filename(depth_filename))
        tenon.render.DepthMode.disable()

        paint_filename = os.path.join(outputdir, 'parts/%04d.png' % i)
        for obj in objs:
            tenon.render.PaintMode.enable(obj)
        tenon.render.write(paint_filename)
        L.info('Semantic parts: %s' % L.prettify_filename(paint_filename))
        for obj in objs:
            tenon.render.PaintMode.disable(obj)

        # Also save the joint annotation and part annotation
        joint_filename = os.path.join(outputdir, 'joints/%04d.csv' % i)
        joints = lsppose.JointInfo.export()
        lsppose.JointInfo.serializeJointInfo(joint_filename, joints)
Exemple #6
0
def main():
    import tenon.logging as L
    L.setLevel(L.DEBUG)
    cachedir = os.path.abspath(
        os.path.join(rootdir, 'cache/examples/render_mode'))

    tenon.render.write(os.path.join(cachedir, 'normal_mode.png'))

    tenon.render.DepthMode.enable()
    tenon.render.write(os.path.join(cachedir, 'depth_mode.png'))
    tenon.render.DepthMode.disable()

    tenon.render.PaintMode.enable(tenon.obj.get('Suzanne'))
    tenon.render.write(os.path.join(cachedir, 'paint_mode.png'))
Exemple #7
0
def main():
    util = lsppose.Util()
    models = lsppose.Models()
    util.rootdir = rootdir

    import tenon.logging as L
    # outputdir = '//../cache/lsp_synthesized'
    L.setLevel(tenon.logging.INFO)
    L.info('Switch logging level to INFO')
    tenon.render.write('init.png')

    camera = tenon.obj.get('Camera') # Unused in this demo
    scene = util.setup_scene()

    objs = [
        # models.humanModel(),
        models.bodyMesh(),
        models.upperCloth(),
        models.lowerCloth(),
        models.hair(),
        models.eye()
        ]

    schedule_idx = range(1, 20001)
    schedule_idx = [73, 2]
    for i in schedule_idx:
        util.update_scene(scene, i)

        imgfilename = os.path.join(outputdir, 'imgs/%04d.png' % i)
        tenon.render.write(imgfilename)
        L.info('Synthetic image: %s' % L.prettify_filename(imgfilename))

        depth_filename = os.path.join(outputdir, 'depth/%04d.png' % i)
        tenon.render.DepthMode.enable()
        tenon.render.write(depth_filename)
        L.info('Depth: %s' % L.prettify_filename(depth_filename))
        tenon.render.DepthMode.disable()

        paint_filename = os.path.join(outputdir, 'parts/%04d.png' % i)
        for obj in objs:
            tenon.render.PaintMode.enable(obj)
        tenon.render.write(paint_filename)
        L.info('Semantic parts: %s' % L.prettify_filename(paint_filename))
        for obj in objs:
            tenon.render.PaintMode.disable(obj)

        # Also save the joint annotation and part annotation
        joint_filename = os.path.join(outputdir, 'joints/%04d.csv' % i)
        joints = lsppose.JointInfo.export()
        lsppose.JointInfo.serializeJointInfo(joint_filename, joints)
def main():
    util = lsppose.Util()
    models = lsppose.Models()
    util.rootdir = rootdir

    import tenon.logging as L
    # outputdir = '//../cache/lsp_synthesized'
    L.setLevel(tenon.logging.INFO)
    L.info('Switch logging level to INFO')
    tenon.render.write('init.png')

    camera = tenon.obj.get('Camera') # Unused in this demo
    scene = util.setup_scene()

    objs = [
        # models.humanModel(),
        models.bodyMesh(),
        models.upperCloth(),
        models.lowerCloth(),
        models.hair(),
        models.eye()
        ]

    schedule_idx = range(1, 20001)
    schedule_idx = [2]
    for i in schedule_idx:
        util.update_scene(scene, i)

        # imgfilename = os.path.join(outputdir, 'imgs/%04d.png' % i)
        # tenon.render.write(imgfilename)
        # L.info('Synthetic image: %s' % L.prettify_filename(imgfilename))

        # depth_filename = os.path.join(outputdir, 'depth/%04d.png' % i)
        # tenon.render.DepthMode.enable()
        # tenon.render.write(depth_filename)
        # L.info('Depth: %s' % L.prettify_filename(depth_filename))
        # tenon.render.DepthMode.disable()

        # paint_filename = os.path.join(outputdir, 'parts/%04d.png' % i)
        # for obj in objs:
        #     tenon.render.PaintMode.enable(obj)
        # tenon.render.write(paint_filename)
        # L.info('Semantic parts: %s' % L.prettify_filename(paint_filename))
        # for obj in objs:
        #     tenon.render.PaintMode.disable(obj)

        # # Also save the joint annotation and part annotation
        # joint_filename = os.path.join(outputdir, 'joints/%04d.csv' % i)
        # joints = lsppose.JointInfo.export()
        # lsppose.JointInfo.serializeJointInfo(joint_filename, joints)

        import tenon.util as U
        radius = camera.location.length # Keep the radius fixed
        el = 0
        # for angle in [0, 90, 180, 270]:
        # for angle in range(0, 360, 10):
        for angle in [240]:
            for el in range(0, 90, 10):
                loc = U.sphere_location(radius, angle, el)
                camera.location = loc
                imgfilename = os.path.join(outputdir, 'imgs/%04d_%d_%d.png' % (i, angle, el))
                tenon.render.write(imgfilename)
                L.info('Synthetic image: %s' % L.prettify_filename(imgfilename))
Exemple #9
0
Synthesize images around the center object
'''
import sys, os
rootdir = os.path.expanduser('~/Dropbox/workspace/graphics_for_vision/tenon')
tenonpath = os.path.join(rootdir, 'code/tenon')
pwd = os.path.join(rootdir, 'code/tenon/examples/demo_lsp')
for v in [tenonpath, pwd]:
    sys.path.append(os.path.expanduser(v))
import tenon
import lsppose

# output_dir = os.path.join(rootdir, 'cache/lsp_synthesized/circular_demo')
output_dir = os.path.expanduser('~/nosync/circular_demo/')

import tenon.logging as L
L.setLevel(L.INFO)
# L.setLevel(L.DEBUG)
L.info('Output folder is %s', L.prettify_filename(output_dir))


def blender():
    lsppose_ = lsppose.Util()
    lsppose_.rootdir = rootdir

    import tenon.util as U

    L.info('Switch logging level to INFO')

    camera = tenon.obj.get('Camera') # Unused in this demo
    scene = lsppose_.setup_scene()