
Overview
Ignitix is a Python-based AI workout manager designed to guide users through fitness routines using real-time computer vision. It provides posture analysis, counts repetitions, and visualizes performance using meaningful graphs. The solution uses OpenCV, MediaPipe, NumPy, and Pandas to track movements, detect body landmarks, and analyze posture through joint angle calculations.
Project Idea & Objective
The core idea behind Ignitix is to help fitness enthusiasts, especially beginners, maintain proper form during exercises like pull-ups. Poor posture can lead to injuries or ineffective workouts. Ignitix ensures:
- Accurate posture detection using camera feed.
- Real-time feedback on movements.
- Automatic rep counting using joint angle thresholds.
- Visualization of performance and progress.
Ignitix acts as a virtual fitness trainer that ensures form correctness and helps track improvement over time.
Technologies Used
- Python: Primary programming language.
- OpenCV: Video capture, rendering, and drawing feedback overlays.
- MediaPipe: Body landmark detection.
- NumPy: Angle calculation and vector math.
- Pandas: Logging session data and generating analytics.
- Matplotlib / Seaborn: Plotting session insights.
Code Breakdown
- Angle Calculation Function
Calculates the angle between joints using the dot product and vector subtraction.
Used to track motion and determine whether a rep is complete.
def calculate_angle(a, b, c):
a = np.array(a)
b = np.array(b)
c = np.array(c)
radians = math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0])
angle = np.abs(radians * 180.0 / math.pi)
if angle > 180.0:
angle = 360 - angle
return angle
- Frame Preprocessing
Prepares frame for pose detection and converts color formats as required by MediaPipe and OpenCV.
def process_frame(frame, pose):
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image.flags.writeable = False
results = pose.process(image)
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
return image, results, height, width
- Landmark Extraction
Retrieves specific body joints based on the workout type.
def extract_landmarks(results):
landmarks = results.pose_landmarks.landmark
wrist = [...]
shoulder = [...]
hip = [...]
return wrist, shoulder, hip
- Angle-Based Rep Counting Logic
Logic to transition between stages and count reps.
def calculate_and_display_angle(wrist, shoulder, hip, stage, counter):
angle = calculate_angle(wrist, shoulder, hip)
if angle > 160:
stage = "Pull Down"
if angle < 70 and stage == 'Pull Down':
stage = "Pull Up"
counter += 1
return angle, stage, counter
- UI Rendering (Live Feedback)
Visual overlay for users during the session.
def render_ui(image, counter, stage, angle, width):
# Draw progress bar, counts, stages, etc.
- Main Execution Loop
Orchestrates all components and displays live annotated video.
def run_pose_detection(...):
while cap.isOpened():
frame = cap.read()
landmarks = extract_landmarks(...)
angle, stage, counter = calculate_and_display_angle(...)
image = render_ui(...)
display image in OpenCV window
Sample Output Visualizations (Generated from Simulated Data)
- Line Plot
Shows how reps increase over time.

- Histogram
Distribution of joint angles during the session.
Helps identify consistency in form.

- Boxplot
Visualizes spread and outliers in angles.
Ideal for identifying inconsistent movements.

- Scatter Plot
Plots reps vs. average angle.
Shows how tight the user's range of motion is.

- Bar Graph
Each bar represents activity in a 10-second window.
Helps visualize bursts of effort or breaks.

- Annotated Time Series Graph
Plots joint angles over time.
Vertical lines mark completed reps.
Provides rhythm and tempo analysis.

- Heatmap
Based on posture deviation per frame.
Red areas indicate common posture faults.

Time (s) | Reps | Joint Angle (Β°) |
---|
0 | 0 | 160 |
5 | 1 | 90 |
10 | 1 | 65 |
15 | 2 | 160 |
20 | 2 | 70 |
25 | 3 | 160 |
30 | 4 | 60 |
35 | 4 | 160 |
40 | 5 | 68 |
45 | 5 | 160 |
50 | 6 | 65 |
55 | 7 | 160 |
Impact and Applications
- Fitness Beginners: Form correction.
- Rehabilitation: Monitoring recovery movements.
- Remote Coaching: Feedback for online training.
- Gamified Fitness: Motivation via UI interaction.
Future Enhancements
- Add voice prompts and feedback.
- Add pose classification to support various workouts.
- Upload user sessions to the cloud.
- Build a leaderboard and social sharing.
Code Integration and Explanation of Complete System
This section discusses how the final integrated code (run_pose_detection function) brings together the modules into a seamless system:
- Imports and Constants: All necessary libraries like math, cv2, mediapipe, numpy, and time are imported. Colors are defined for UI rendering.
- calculate_angle: Computes angle between joints using vector math and math.atan2.
- display_time: Tracks elapsed time since the session began and displays it on the screen.
- process_frame: Converts frame to RGB for pose detection, processes landmarks using MediaPipe Pose, and returns image with landmark data.
- extract_landmarks: Extracts keypoints β in this case, LEFT_HIP, LEFT_KNEE, and LEFT_ANKLE β essential for analyzing deadlifts or squats.
- calculate_and_display_angle: Uses the extracted landmarks to compute angles and determines repetition logic. When a user goes from a standing position (>170Β°) to a squat (<145Β°), a rep is counted.
- render_ui: Draws the UI components like progress bar, angle percentage, rep counter, and current stage. Makes it interactive and motivating.
- run_pose_detection: Opens video stream, processes each frame, applies landmark detection, tracks rep count, displays UI and angle, and breaks on key press.
-Main Execution: Ties everything together by calling run_pose_detection with a sample video input ('assets/deadlift.mp4').
Conclusion
Ignitix demonstrates how AI and computer vision can make fitness training more effective and safe. With real-time posture detection, automated repetition tracking, and insightful visual analytics, users can receive instant feedback and long-term performance analysisβturning a simple webcam into a personal trainer assistant.
