Render of joints.
| 167 | |
| 168 | |
| 169 | class Axes3dJointsRenderer(Axes3dBaseRenderer): |
| 170 | """Render of joints.""" |
| 171 | def __init__(self): |
| 172 | self.if_camera_init = False |
| 173 | self.cam_vector_list = None |
| 174 | self.if_connection_setup = False |
| 175 | self.if_frame_updated = False |
| 176 | self.temp_path = '' |
| 177 | |
| 178 | def set_connections(self, limbs_connection, limbs_palette): |
| 179 | """set body limbs.""" |
| 180 | self.limbs_connection = limbs_connection |
| 181 | self.limbs_palette = limbs_palette |
| 182 | self.if_connection_setup = True |
| 183 | |
| 184 | def render_kp3d_to_video( |
| 185 | self, |
| 186 | keypoints_np: np.ndarray, |
| 187 | output_path: Optional[str] = None, |
| 188 | convention='opencv', |
| 189 | fps: Union[float, int] = 30, |
| 190 | resolution: Iterable[int] = (720, 720), |
| 191 | visual_range: Iterable[int] = (-100, 100), |
| 192 | frame_names: Optional[List[str]] = None, |
| 193 | disable_limbs: bool = False, |
| 194 | return_array: bool = False, |
| 195 | ) -> None: |
| 196 | """Render 3d keypoints to a video. |
| 197 | |
| 198 | Args: |
| 199 | keypoints_np (np.ndarray): shape of input array should be |
| 200 | (f * n * J * 3). |
| 201 | output_path (str): output video path or frame folder. |
| 202 | sign (Iterable[int], optional): direction of the axis. |
| 203 | Defaults to (1, 1, 1). |
| 204 | axis (str, optional): axis convention. |
| 205 | Defaults to 'xzy'. |
| 206 | fps (Union[float, int], optional): fps. |
| 207 | Defaults to 30. |
| 208 | resolution (Iterable[int], optional): (width, height) of |
| 209 | output video. |
| 210 | Defaults to (720, 720). |
| 211 | visual_range (Iterable[int], optional): range of axis value. |
| 212 | Defaults to (-100, 100). |
| 213 | frame_names (Optional[List[str]], optional): List of string |
| 214 | for frame title, no title if None. Defaults to None. |
| 215 | disable_limbs (bool, optional): whether need to disable drawing |
| 216 | limbs. |
| 217 | Defaults to False. |
| 218 | Returns: |
| 219 | None. |
| 220 | """ |
| 221 | assert self.if_camera_init is True |
| 222 | assert self.if_connection_setup is True |
| 223 | sign, axis = enc_camera_convention(convention) |
| 224 | if output_path is not None: |
| 225 | if check_path_suffix(output_path, ['.mp4', '.gif']): |
| 226 | self.temp_path = os.path.join( |