Preparing search index...

    Class CaptureSessionExposes User Data

    Still-capture camera session for Spectacles. Created via CameraModule#createCaptureSession. After CameraModule.CaptureSession#start pre-warms the pipeline, individual snapshots are triggered with CameraModule.CaptureSession#capture, which returns a Promise that resolves with the captured Frame.

    Pre-warming has meaningful latency (~1-2s for ISP init) — start the capture session early (e.g. on Lens load) for low shutter latency.

    Sessions are restartable: stop() releases the camera, start() can be called again with a new (or the same) StreamConfig.

    let cameraModule = require('LensStudio:CameraModule');
    let streams = cameraModule.getSupportedStreams();

    let session = cameraModule.createCaptureSession();
    let config = new CameraModule.StreamConfig();
    config.stream = streams[0];
    session.start(config); // pre-warm

    // Capture a single frame, optionally with a per-shot crop override.
    let overrides = new CameraModule.StreamConfigOverrides();
    overrides.crop = Rect.create(-0.5, 0.5, -0.5, 0.5);
    let frame = await session.capture(overrides);
    mesh.mainPass.baseTex = frame.texture;

    session.onStatusChanged.add((status) => {
    if (status == CameraModule.StreamStatus.Disconnected) print("Camera disconnected");
    });

    Hierarchy (View Summary)

    Index

    Properties

    onStatusChanged: event1<StreamStatus, void>

    Event triggered when session status changes (interruption, disconnection).

    Methods

    • Exposes User Data

      Trigger a single still capture. Returns a Promise that resolves with the captured CameraModule.Frame once the frame is delivered (typically within a few hundred ms on a pre-warmed session).

      Only one capture may be in flight per session: await the returned Promise before calling capture() again.

      The Promise rejects when:

      • the session is not started or was stopped/disconnected,
      • another capture is already in flight,
      • stop() is called before the frame lands,
      • no frame is delivered within 30 seconds (pipeline stall backstop).

      If the camera service delivers a frame whose image data cannot be read, the Promise still resolves, with a Frame whose CameraModule.Frame#texture is null and CameraModule.Frame#imageData is empty — check for a null texture before using the result.

      Parameters

      • Optionaloverrides: StreamConfigOverrides

        Optional per-shot overrides (e.g. crop region). Pass null or omit to use the session's defaults; an empty overrides object does not clear the session's crop.

      Returns Promise<CameraModule.Frame>

      Promise resolving with the captured Frame.

    • 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 string

    • 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

    • Exposes User Data

      Pre-warm the capture pipeline. Call early (e.g. on Lens load) for low shutter latency. No frames are delivered until CameraModule.CaptureSession#capture is invoked.

      Parameters

      • config: StreamConfig

        Stream configuration. The .crop field on config is used as the default crop for subsequent captures unless overridden.

      Returns Result

      Result code.