Downloads · 30 days
0
mdashraf9723/body3d-realsense-measurements
body3d-realsense-measurements is a machine learning model from mdashraf9723. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Automated body measurement extraction from .bag files recorded with the Intel RealSense D455 depth camera. Captures from 3 viewpoints (front, left, right) are fused into a unified 3D body scan, from which anthropometr…
Downloads · 30 days
0
Access
Public
Updated Apr 24, 2026
Repo size
—
Likes
1
Public
Click a slice to open those files.
.py40 KB · 77%
From the Hugging Face model README
Automated body measurement extraction from .bag files recorded with the Intel RealSense D455 depth camera. Captures from 3 viewpoints (front, left, right) are fused into a unified 3D body scan, from which anthropometric measurements are computed.
| Measurement | Method | Typical Accuracy |
|---|---|---|
| Height | Point cloud bounding box + landmark validation | < 1% error |
| Weight | Body volume integration × density (985 kg/m³) | ~5-10% error |
| Neck Circumference | Cross-section slice + radial filtering | ~10-15% error |
| Chest Circumference | Cross-section slice with torso isolation | ~5-10% error |
| Waist Circumference | Narrowest torso cross-section | ~5-10% error |
| Hip Circumference | Widest cross-section at hip level | ~5% error |
| Wrist Circumference | Forearm-perpendicular cross-section | < 2% error |
| Shoulder Width | Bi-acromial landmark distance | < 1% error |
| BMI | Derived from height + estimated weight | — |
# Clone the repo
git clone https://huggingface.co/mdashraf9723/body3d-realsense-measurements
cd body3d-realsense-measurements
# Install Python packages
pip install -r requirements.txt
# On Ubuntu/Debian, you also need:
sudo apt-get install libgl1-mesa-glx libglib2.0-0
Headless server? Use
pip install open3d-cpuinstead ofopen3d.
Set up your D455 camera at 3 positions around the person:
[LEFT CAM]
↓ (90°)
🧍 ← Person (arms slightly out, A-pose)
[FRONT CAM] → ← [RIGHT CAM]
(0°) (-90°)
Option A — Using Intel RealSense Viewer:
front.bagleft.bagright.bagOption B — Using Python script:
import pyrealsense2 as rs
import time
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 1280, 720, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 1280, 720, rs.format.bgr8, 30)
config.enable_record_to_file("front.bag") # change name for each view
pipeline.start(config)
time.sleep(5) # Record 5 seconds
pipeline.stop()
print("Done!")
Recording Tips:
Put your .bag files in the same folder as the scripts, then run:
python pipeline.py \
--front front.bag \
--left left.bag \
--right right.bag \
--output my_measurements.json
python pipeline.py \
--front front.bag \
--left left.bag \
--right right.bag \
--angles 0 -90 90 \
--output my_measurements.json
python pipeline.py --bag front.bag --output my_measurements.json
python pipeline.py --demo
The output my_measurements.json will look like:
{
"height_cm": 175.0,
"estimated_weight_kg": 72.5,
"bmi": 23.7,
"neck_circumference_cm": 38.2,
"chest_circumference_cm": 94.5,
"waist_circumference_cm": 82.1,
"hip_circumference_cm": 96.3,
"wrist_circumference_cm": 16.4,
"shoulder_width_cm": 44.0
}
It also prints a formatted table in the terminal:
============================================================
BODY MEASUREMENTS
============================================================
Height............................. 175.0 cm
Estimated Weight................... 72.5 kg
BMI................................ 23.7
----------------------------------------
Neck Circumference................. 38.2 cm
Chest Circumference................ 94.5 cm
Waist Circumference................ 82.1 cm
Hip Circumference.................. 96.3 cm
Wrist Circumference................ 16.4 cm
----------------------------------------
Shoulder Width..................... 44.0 cm
============================================================
| What you have | Command |
|---|---|
3 .bag files (front, left, right) | python pipeline.py --front front.bag --left left.bag --right right.bag |
1 .bag file | python pipeline.py --bag recording.bag |
| No camera, just testing | python pipeline.py --demo |
python pipeline.py --help
Options:
--demo Run with synthetic test data (no camera needed)
--bag FILE Single .bag file path
--front FILE Front view .bag file
--left FILE Left view .bag file
--right FILE Right view .bag file
--angles FLOAT... Camera angles in degrees (e.g. 0 -90 90)
--output FILE Output JSON path (default: measurements.json)
--voxel-size FLOAT Point cloud resolution in meters (default: 0.01)
--max-depth FLOAT Max depth from camera in meters (default: 3.0)
--save-ply FILE Save merged point cloud to PLY file
.bag files (3 views) → bag_reader.py → registration.py → landmarks.py → measurements.py → JSON output
Modules:
.bag files via pyrealsense2, applies spatial/temporal/hole-filling filters, extracts aligned depth+color frames, generates Open3D point clouds with camera intrinsicsbody3d-realsense-measurements/
├── pipeline.py # Main entry point (CLI)
├── bag_reader.py # Module 1: RealSense .bag file reader
├── registration.py # Module 2: Multi-view point cloud registration
├── landmarks.py # Module 3: MediaPipe body landmarks
├── measurements.py # Module 4: Body measurement computation
├── requirements.txt # Python dependencies
└── README.md # This file
For each body measurement (chest, waist, hip, neck, wrist):
Three methods combined with weighted average:
Tested on synthetic body with known ground truth dimensions:
✓ height_cm.............. GT: 175.0 Est: 175.0 Err: 0.0 (0.0%)
✓ chest_circumference.... GT: 94.2 Est: 85.7 Err: 8.5 (9.1%)
✓ waist_circumference.... GT: 81.7 Est: 85.6 Err: 3.9 (4.7%)
✓ hip_circumference...... GT: 97.4 Est: 93.1 Err: 4.3 (4.5%)
⚠ neck_circumference..... GT: 37.7 Est: 43.0 Err: 5.3 (14.2%)
✓ wrist_circumference.... GT: 15.7 Est: 15.6 Err: 0.1 (0.7%)
✓ shoulder_width......... GT: 44.0 Est: 44.0 Err: 0.0 (0.0%)
For higher accuracy (~1-2cm error), you can integrate SMPL body model fitting:
smplx: pip install smplxpip install git+https://github.com/DavidBoja/SMPL-AnthropometryThe pipeline can be extended to fit SMPL to the merged point cloud and extract measurements from the parametric mesh, giving more precise circumferences through anatomical priors.