react-native-depth-health
v0.3.1
Published
react-native-depth-health
Downloads
195
Readme
react-native-depth-health
Detect available iOS depth sensors and check whether their synchronized depth stream is healthy.
iOS only: the native implementation currently targets TrueDepth and LiDAR cameras through AVFoundation.
Installation
npm install react-native-depth-healthFor iOS, install pods after adding the package:
cd ios && pod installAPI
getSensors()
Returns the available iOS depth sensors synchronously.
type DepthSensor = {
type: 'structured-light' | 'time-of-flight';
position: 'front' | 'back';
};
function getSensors(): DepthSensor[];The iOS implementation maps:
- front
AVCaptureDevice.DeviceType.builtInTrueDepthCamerato{ type: 'structured-light', position: 'front' } - back
AVCaptureDevice.DeviceType.builtInLiDARDepthCamerato{ type: 'time-of-flight', position: 'back' }
checkSensors()
Checks each available iOS depth sensor and resolves with a health result.
type DepthSensorFilter = {
type?: 'structured-light' | 'time-of-flight';
position?: 'front' | 'back';
};
type DepthSensorHealth = {
type: 'structured-light' | 'time-of-flight';
position: 'front' | 'back';
healthy: boolean;
};
function checkSensors(filter?: DepthSensorFilter): Promise<DepthSensorHealth[]>;healthy is true only when the native check receives depth data and finds at
least one finite positive value while scanning the full depth map.
Usage
import { checkSensors, getSensors } from 'react-native-depth-health';
const sensors = getSensors();
// [{ type: 'structured-light', position: 'front' }, ...]
const health = await checkSensors();
// [{ type: 'structured-light', position: 'front', healthy: true }, ...]
const frontHealth = await checkSensors({ position: 'front' });
const lidarHealth = await checkSensors({ type: 'time-of-flight' });iOS permissions
Because checkSensors() opens camera capture devices, your app should include an
NSCameraUsageDescription entry in its iOS Info.plist.
Contributing
License
MIT
Made with create-react-native-library
