diff --git a/README.md b/README.md index 78a46d0..2702b8b 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Maintaining data consistency is very important and data normalization is one met For instance, you can set the shoulder width to a consistent measurement across all data points. This is useful for comparing poses across different individuals. -* See this example for using a standard body feature, such as the shoulder width, for normalization: +* See this example for manually specifying a standard body feature, such as the shoulder width, for normalization: ```python pose.normalize(p.header.normalization_info( @@ -106,6 +106,12 @@ pose.normalize(p.header.normalization_info( )) ``` +* If normalization info is not specified, normalize() will automatically base normalization on shoulder joints. + +```python +pose.normalize() # same result as above, but attempts to automatically select shoulder points based on format +``` + * Keypoint values can be standardized to have a mean of zero and unit variance: ```python @@ -116,7 +122,6 @@ pose.normalize_distribution() The usual way to do this is to compute a separate mean and standard deviation for each keypoint and each dimension (usually x and y). This can be achieved with the `axis` argument of `normalize_distribution`. - ```python # Normalize each keypoint separately: diff --git a/src/python/pose_format/pose.py b/src/python/pose_format/pose.py index 1740d77..5dbad62 100644 --- a/src/python/pose_format/pose.py +++ b/src/python/pose_format/pose.py @@ -10,6 +10,7 @@ PoseNormalizationInfo) from pose_format.utils.fast_math import distance_batch from pose_format.utils.reader import BufferReader +from pose_format.utils.generic import pose_normalization_info class Pose: @@ -87,7 +88,7 @@ def focus(self): dimensions = (maxs - mins).tolist() self.header.dimensions = PoseHeaderDimensions(*dimensions) - def normalize(self, info: PoseNormalizationInfo, scale_factor: float = 1) -> "Pose": + def normalize(self, info: PoseNormalizationInfo|None=None, scale_factor: float = 1) -> "Pose": """ Normalize the points to a fixed distance between two particular points. @@ -103,6 +104,9 @@ def normalize(self, info: PoseNormalizationInfo, scale_factor: float = 1) -> "Po Pose The normalized Pose object. """ + if info is None: + info = pose_normalization_info(self) + transposed = self.body.points_perspective() p1s = transposed[info.p1]