From 881733c610fdfa21770bfa82ad117fbc5930dc6c Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sat, 15 Jul 2023 19:43:32 +0400 Subject: [PATCH 1/9] Update README.md --- examples/config/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/config/README.md b/examples/config/README.md index 9a7ab1a6..7f7d90fd 100644 --- a/examples/config/README.md +++ b/examples/config/README.md @@ -76,6 +76,9 @@ Transparency is only available for `.gif` videos. The codec to use when encoding the output video. Only used in `video_render` mode and only if a `.mp4` output video file is specified. + - FRAME_TIME (float): +Overrideing BVH frame time value. + ## Character Config File This configuration file (referred to below as `char_cfg`) contains the information necessary to create an instance of the Animated Drawing class. In addition to the fields below, which are explicitly listed within `char_cfg`, the filepath of `char_cfg` is used to store the location of the character's texture and mask files. Essentially, just make sure the associated `texture.png` and `mask.png` files are in the same directory as `char_cfg`. From 5a59cbfa4209c3463fa5f299e54aeaa75857190f Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sat, 15 Jul 2023 19:46:18 +0400 Subject: [PATCH 2/9] Update mvc_base_cfg.yaml add Frame Time default value --- animated_drawings/mvc_base_cfg.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/animated_drawings/mvc_base_cfg.yaml b/animated_drawings/mvc_base_cfg.yaml index 7d29f547..b5e8081d 100644 --- a/animated_drawings/mvc_base_cfg.yaml +++ b/animated_drawings/mvc_base_cfg.yaml @@ -17,3 +17,4 @@ controller: KEYBOARD_TIMESTEP: 0.0333 # only used if mode is 'interactive' OUTPUT_VIDEO_PATH: ./output_video.mp4 # only used if mode is 'video_render' OUTPUT_VIDEO_CODEC: avc1 # only used if mode is 'video_render' + FRAME_TIME: null # override bvh frame time From dd51d503883a2fe5a44a5cd9d52ca177839e9257 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sat, 15 Jul 2023 19:48:16 +0400 Subject: [PATCH 3/9] Update config.py set and check frame time value type --- animated_drawings/config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/animated_drawings/config.py b/animated_drawings/config.py index 3a4b2dce..e80c04e3 100644 --- a/animated_drawings/config.py +++ b/animated_drawings/config.py @@ -244,7 +244,15 @@ def __init__(self, controller_cfg: dict) -> None: msg = f'Error in OUTPUT_VIDEO_CODEC config parameter: {e}' logging.critical(msg) assert False, msg - + + # set frame time (override bvh frame time) + try: + self.frame_time: Union[None,float] = controller_cfg['FRAME_TIME'] + assert isinstance(self.frame_time, (NoneType,float)), 'is not None or float' + except (AssertionError, ValueError) as e: + msg = f'Error in FRAME_TIME config parameter: {e}' + logging.critical(msg) + assert False, msg class CharacterConfig(): From 3c9623c087cc6ca4e18f9efc26bc30fa783cafa9 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sat, 15 Jul 2023 19:49:19 +0400 Subject: [PATCH 4/9] Update video_render_controller.py overriding frame time from config to BVH --- animated_drawings/controller/video_render_controller.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/animated_drawings/controller/video_render_controller.py b/animated_drawings/controller/video_render_controller.py index 2080e644..2fc617c3 100644 --- a/animated_drawings/controller/video_render_controller.py +++ b/animated_drawings/controller/video_render_controller.py @@ -34,6 +34,7 @@ def __init__(self, cfg: ControllerConfig, scene: Scene, view: View) -> None: self.view: View = view self.scene: Scene = scene + self.cfg: ControllerConfig = cfg self.frames_left_to_render: int # when this becomes zero, stop rendering self.delta_t: float # amount of time to progress scene between renders @@ -65,6 +66,13 @@ def _set_frames_left_to_render_and_delta_t(self) -> None: if not isinstance(child, AnimatedDrawing): continue max_frames = max(max_frames, child.retargeter.bvh.frame_max_num) + # check if overriding frame time + if self.cfg.frame_time: + msg = f'overriding BVH Frame Time value: {child.retargeter.bvh.frame_time} -> {self.cfg.frame_time}.' + logging.info(msg) + child.retargeter.bvh.frame_time = self.cfg.frame_time + print(msg) + frame_time.append(child.retargeter.bvh.frame_time) if not all(x == frame_time[0] for x in frame_time): From 860d344b9cab9eba8bf02d8933c169caa920fb5e Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 15 Aug 2023 16:38:46 -0700 Subject: [PATCH 5/9] moved frame_time from controller_cfg to motion_cfg --- animated_drawings/config.py | 18 +++++++++--------- .../controller/video_render_controller.py | 8 -------- animated_drawings/model/retargeter.py | 4 ++++ examples/config/README.md | 5 +++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/animated_drawings/config.py b/animated_drawings/config.py index e80c04e3..f75760b3 100644 --- a/animated_drawings/config.py +++ b/animated_drawings/config.py @@ -244,15 +244,6 @@ def __init__(self, controller_cfg: dict) -> None: msg = f'Error in OUTPUT_VIDEO_CODEC config parameter: {e}' logging.critical(msg) assert False, msg - - # set frame time (override bvh frame time) - try: - self.frame_time: Union[None,float] = controller_cfg['FRAME_TIME'] - assert isinstance(self.frame_time, (NoneType,float)), 'is not None or float' - except (AssertionError, ValueError) as e: - msg = f'Error in FRAME_TIME config parameter: {e}' - logging.critical(msg) - assert False, msg class CharacterConfig(): @@ -370,6 +361,15 @@ def __init__(self, motion_cfg_fn: str) -> None: # noqa: C901 logging.critical(msg) assert False, msg + # validate frame time override + try: + self.frame_time: Optional[float] = motion_cfg.get('frame_rate', None) + assert isinstance(self.frame_time, (NoneType, float)), 'is not None or float' + except (AssertionError, ValueError) as e: + msg = f'Error in frame_time config parameter: {e}' + logging.critical(msg) + assert False, msg + # validate groundplane joint try: self.groundplane_joint: str = motion_cfg['groundplane_joint'] diff --git a/animated_drawings/controller/video_render_controller.py b/animated_drawings/controller/video_render_controller.py index 2fc617c3..2080e644 100644 --- a/animated_drawings/controller/video_render_controller.py +++ b/animated_drawings/controller/video_render_controller.py @@ -34,7 +34,6 @@ def __init__(self, cfg: ControllerConfig, scene: Scene, view: View) -> None: self.view: View = view self.scene: Scene = scene - self.cfg: ControllerConfig = cfg self.frames_left_to_render: int # when this becomes zero, stop rendering self.delta_t: float # amount of time to progress scene between renders @@ -66,13 +65,6 @@ def _set_frames_left_to_render_and_delta_t(self) -> None: if not isinstance(child, AnimatedDrawing): continue max_frames = max(max_frames, child.retargeter.bvh.frame_max_num) - # check if overriding frame time - if self.cfg.frame_time: - msg = f'overriding BVH Frame Time value: {child.retargeter.bvh.frame_time} -> {self.cfg.frame_time}.' - logging.info(msg) - child.retargeter.bvh.frame_time = self.cfg.frame_time - print(msg) - frame_time.append(child.retargeter.bvh.frame_time) if not all(x == frame_time[0] for x in frame_time): diff --git a/animated_drawings/model/retargeter.py b/animated_drawings/model/retargeter.py index f4e1a6c0..1effc1b5 100644 --- a/animated_drawings/model/retargeter.py +++ b/animated_drawings/model/retargeter.py @@ -43,6 +43,10 @@ def __init__(self, motion_cfg: MotionConfig, retarget_cfg: RetargetConfig) -> No # bvh joints defining a set of vectors that skeleton's fwd is perpendicular to self.forward_perp_vector_joint_names: List[Tuple[str, str]] = motion_cfg.forward_perp_joint_vectors + # override the frame_time, if one was specified within motion_cfg + if motion_cfg.frame_time: + self.bvh.frame_time = motion_cfg.frame_time + # rotate BVH skeleton so up is +Y if motion_cfg.up == '+y': pass # no rotation needed diff --git a/examples/config/README.md b/examples/config/README.md index 7f7d90fd..dd02cbfe 100644 --- a/examples/config/README.md +++ b/examples/config/README.md @@ -76,8 +76,6 @@ Transparency is only available for `.gif` videos. The codec to use when encoding the output video. Only used in `video_render` mode and only if a `.mp4` output video file is specified. - - FRAME_TIME (float): -Overrideing BVH frame time value. ## Character Config File @@ -115,6 +113,9 @@ If you want to skip beginning motion frames, this can be set to an int between 0 - end_frame_idx (int): If you want to skip ending motion frames, this can be set to an int between `start_frame_idx+1` and the BVH Frames Count, inclusive. +- frame_time (float): +If you want to override the frame time specified within the BVH, you can set it here. + - groundplane_joint (str): The name of a joint that exists within the BVH's skeleton. When visualizing the BVH's motion, the skeleton will have it's worldspace y offset adjusted so this joint is within the y=0 plane at `start_frame_idx`. From 6f7f98547dd42b702cd6d3a4dbe3eb59ac09a113 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 15 Aug 2023 16:49:50 -0700 Subject: [PATCH 6/9] removed FRAME_TIME --- animated_drawings/mvc_base_cfg.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animated_drawings/mvc_base_cfg.yaml b/animated_drawings/mvc_base_cfg.yaml index b5e8081d..062716b7 100644 --- a/animated_drawings/mvc_base_cfg.yaml +++ b/animated_drawings/mvc_base_cfg.yaml @@ -17,4 +17,4 @@ controller: KEYBOARD_TIMESTEP: 0.0333 # only used if mode is 'interactive' OUTPUT_VIDEO_PATH: ./output_video.mp4 # only used if mode is 'video_render' OUTPUT_VIDEO_CODEC: avc1 # only used if mode is 'video_render' - FRAME_TIME: null # override bvh frame time + From 72ce0a094a98a2c1bae571e1f06ccbf0ca2ac79a Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 15 Aug 2023 16:56:08 -0700 Subject: [PATCH 7/9] fixed variable name mismatch --- animated_drawings/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animated_drawings/config.py b/animated_drawings/config.py index f75760b3..19015a28 100644 --- a/animated_drawings/config.py +++ b/animated_drawings/config.py @@ -363,7 +363,7 @@ def __init__(self, motion_cfg_fn: str) -> None: # noqa: C901 # validate frame time override try: - self.frame_time: Optional[float] = motion_cfg.get('frame_rate', None) + self.frame_time: Optional[float] = motion_cfg.get('frame_time', None) assert isinstance(self.frame_time, (NoneType, float)), 'is not None or float' except (AssertionError, ValueError) as e: msg = f'Error in frame_time config parameter: {e}' From 4fef92fc50811161ed678ad553a3128adf81eed2 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 15 Aug 2023 16:58:03 -0700 Subject: [PATCH 8/9] linter fix --- animated_drawings/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/animated_drawings/config.py b/animated_drawings/config.py index 19015a28..52bfafc1 100644 --- a/animated_drawings/config.py +++ b/animated_drawings/config.py @@ -245,6 +245,7 @@ def __init__(self, controller_cfg: dict) -> None: logging.critical(msg) assert False, msg + class CharacterConfig(): class JointDict(TypedDict): From 69d2e44eb997c2a6b426c2170662971d5868c137 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 15 Aug 2023 17:00:01 -0700 Subject: [PATCH 9/9] removed blank lines --- animated_drawings/mvc_base_cfg.yaml | 1 - examples/config/README.md | 1 - 2 files changed, 2 deletions(-) diff --git a/animated_drawings/mvc_base_cfg.yaml b/animated_drawings/mvc_base_cfg.yaml index 062716b7..7d29f547 100644 --- a/animated_drawings/mvc_base_cfg.yaml +++ b/animated_drawings/mvc_base_cfg.yaml @@ -17,4 +17,3 @@ controller: KEYBOARD_TIMESTEP: 0.0333 # only used if mode is 'interactive' OUTPUT_VIDEO_PATH: ./output_video.mp4 # only used if mode is 'video_render' OUTPUT_VIDEO_CODEC: avc1 # only used if mode is 'video_render' - diff --git a/examples/config/README.md b/examples/config/README.md index dd02cbfe..709c66a7 100644 --- a/examples/config/README.md +++ b/examples/config/README.md @@ -76,7 +76,6 @@ Transparency is only available for `.gif` videos. The codec to use when encoding the output video. Only used in `video_render` mode and only if a `.mp4` output video file is specified. - ## Character Config File This configuration file (referred to below as `char_cfg`) contains the information necessary to create an instance of the Animated Drawing class. In addition to the fields below, which are explicitly listed within `char_cfg`, the filepath of `char_cfg` is used to store the location of the character's texture and mask files. Essentially, just make sure the associated `texture.png` and `mask.png` files are in the same directory as `char_cfg`.