Skip to main content

CameraModule.StreamConfigOverrides

Class

Per-shot overrides for CameraModule.CaptureSession#capture.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
1 platform note
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
    • Restricted when the Lens uses internet-connected APIs (see Privacy Restrictions).
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported. Restricted when the Lens uses internet-connected APIs (see Privacy Restrictions)

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v368Exposes user data

Per-shot overrides for CameraModule.CaptureSession#capture.

Index

Remarks

Only the properties listed here are overridable on a per-capture basis. Other StreamConfig fields (stream, tuning parameters) are fixed at session start and cannot be changed per-shot.

Example

let cameraModule = require('LensStudio:CameraModule');
let captureSession = cameraModule.createCaptureSession();

// Select the largest JPEG snapshot capability on the RGB camera.
let rgb = cameraModule.getCameras().find(function (c) { return c.type == CameraModule.CameraType.Rgb; });
let stream = rgb && rgb.getStreams().find(function (s) {
return s.operation == CameraModule.Operation.Capture && s.imageFormat == CameraModule.ImageFormat.Jpeg;
});
let ready = false;
if (stream) {
let config = new CameraModule.StreamConfig();
config.stream = stream;
ready = captureSession.start(config) == CameraModule.Result.Success; // pre-warm
}

async function takePhoto() {
if (!ready) return;
let overrides = new CameraModule.StreamConfigOverrides();
overrides.crop = Rect.create(-0.5, 0.5, -0.5, 0.5); // centered 50% crop for this shot only
try {
let frame = await captureSession.capture(overrides);
print('Captured ' + frame.width + 'x' + frame.height);
} catch (e) {
print('Capture failed: ' + e);
}
}

// Capture two seconds after start; call takePhoto() from your own trigger instead.
let delay = script.createEvent('DelayedCallbackEvent');
delay.bind(takePhoto);
delay.reset(2);

Extends

Constructors

Constructor

new StreamConfigOverrides(): StreamConfigOverrides

Returns

StreamConfigOverrides

Overrides

ScriptObject.constructor

Properties

crop

crop: Rect

Exposes user dataSPECS

Per-shot snapshot crop region, in the same space as CameraModule.StreamConfig#crop: [-1, 1] on each axis, y up (a centered 50% crop is Rect.create(-0.5, 0.5, -0.5, 0.5)). Null means "use the session's default crop (or no crop)".

Since

Lens Scripting Version 368

Default Value

null
@exposesUserData
@snapOS

Methods

getTypeName()

static getTypeName(): TypeName<StreamConfigOverrides>

Exposes user dataSPECS

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<StreamConfigOverrides>

Since

Lens Scripting Version 368

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