Angle calculation functions for rehabilitation exercises
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deeprehab_angles-0.1.0.tar.gz.
File metadata
- Download URL: deeprehab_angles-0.1.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f142bfc8d77ebfda14c351db3c9c595b125e5184347006d1774adf78cddd1021
|
|
| MD5 |
27443cecdff79a66b3b9bf0af3cfc172
|
|
| BLAKE2b-256 |
46529fae705cfce560f9455e99c915b86e66517b87ac4014e08487f89d0ecebb
|
File details
Details for the file deeprehab_angles-0.1.0-py3-none-any.whl.
File metadata
- Download URL: deeprehab_angles-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e41ec546cf594251b6028df2a095324cf852dff655e61eba8fcbb8dbc906b69
|
|
| MD5 |
cf476991a5ad71aa264115266029e229
|
|
| BLAKE2b-256 |
40c243e315ad343dc79c117e4b3032dcc3dbb0fdf9592b87ba6d4005a3875a99
|