https://github.com/javtahir/live-measurements-api
API to extract body measurements from front and side images using computer vision.
https://github.com/javtahir/live-measurements-api
body-measurement-api computer-vision flask image-processing pose-estimation
Last synced: 3 days ago
JSON representation
API to extract body measurements from front and side images using computer vision.
- Host: GitHub
- URL: https://github.com/javtahir/live-measurements-api
- Owner: JavTahir
- License: mit
- Created: 2025-06-13T10:24:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-13T10:44:38.000Z (about 1 year ago)
- Last Synced: 2025-09-04T00:42:54.530Z (10 months ago)
- Topics: body-measurement-api, computer-vision, flask, image-processing, pose-estimation
- Language: Python
- Homepage:
- Size: 250 KB
- Stars: 2
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AI-Based Human Body Measurement System for Tailoring & Fashion E-Commerce
This project is a real-time body measurement API built with **Flask**, **MediaPipe**, **OpenCV**, and **PyTorch**. By analyzing **front and side pose images** of a person, it calculates accurate human body measurements useful for tailoring, clothing size prediction, and virtual fitting rooms.
> đ¸ Just send **front and side pose images** (captured using a smartphone or webcam) to this API, and receive key body measurements in centimeters â perfect for fashion retail platforms and tailor-made garment businesses.
---
## Features
- Real-time image-based body measurement
- AI-powered depth estimation using **MiDaS**
- Measurement accuracy with a deviation of **Âą2-3 cm**
- Calibrates scale using an **A4 paper** as a reference object
- Easily integratable into fashion e-commerce or tailoring platforms
- No external APIs â runs entirely on your local or server environment
---
## Libraries Used
| Library | Purpose |
|----------------|-------------------------------------------------------------------------|
| `Flask` | To expose a simple HTTP API |
| `OpenCV` | For image processing and contour detection |
| `MediaPipe` | For pose landmark detection (shoulders, hips, etc.) |
| `PyTorch` | For AI-based **depth estimation** using [MiDaS](https://github.com/isl-org/MiDaS) |
| `torchvision` | Support for model loading & image transformations |
---
# How It Works
1. Detects key landmarks using **MediaPipe Pose** (shoulders, hips, knees, ankles).
2. Uses **A4 paper** in the image to calibrate real-world scale from pixels.
3. Enhances width and depth estimation using the **MiDaS depth AI model**.
4. Calculates measurements using geometric approximations (**elliptical body model**).
5. Returns measurement data in **JSON format**.
## How to Run
```bash
pip install -r requirements.txt
python app.py
```
# API Endpoint
**POST** `/measurements`
> âšī¸ For reference, see the images placed in the root directory.
---
## Request
Send a `multipart/form-data` **POST** request with the following fields:
- **`front_image`**: JPEG/PNG image captured from the front *(required)*
- **`side_image`** *(optional)*: JPEG/PNG image from the side *(for better accuracy)*
- **`user_height_cm`** : Real height of the person (in cm) for more precise calibration
---
### Example using `curl`
```bash
curl -X POST http://localhost:5000/measurements \
-F "front_image=@front.jpg" \
-F "side_image=@side.jpg" \
-F "user_height_cm=170"
```
# Measurements Provided
| **Measurement Name** | **Description** |
|--------------------------|-------------------------------------------------------------------|
| `shoulder_width` | Distance between left and right shoulders |
| `chest_width` | Width at chest level |
| `chest_circumference` | Estimated chest circumference |
| `waist_width` | Width at waist level |
| `waist` | Estimated waist circumference |
| `hip_width` | Distance between left and right hips |
| `hip_circumference` | Estimated hip circumference *(if side image is given)* |
---
> đ **Note:**
> The system uses **AI depth maps** and **contour-based width detection**.
> Final measurements may have a **Âą2â3 cm variance** depending on image quality and user alignment.
# Integration in Fashion E-Commerce
This solution is plug-and-play for:
- **E-commerce brands** offering size suggestions or virtual try-ons.
- **Tailoring platforms** wanting remote client measurements.
- **Clothing manufacturers** personalizing size charts for customers.
- **Fashion mobile apps** for custom-fitted clothing suggestions.
Simply integrate this API into your frontend â mobile or web â to collect two photos and retrieve exact measurements.
## đ¤ Contributions
PRs and suggestions are welcome! Fork this repo, raise an issue, or open a pull request.
## đ License
MIT License. Feel free to use this for personal or commercial projects â just give credit.