Day 79: Implementing calibration: math and code
Calibration in the pipeline
Wire calibration into the measurement flow: take the user's height, compute the scale factor from their pixel height, and convert every pixel measurement to centimeters β propagating confidence through. Add guardrails: if the pose isn't upright/in-frame (detectable from keypoint geometry), lower confidence or ask for a better photo rather than returning a confidently-scaled wrong number.
def calibrated_measurements(pose, mask, parsing, real_height_cm):
quality = pose_quality(pose) # upright? in-frame? fronto-parallel?
if quality < 0.6:
return {"error": "pose_unsuitable_for_measurement", "quality": quality}
scale = scale_factor_cm_per_px(pose, real_height_cm)
px = fuse_measurements(pose, mask, parsing)
return {
name: {
"cm": round(m["px"] * scale, 1),
"confidence": round(m["confidence"] * quality, 3), # fold in pose quality
"sources": m["sources"],
}
for name, m in px.items()
}Confidence now reflects calibration quality too
The final confidence multiplies keypoint visibility (Day 59) by pose quality (calibration suitability). A measurement is only as good as both its keypoints *and* the calibration that scaled it. Threading both into one honest number is the culmination of the confidence-propagation discipline you've built since Day 57.
Key terms
- Pose quality gate
- A check on whether the pose is suitable for measurement (upright, in-frame), gating or down-weighting output.
- Calibrated measurement
- A pixel measurement converted to real units via the scale factor, with confidence reflecting both keypoint and calibration quality.
Why fold pose quality into the final measurement confidence, on top of keypoint visibility?