DeepRehab Angles
Angle calculation functions for rehabilitation exercises.
Overview
DeepRehab Angles is a Python package that provides functions for calculating joint angles from body landmarks. It's designed to work with pose estimation data for rehabilitation exercise analysis.
Features
- Calculate joint angles (knee, shoulder)
- Support for both left and right sides of the body
- Compatible with MediaPipe Pose landmark format
- Only uses Python built-in modules (math)
- Easy to integrate into rehabilitation applications
Installation
To install the package in development mode:
pip install -e .
To install from source:
python -m build
pip install dist/deeprehab_angles-0.1.0-py3-none-any.whl
Usage
from deeprehab_angles import knee_angle, shoulder_flexion_angle, Landmark
# Create a list of landmarks (typically from MediaPipe Pose)
landmarks = [Landmark(x, y, z, visibility) for _ in range(33)]
# Set specific landmarks for testing
landmarks[23] = Landmark(0.0, 2.0, 0.0, 1.0) # Left hip
landmarks[25] = Landmark(0.0, 1.0, 0.0, 1.0) # Left knee
landmarks[27] = Landmark(1.0, 1.0, 0.0, 1.0) # Left ankle
# Calculate left knee angle
knee_angle_left = knee_angle(landmarks, "left")
print(f"Left knee angle: {knee_angle_left:.1f}°")
# Set specific landmarks for shoulder
landmarks[12] = Landmark(0.0, 1.0, 0.0, 1.0) # Right shoulder
landmarks[14] = Landmark(0.0, 0.0, 0.0, 1.0) # Right elbow
landmarks[16] = Landmark(1.0, 0.0, 0.0, 1.0) # Right wrist
# Calculate right shoulder flexion angle
shoulder_angle_right = shoulder_flexion_angle(landmarks, "right")
print(f"Right shoulder flexion angle: {shoulder_angle_right:.1f}°")
API
Main Functions
knee_angle(landmarks, side)- Calculate knee flexion/extension angleshoulder_flexion_angle(landmarks, side)- Calculate shoulder flexion angle_angle_3p(a, b, c)- Calculate angle formed by three points
Data Classes
Landmark- Represents a body landmark with x, y, z coordinates and visibility
Testing
Run the tests with:
python -m pytest src/deeprehab_angles/test_angles.py
License
MIT
Metadata
Release files for deeprehab-angles 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deeprehab_angles-0.1.0.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deeprehab_angles-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 kB
Release files / deeprehab_angles-0.1.0.tar.gz
| Download URL | deeprehab_angles-0.1.0.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f142bfc8d77ebfda14c351db3c9c595b125e5184347006d1774adf78cddd1021
|
|
BLAKE2b-256 checksum How to use checksums |
46529fae705cfce560f9455e99c915b86e66517b87ac4014e08487f89d0ecebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / deeprehab_angles-0.1.0-py3-none-any.whl
| Download URL | deeprehab_angles-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e41ec546cf594251b6028df2a095324cf852dff655e61eba8fcbb8dbc906b69
|
|
BLAKE2b-256 checksum How to use checksums |
40c243e315ad343dc79c117e4b3032dcc3dbb0fdf9592b87ba6d4005a3875a99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|