diff --git a/.gitignore b/.gitignore index 62c8935..f32e31a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +.DS_Store diff --git a/src/js/pose_viewer/package.json b/src/js/pose_viewer/package.json index 12b53b3..24f7c48 100644 --- a/src/js/pose_viewer/package.json +++ b/src/js/pose_viewer/package.json @@ -2,6 +2,7 @@ "name": "pose-viewer", "version": "0.10.0", "description": "Stencil Component Starter", + "homepage": "https://github.com/sign-language-processing/pose", "main": "dist/index.cjs.js", "module": "dist/index.js", "es2015": "dist/esm/index.mjs", diff --git a/src/python/pose_format/pose_body.py b/src/python/pose_format/pose_body.py index cdd53be..ca0a0da 100644 --- a/src/python/pose_format/pose_body.py +++ b/src/python/pose_format/pose_body.py @@ -2,6 +2,7 @@ from typing import BinaryIO, List, Tuple import numpy as np +import math from pose_format.pose_header import PoseHeader from pose_format.utils.reader import BufferReader, ConstStructs @@ -192,6 +193,8 @@ def read_v0_2(cls, reader: BufferReader, start_frame: int = None, end_frame: int = None, + start_time: int = None, + end_time: int = None, **unused_kwargs) -> "PoseBody": """ Reads pose data for version 0.2 from a buffer. @@ -206,6 +209,10 @@ def read_v0_2(cls, Index of the first frame to read. Default is None. end_frame : int, optional Index of the last frame to read. Default is None. + start_time : int, optional + Start time of the pose data (in milliseconds). Default is None. + end_time : int, optional + End time of the pose data (in milliseconds). Default is None. **unused_kwargs : dict Unused additional parameters for this version. @@ -214,6 +221,12 @@ def read_v0_2(cls, PoseBody PoseBody object initialized with the read data for version 0.2. """ + + if start_time is not None and start_frame is not None: + raise ValueError("Cannot specify both start_time and start_frame") + if end_time is not None and end_frame is not None: + raise ValueError("Cannot specify both end_time and end_frame") + fps = reader.unpack(ConstStructs.float) # Changed from v0.1, uint -> float _frames = reader.unpack(ConstStructs.uint) # Changed from v0.1, ushort -> uint @@ -221,6 +234,11 @@ def read_v0_2(cls, _points = sum([len(c.points) for c in header.components]) _dims = header.num_dims() + if start_time is not None: + start_frame = math.floor(start_time / 1000 * fps) + if end_time is not None: + end_frame = math.ceil(end_time / 1000 * fps) + data = cls.read_v0_1_frames(_frames, (_people, _points, _dims), reader, start_frame, end_frame) confidence = cls.read_v0_1_frames(_frames, (_people, _points), reader, start_frame, end_frame)