Lens Scripting API
    Preparing search index...

    Class DepthFrameDataExposes User Data

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

    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();

    Hierarchy (View Summary)

    Index

    Properties

    depthFrame: Float32Array

    The depth frame as a linear Float32Array in centimeters.

    deviceCamera: DeviceCamera

    Provides information about the depth device camera.

    timestampSeconds: number

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

    toWorldTrackingOriginFromDeviceRef: mat4

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

    Methods

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

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean