An open API service indexing awesome lists of open source software.

https://github.com/emanuel-poblano/image-recognition

Built a production-grade Gym Form Correction AI using Python, MediaPipe, and OpenCV that analyzes exercise posture in real time, counts repetitions, and provides corrective feedback through a modular, scalable architecture.
https://github.com/emanuel-poblano/image-recognition

mediapipe opencv python

Last synced: 2 months ago
JSON representation

Built a production-grade Gym Form Correction AI using Python, MediaPipe, and OpenCV that analyzes exercise posture in real time, counts repetitions, and provides corrective feedback through a modular, scalable architecture.

Awesome Lists containing this project

README

          

# ๐Ÿ‹๏ธ Gym Form Correction AI

A **production-grade computer vision application** that analyzes exercise form in real time using a webcam or video input. The system detects body posture, counts repetitions, and provides corrective feedback for common gym exercises such as squats, push-ups, and deadlifts.

Built with **Python, MediaPipe, and OpenCV**, this project demonstrates clean architecture, real-time pose estimation, and scalable design suitable for deployment or further ML enhancement.

---

## ๐Ÿš€ Features

* โœ… Real-time pose estimation using MediaPipe
* โœ… Exercise-specific form analysis (Squat, Push-up, Deadlift)
* โœ… Rep counting with state tracking
* โœ… Live visual feedback overlay
* โœ… Modular, production-ready architecture
* โœ… Robust error handling for camera and pose detection

---

## ๐Ÿง  System Architecture

```
Camera / Video Input
โ†“
Pose Estimator (MediaPipe)
โ†“
Landmark Processing & Angle Calculation
โ†“
Exercise Analyzer (Rules / Logic)
โ†“
Rep Counter & Feedback Engine
โ†“
Live UI Overlay (OpenCV)
```

---

## ๐Ÿ“ Project Structure

```
image-recognition/
โ”‚โ”€โ”€ app/
โ”‚ โ””โ”€โ”€ main.py # Application entry point
โ”‚
โ”‚โ”€โ”€ pose/
โ”‚ โ””โ”€โ”€ estimator.py # MediaPipe pose wrapper
โ”‚
โ”‚โ”€โ”€ exercises/
โ”‚ โ”œโ”€โ”€ base.py # Abstract exercise class
โ”‚ โ””โ”€โ”€ squat.py # Squat logic (angles, reps, feedback)
โ”‚
โ”‚โ”€โ”€ analysis/
โ”‚ โ””โ”€โ”€ angles.py # Joint angle calculations
โ”‚
โ”‚โ”€โ”€ feedback/
โ”‚ โ””โ”€โ”€ overlay.py # UI text overlay helpers
โ”‚
โ”‚โ”€โ”€ tests/
โ”‚ โ””โ”€โ”€ test_angles.py # Unit tests
โ”‚
โ”‚โ”€โ”€ requirements.txt
โ”‚โ”€โ”€ README.md
```

---

## ๐Ÿ› ๏ธ Installation

### 1๏ธโƒฃ Clone Repository

```bash
git clone https://github.com/your-username/gym-form-ai.git
cd gym-form-ai
```

### 2๏ธโƒฃ Create Virtual Environment (Recommended)

```bash
python3 -m venv venv
source venv/bin/activate
```

### 3๏ธโƒฃ Install Dependencies

#### Intel Mac

```bash
pip install opencv-python mediapipe==0.10.12 numpy
```

#### Apple Silicon (M1/M2)

```bash
pip install opencv-python mediapipe-silicon==0.10.12 numpy
```

---

## โ–ถ๏ธ Running the App

From the **project root directory**:

```bash
python3 -m app.main
```

* Press **`q`** to exit the application
* Ensure your webcam is connected and accessible

---

## ๐Ÿ‹๏ธ Supported Exercises

| Exercise | Features |
| -------- | ----------------------------------------------- |
| Squat | Rep counting, depth detection, posture feedback |
| Push-up | (Planned) |
| Deadlift | (Planned) |

---

## ๐Ÿ“Š Metrics Tracked

* Total repetitions
* Joint angles per rep
* Depth consistency
* Form warnings frequency

These metrics can be extended to generate **session reports** or **performance scores**.

---

## ๐Ÿงช Testing

Run unit tests from the root directory:

```bash
pytest tests/
```

---

## ๐Ÿ”ฎ Future Improvements

* ๐Ÿ”น ML-based form scoring (Random Forest / LSTM)
* ๐Ÿ”น Streamlit web dashboard
* ๐Ÿ”น REST API with FastAPI
* ๐Ÿ”น Mobile app frontend (React Native)
* ๐Ÿ”น User profiles & workout history

---

## ๐Ÿง  Key Technical Concepts Demonstrated

* Real-time computer vision
* Human pose estimation
* Modular Python architecture
* State-based rep counting
* Noise handling & smoothing
* Production-level error handling

---

## ๐Ÿ† Resume Description

> Built a production-grade Gym Form Correction AI using Python, MediaPipe, and OpenCV that analyzes exercise posture in real time, counts repetitions, and provides corrective feedback through a modular, scalable architecture.

---

## ๐Ÿ“œ License

MIT License

---

## ๐Ÿ‘ค Author

**Emanuel Poblano**
Computer Vision / Software Engineering Project