InterfaceCameraModuleExperimental Exposes User Data Wearable Only

Provides access to the requested camera. Useful for requesting a specific camera on spectacles or requesting images from both cameras simultaneously.

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
})
});
interface CameraModule {
    name: string;
    uniqueIdentifier: string;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    requestCamera(request: CameraRequest): Texture;
}

Hierarchy (view full)

Properties

name: string

The name of the Asset in Lens Studio.

uniqueIdentifier: string

Methods

  • 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

    Returns a Texture whose provider is CameraTextureProvider which provides images from the requested camera ID.

    Parameters

    Returns Texture