Class CameraModuleExperimental Exposes User Data Wearable Only

Provides access to a specific camera on Spectacles device.

Useful for requesting a specific camera on Spectacles or requesting images from both cameras simultaneously.

Camera Module guide.

let cameraModule = require('LensStudio:CameraModule');

let cameraRequest = CameraModule.createCameraRequest();
cameraRequest.id = CameraModule.CameraId.Left_Color;

let cameraTexture = cameraModule.requestCamera(cameraRequest);
// @input Asset.Image displayImage

let cameraModule = require('LensStudio:CameraModule');

script.createEvent('OnStartEvent').bind(function() {
let cameraRequest = CameraModule.createCameraRequest();
cameraRequest.id = CameraModule.CameraId.Left_Color;

let cameraTexture = cameraModule.requestCamera(cameraRequest);
script.displayImage.mainPass.baseTex = cameraTexture
})
// @input Component.MLComponent mlComponent
// @input SceneObject image

let cameraModule = require('LensStudio:CameraModule');
let createCameraTexture = () => {
let request = CameraModule.createCameraRequest();
request.cameraId = CameraModule.CameraId.Left_Color;
return cameraModule.requestCamera(request);
}

let cameraTexControl;
let runInference = (frame) => {
script.mlComponent.runImmediate(true);
// Use frame.timestampMillis if you need to use timestamps
script.image.enabled = true;
}

script.mlComponent.onLoadingFinished = () => {
let cameraTex = createCameraTexture();
cameraTexControl = cameraTex.control;
script.mlComponent.getInput('input').texture = cameraTex;
cameraTexControl.onNewFrame.add(runInference)

// For obtaining camera intrinsics / extrinsics
let cameraInfo =
global.deviceInfoSystem.getTrackingCameraForId(CameraModule.CameraId.Left_Color);
print(cameraInfo);
}
let cameraModule = require('LensStudio:CameraModule');
let remoteMediaModule = require('LensStudio:RemoteMediaModule');
script.createEvent('TurnOnEvent').bind(function() {
let cameraRequest = CameraModule.createCameraRequest();
let cameraTex = cameraModule.requestCamera(cameraRequest);
// Wait for image to be available before trying to use it
let registration = cameraTex.control.onNewFrame.add(async function() {
// Only need 1 frame, remove registration to stop receiving more frames
cameraTex.control.onNewFrame.remove(registration);

let imageResource = await remoteMediaModule.createImageResourceForTexture(cameraTex, ImageUploadOptions.create());
// Use imageResource, like uploading to backend for further processing
})
});

Hierarchy (View Summary, Expand)

Constructors

Properties

name: string

The name of the Asset in Lens Studio.

uniqueIdentifier: string

Methods

  • Experimental Exposes User Data Wearable Only

    Creates a camera request object.

    Returns CameraRequest

  • Experimental Exposes User Data Wearable Only

    Spectacles: create a CameraImage.ImageRequest. This object can be used to configure a request for a high resolution image of the user's camera stream. The resolution of this image will be fixed to 3200x2400.

    Returns CameraModule.ImageRequest

  • Experimental

    Returns the name of this object's type.

    Returns string

  • Experimental

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

    Parameters

    • type: string

    Returns boolean

  • Experimental

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

    Parameters

    Returns boolean

  • Experimental

    Spectacles: Request a still image of the user's camera stream. Unlike {@CameraModule.requestCamera}, this method takes more time but yields a higher resolution image (3200x2400) suitable for tasks like OCR. This method is asynchronous and when complete will return an ImageFrame that contains a {@Texture } that can be attached to a visual.

    let cameraModule = require("LensStudio:CameraModule");
    let imageRequest = CameraModule.createImageRequest();

    try {
    let imageFrame = await cameraModule.requestImage(imageRequest);

    // Use the texture in some visual
    script.image.mainPass.baseTex = imageFrame.texture;
    let timestamp = imageFrame.timestampMillis; // scene-relative time
    } catch (error) {
    print(`Still image request failed: ${error}`);
    }

    Parameters

    Returns Promise<ImageFrame>

MMNEPVFCICPMFPCPTTAAATR