{"id":29082257,"url":"https://github.com/devroopsaha744/yogafix","last_synced_at":"2026-04-18T14:32:38.927Z","repository":{"id":282863971,"uuid":"949882356","full_name":"devroopsaha744/YogaFix","owner":"devroopsaha744","description":"YogaFix is a real-time Yoga Pose detection and feedback system built using Python, OpenCV, and Mediapipe for pose estimation. The system is served via a FastAPI backend that captures webcam frames server-side, processes them to detect poses, and provides real-time feedback over WebSocket connections.","archived":false,"fork":false,"pushed_at":"2025-05-27T17:55:49.000Z","size":380,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-09T15:33:55.353Z","etag":null,"topics":["ai-trainer","computer-vision","fastapi","mediapie","opencv","pose-correction","pose-detection","pose-estimation","python","websockets","yoga"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/playlist?list=PLevupJ4B1q4Mn3YHLnyD1Q8_3HtMfyegf","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devroopsaha744.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-17T09:41:38.000Z","updated_at":"2025-12-15T03:53:22.000Z","dependencies_parsed_at":"2025-08-26T23:45:58.786Z","dependency_job_id":"1decd02a-c2b3-4d95-8ea0-55582ebb194b","html_url":"https://github.com/devroopsaha744/YogaFix","commit_stats":null,"previous_names":["devroopsaha744/yogifix","devroopsaha744/yogafix"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devroopsaha744/YogaFix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devroopsaha744%2FYogaFix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devroopsaha744%2FYogaFix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devroopsaha744%2FYogaFix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devroopsaha744%2FYogaFix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devroopsaha744","download_url":"https://codeload.github.com/devroopsaha744/YogaFix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devroopsaha744%2FYogaFix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31972337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-trainer","computer-vision","fastapi","mediapie","opencv","pose-correction","pose-detection","pose-estimation","python","websockets","yoga"],"created_at":"2025-06-27T20:05:21.803Z","updated_at":"2026-04-18T14:32:38.908Z","avatar_url":"https://github.com/devroopsaha744.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YogaFix\r\n\r\nYogaFix is a  **real-time** Yoga Pose detection and feedback system built using **Python**, **OpenCV**, and **Mediapipe** for pose estimation. The system is served via a **FastAPI** backend that captures webcam frames server-side, processes them to detect poses, and provides real-time feedback over WebSocket connections.\r\n\r\n\u003e **Important:** This version relies on **server-side webcam access** (using `cv2.VideoCapture(0)`). It must be deployed on hardware with an attached webcam (e.g., a local machine or a dedicated server/VPS with USB passthrough). Cloud platforms like Render or similar PaaS do not provide direct hardware access.\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- [Overview](#overview)\r\n- [Features](#features)\r\n- [Tech Stack](#tech-stack)\r\n- [Directory Structure](#directory-structure)\r\n- [How It Works](#how-it-works)\r\n- [API Endpoints](#api-endpoints)\r\n- [Running Locally](#running-locally)\r\n- [Performance \u0026 Concurrency Considerations](#performance--concurrency-considerations)\r\n- [Future Enhancements](#future-enhancements)\r\n- [License](#license)\r\n\r\n---\r\n\r\n## Overview\r\n\r\nThis module provides real-time feedback for yoga poses by:\r\n- Capturing webcam video directly on the server.\r\n- Processing each frame with a pose detection algorithm.\r\n- Comparing the user's pose to predefined “ideal” poses.\r\n- Returning annotated frames and detailed feedback over WebSockets.\r\n\r\nThe system is designed for scenarios where server-side processing is viable (e.g., dedicated hardware) and offers low-latency feedback for enhanced user interaction.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **Real-Time Processing:** Captures and processes frames from a physical webcam attached to the server.\r\n- **Multiple Pose Detection:** Supports a variety of yoga poses, including:\r\n  - T Pose\r\n  - Tree Pose\r\n  - Warrior 3 Pose\r\n  - Bridge Pose\r\n  - Cat Pose\r\n  - Cobra Pose\r\n  - Crescent Lunge Pose\r\n  - Downward Facing Dog Pose\r\n  - Leg-Up-The-Wall Pose\r\n  - Mountain Pose\r\n  - Padmasana (Lotus Pose)\r\n  - Pigeon Pose\r\n  - Seated Forward Bend\r\n  - Standing Forward Bend\r\n  - Triangle Pose\r\n  - Warrior Pose\r\n- **Detailed Feedback:** Computes similarity scores based on joint angles and generates corrective feedback.\r\n- **WebSocket Communication:** Uses FastAPI’s asynchronous WebSocket support for real-time bi-directional communication.\r\n- **CORS Enabled:** Easily integrates with separate front-end applications.\r\n\r\n---\r\n\r\n## Tech Stack\r\n\r\n- **Programming Language:** Python 3.x\r\n- **Backend Framework:** FastAPI\r\n- **WebSocket Server:** Uvicorn (ASGI server)\r\n- **Computer Vision:** OpenCV\r\n- **Pose Estimation:** Mediapipe\r\n- **Data Processing:** NumPy\r\n- **Asynchronous Programming:** asyncio\r\n\r\n---\r\n\r\n## Directory Structure\r\n\r\n```\r\nYogaModule/\r\n├─ api/\r\n│  └─ main.py               # FastAPI application with server-side webcam processing\r\n├─ logic/\r\n│  ├─ __init__.py\r\n│  ├─ T_pose.py           # T Pose detection logic\r\n│  ├─ traingle_pose.py    # Triangle Pose detection logic\r\n│  ├─ Tree_pose.py        # Tree Pose detection logic\r\n│  ├─ Crescent_lunge_pose.py  # Crescent Lunge detection logic\r\n│  ├─ warrior_pose.py     # Warrior Pose detection logic\r\n│  └─ mountain_pose.py    # Mountain Pose detection logic\r\n├─ tests/\r\n|    └─index.htm          # Client side code to test the API\r\n└─ README.md              # This README file\r\n```\r\n\r\n- **`web-app/app.py`**: Contains the FastAPI backend which captures frames from a server-side webcam, processes them, and sends back annotated frames and feedback.\r\n- **`logic/`**: Contains the pose checker classes that perform frame processing, angle calculations, and generate feedback.\r\n\r\n---\r\n\r\n## How It Works\r\n\r\n1. **Webcam Capture:**  \r\n   The API opens a connection to a physical webcam using `cv2.VideoCapture(0)`.\r\n\r\n2. **Frame Processing:**  \r\n   - Each frame is read, flipped for a mirror view, and passed to a selected pose checker.\r\n   - The pose checker uses Mediapipe to extract landmarks and compute joint angles.\r\n   - A similarity score is calculated by comparing the user's pose with the ideal pose.\r\n   - Annotated frames are generated by drawing landmarks using Mediapipe’s drawing utilities.\r\n\r\n3. **WebSocket Communication:**  \r\n   - The processed frame (encoded as a JPEG and then base64) and the feedback (similarity score, joint details, textual corrections) are sent back to the client via a WebSocket connection.\r\n   - A connection manager handles multiple clients and processing tasks concurrently.\r\n\r\n---\r\n\r\n## API Endpoints\r\n\r\n### WebSocket Endpoint\r\n\r\n- **URL:** `/ws/{client_id}`\r\n- **Method:** WebSocket\r\n- **Description:**  \r\n  When a client connects and sends a JSON message containing a `\"pose_type\"`, the API starts processing frames from the server-side webcam. It continuously sends back a JSON response containing:\r\n  - **`frame`**: Base64-encoded annotated JPEG image.\r\n  - **`feedback`**: An object with:\r\n    - `similarity`: A float value representing overall pose similarity.\r\n    - `feedback_text`: A textual description of the feedback.\r\n    - `joint_similarities`: Detailed feedback per joint (if applicable).\r\n\r\n- **Stop Command:**  \r\n  Clients can send `{\"command\": \"stop\"}` to disconnect and stop processing.\r\n\r\n### Health Check Endpoint\r\n\r\n- **URL:** `/health`\r\n- **Method:** GET\r\n- **Description:**  \r\n  Returns a JSON response indicating the server status.\r\n  ```json\r\n  {\r\n    \"status\": \"healthy\"\r\n  }\r\n  ```\r\n\r\n---\r\n\r\n## Running Locally\r\n\r\n1. **Clone the Repository:**\r\n   ```bash\r\n   git clone https://github.com/yourusername/YogaModule.git\r\n   cd YogaModule\r\n   ```\r\n\r\n2. **Set Up a Virtual Environment (Optional but Recommended):**\r\n   ```bash\r\n   python -m venv venv\r\n   source venv/bin/activate  # For Linux/Mac\r\n   # or venv\\Scripts\\activate   # For Windows\r\n   ```\r\n\r\n3. **Install Dependencies:**\r\n   ```bash\r\n   pip install fastapi uvicorn opencv-python mediapipe numpy\r\n   ```\r\n   \u003e If a `requirements.txt` is available, run:  \r\n   \u003e `pip install -r requirements.txt`\r\n\r\n4. **Run the FastAPI Server:**\r\n   ```bash\r\n   cd web-app\r\n   uvicorn app:app --reload --host 0.0.0.0 --port 8000\r\n   ```\r\n   The server will start at **http://localhost:8000**.\r\n\r\n5. **Connect a WebSocket Client:**\r\n   Use a WebSocket client or a browser-based front-end to connect to `ws://localhost:8000/ws/{client_id}` and send JSON messages as described.\r\n\r\n\u003e **Note:** Ensure that the machine running the server has a webcam attached. If `cv2.VideoCapture(0)` fails, verify the webcam index or hardware permissions.\r\n\r\n---\r\n\r\n## Performance \u0026 Concurrency Considerations\r\n\r\n- **CPU-Intensive Processing:**  \r\n  Frame processing (especially with OpenCV and Mediapipe) is CPU-bound. For multiple concurrent connections, consider:\r\n  - Offloading heavy computations to separate worker threads or processes.\r\n  - Horizontal scaling (running multiple instances) if using dedicated hardware.\r\n\r\n- **Vertical Scaling:**  \r\n  Since server-side webcam processing avoids network transmission delays and base64 overhead from the client, it can offer faster processing. However, vertical scaling (upgrading CPU/RAM) is crucial if many clients connect concurrently.\r\n\r\n- **Hardware Constraints:**  \r\n  This approach requires a physical webcam. In cloud environments, server-side webcam access is typically not available, so this setup is best suited for dedicated hardware or on-premise servers.\r\n\r\n---\r\n\r\n## Demo Videos\r\nDemo of the project can be seen in this [playlist](https://www.youtube.com/playlist?list=PLevupJ4B1q4Mn3YHLnyD1Q8_3HtMfyegf)\r\n\r\n## Future Enhancements\r\n\r\n- **GPU Acceleration:**  \r\n  Integrate CUDA/TensorRT to speed up pose estimation on GPUs.\r\n\r\n- **Asynchronous Processing:**  \r\n  Use thread pools or asynchronous libraries to better handle CPU-bound tasks without blocking the event loop.\r\n\r\n- **Client-Side Integration:**  \r\n  Develop a web or mobile front-end that dynamically connects via WebSockets for real-time feedback.\r\n\r\n- **Support for Multiple Cameras:**  \r\n  Extend the module to support multiple simultaneous camera inputs or multiple users.\r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevroopsaha744%2Fyogafix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevroopsaha744%2Fyogafix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevroopsaha744%2Fyogafix/lists"}