Skip to main content

DepthFrameData

Class

The depth frame data as provided by the DepthFrameSession.onNewFrame.

  • Available on all platforms
1 platform note
  • 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).

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

  • 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

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

readonly depthFrame: Float32Array

Exposes user data

The depth frame as a linear Float32Array in centimeters.


deviceCamera

readonly deviceCamera: DeviceCamera

Exposes user data

Provides information about the depth device camera.


timestampSeconds

readonly timestampSeconds: number

Exposes user data

The timestamp of the start of exposure of the frame in seconds.


toWorldTrackingOriginFromDeviceRef

readonly toWorldTrackingOriginFromDeviceRef: mat4

Exposes user dataSPECS only

The pose of the device reference relative to the frame of reference of the tracked device position.

Methods

getTypeName()

static getTypeName(): 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

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame