expo-arkit-body-measurements
v1.4.1
Published
Expo module for ARKit body measurements using LiDAR
Maintainers
Readme
expo-arkit-body-measurements
📱 Expo module for ARKit body measurements using LiDAR sensor on iOS devices.
Features
- 🎯 Capture 3 body measurements using ARKit body tracking
- Shoulder-to-shoulder distance (horizontal)
- Waist circumference (estimated)
- Waist-to-shoulder length (vertical)
- 📷 Uses iPhone/iPad rear camera + LiDAR sensor
- ⚡ Real-time body detection and measurement
- 🔒 Measurements saved locally with AsyncStorage
Requirements
- iPhone or iPad Pro with LiDAR sensor (iPhone 12 Pro or newer, iPad Pro 2020 or newer)
- iOS 14.0+
- Expo SDK 48+
- Expo development build (not compatible with Expo Go)
Installation
npm install expo-arkit-body-measurementsConfiguration
1. Run prebuild
npx expo prebuild --platform ios2. ⚠️ Manual registration required
Due to Expo autolinking limitations, you need to manually register the module.
Edit ios/Pods/Target Support Files/Pods-{YourAppName}/ExpoModulesProvider.swift:
Add the import:
import expo_arkit_body_measurementsAdd to both module arrays (DEBUG and RELEASE sections):
ExpoArkitBodyMeasurements.self,3. Install pods and build
npx pod-install ios
npx expo run:ios --deviceUsage
import {
startMeasurement,
stopMeasurement,
addMeasurementCompleteListener,
ARKitPreviewView,
} from "expo-arkit-body-measurements";
// Start measurement
startMeasurement();
// Listen for results
const subscription = addMeasurementCompleteListener((event) => {
console.log("Measurements:", event);
// {
// shoulderToShoulder: 42.5, // cm
// waist: 85.2, // cm
// shirtLength: 65.8 // cm
// }
});
// Use ARKit preview component
<ARKitPreviewView
style={{ flex: 1 }}
isActive={true}
onBodyDetected={(event) => console.log("Body detected!")}
onMeasurementReady={(event) => console.log("Measurement ready:", event)}
/>
// Cleanup
subscription.remove();
stopMeasurement();Example Component
Check the example implementation in the package for a complete modal-based measurement flow with UI.
API
Functions
startMeasurement()- Start ARKit body tracking sessionstopMeasurement()- Stop tracking sessiongetMeasurements()- Get current measurements (if available)
Events
onMeasurementComplete- Fired when measurements are capturedonMeasurementProgress- Fired during measurement process
Components
ARKitPreviewView- Native AR camera preview component- Props:
isActive,style,onBodyDetected,onMeasurementReady
- Props:
Troubleshooting
Module not found error:
- Make sure you've manually registered the module in
ExpoModulesProvider.swift - Run
npx expo prebuild --cleanand retry
Camera not working:
- Ensure you have camera permissions configured in
app.json:
{
"ios": {
"infoPlist": {
"NSCameraUsageDescription": "This app uses the camera to measure your body."
}
}
}LiDAR not available:
- The feature is automatically hidden on non-LiDAR devices
- Test only on physical devices with LiDAR support
License
MIT
Contributing
Contributions are welcome! Please open an issue or PR.
