DepthFrameData
ClassThe depth frame data as provided by the DepthFrameSession.onNewFrame.
- Available on all platforms
- SnapchatFully supported
- SPECSFully supported
- Camera Kit WebFully supported
- Camera Kit MobileFully supported
Applies to all platforms
- Restricted when the Lens uses internet-connected APIs (see Privacy Restrictions).
Exposes user data
The depth frame data as provided by the DepthFrameSession.onNewFrame.
Index
Properties
Methods
Example
const depthModule = require("LensStudio:DepthModule");
const session = depthModule.createDepthFrameSession();
session.onNewFrame.add((depthFrameData) => {
const depthDeviceCamera = depthFrameData.deviceCamera;
// Sample depth for specific pixel
const pixelCoordX = 112;
const pixelCoordY = 80;
const depthFrameArrayIdx = Math.floor(pixelCoordX + pixelCoordY * depthDeviceCamera.resolution.x);
const depthValue = depthFrameData.depthFrame[depthFrameArrayIdx];
// Back-project depth pixel to device reference space
const normalizedCoord = new vec2(pixelCoordX / depthDeviceCamera.resolution.x, pixelCoordY / depthDeviceCamera.resolution.y);
const pointInDeviceRef = depthDeviceCamera.unproject(
normalizedCoord,
depthValue
);
// Transform point in device reference space to world tracking origin space
const worldFromDeviceRef =
depthFrameData.toWorldTrackingOriginFromDeviceRef;
const pointInWorld = worldFromDeviceRef.multiplyPoint(pointInDeviceRef);
});
session.start();
session.stop();
Extends
Properties
depthFrame
readonlydepthFrame:Float32Array
Exposes user data
The depth frame as a linear Float32Array in centimeters.
deviceCamera
readonlydeviceCamera:DeviceCamera
Exposes user data
Provides information about the depth device camera.
timestampSeconds
readonlytimestampSeconds:number
Exposes user data
The timestamp of the start of exposure of the frame in seconds.
toWorldTrackingOriginFromDeviceRef
readonlytoWorldTrackingOriginFromDeviceRef:mat4
Exposes user dataSPECS only
The pose of the device reference relative to the frame of reference of the tracked device position.
Methods
getTypeName()
staticgetTypeName():TypeName<DepthFrameData>
Exposes user data
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<DepthFrameData>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean