Example #1
0
def load_motion_from_bvh(filename):
    bvh_reader = BVHReader(filename)
    motion_vector = MotionVector()
    motion_vector.from_bvh_reader(bvh_reader, False)
    animated_joints = list(bvh_reader.get_animated_joints())
    motion_vector.skeleton = SkeletonBuilder().load_from_bvh(
        bvh_reader, animated_joints=animated_joints)
    return motion_vector
Example #2
0
 def load_file(self, filename):
     bvh_reader = BVHReader(str(self.folder_path) + os.sep + filename)
     mv = MotionVector()
     mv.from_bvh_reader(bvh_reader, False)
     animated_joints = list(bvh_reader.get_animated_joints())
     mv.skeleton = SkeletonBuilder().load_from_bvh(
         bvh_reader, animated_joints=animated_joints)
     self.motion_cache[filename] = mv
Example #3
0
def load_target_skeleton(file_path, scale_factor=1.0):
    skeleton = None
    target_bvh = BVHReader(file_path)
    animated_joints = list(target_bvh.get_animated_joints())
    skeleton = SkeletonBuilder().load_from_bvh(target_bvh,
                                               animated_joints,
                                               add_tool_joints=False)
    for node in list(skeleton.nodes.values()):
        node.offset[0] *= scale_factor
        node.offset[1] *= scale_factor
        node.offset[2] *= scale_factor
    return skeleton
def main():
    global context, pool
    port = 8888
    target_skeleton_file = MODEL_DATA_DIR + os.sep + "iclone_female4.bvh"
    skeleton_model = "iclone"
    target_skeleton_file = None
    parser = argparse.ArgumentParser(
        description="Start the MorphableGraphs REST-interface")
    parser.add_argument(
        "-set",
        nargs='+',
        default=[],
        help="JSONPath expression, e.g. -set $.model_data=path/to/data")
    parser.add_argument("-config_file",
                        nargs='?',
                        default=SERVICE_CONFIG_FILE,
                        help="Path to default config file")
    parser.add_argument("-target_skeleton",
                        nargs='?',
                        default=target_skeleton_file,
                        help="Path to target skeleton file")
    parser.add_argument("-skeleton_scale",
                        nargs='?',
                        default=1.0,
                        help="Scale applied to the target skeleton offsets")
    args = parser.parse_args()
    if os.path.isfile(args.config_file):
        service_config = load_json_file(args.config_file)
        algorithm_config_file = "config" + os.sep + service_config[
            "algorithm_settings"] + "_algorithm.config"
        algorithm_config = load_json_file(algorithm_config_file)
        port = service_config["port"]
        if args.target_skeleton is not None:
            # TODO use custom json file instead
            bvh_reader = BVHReader(args.target_skeleton)
            animated_joints = list(bvh_reader.get_animated_joints())
            target_skeleton = SkeletonBuilder().load_from_bvh(
                bvh_reader, animated_joints=animated_joints)
            target_skeleton.skeleton_model = SKELETON_MODELS[skeleton_model]
        else:
            target_skeleton = None

        context = Context(service_config, algorithm_config, target_skeleton)
    count = cpu_count()
    print("run {} processes on port {}".format(count, port))
    pool = ProcessPoolExecutor(max_workers=count)

    # configure tornado to work with the asynchio loop
    tornado.platform.asyncio.AsyncIOMainLoop().install()
    app.listen(port)
    asyncio.get_event_loop().run_forever()
    pool.shutdown()
Example #5
0
 def slot_load_bvh_str(self):
     filename = QFileDialog.getOpenFileName(self, 'Open File', '.')[0]
     filename = str(filename)
     if os.path.isfile(filename):
         try:
             bvh = BVHReader(filename)
             skeleton = SkeletonBuilder().load_from_bvh(
                 bvh, list(bvh.get_animated_joints()))
             self.data = skeleton.to_unity_format()
             print("loaded bvh string from", filename)
         except Exception as e:
             self.data = None
             print("Could not read file", e.args, filename)