Skip to main content

LensStudio:Preview.Config

Class

Preview input configuration: input source, camera view, simulated device, and input upscale.

Preview input configuration: input source, camera view, simulated device, and input upscale. Read it from a preview's config property, modify it, and assign it back.

Index

Example

Show the Lens on a bundled sample image through the back camera, with smaller input frames. config returns a copy, so the changes apply only when it is assigned back.

import { LensPreview } from 'LensStudio:LensPreview';
import { allImages, CameraView, Config } from 'LensStudio:Preview';

export async function useBackCameraSample(preview: LensPreview, upscale = 720): Promise<Config> {
const [sample] = await allImages();
if (!sample) throw new Error('No bundled sample images are available');

const config = preview.config;
config.input = sample;
config.cameraView = CameraView.Back;
config.upscale = upscale; // longer side of each input frame, in pixels
preview.config = config;
return preview.config;
}

Constructors

Constructor

new Config(): Config

Constructs a Config with default values: no device, the front camera view, and an upscale of 1280.

Returns

Config

Properties

cameraView

cameraView: CameraView

Camera the preview simulates, front or back.


device

device: any

Device descriptor to simulate. When unset, applying the Config keeps the preview's current device.


input

input: Input

Input source that feeds the preview.


upscale

upscale: number

Target size, in pixels, of the longest side of the input frame. Image and video input is resized to this size before it reaches the Lens, keeping its aspect ratio: larger sources are scaled down and smaller ones are scaled up. Set to 0 to use the source's own resolution. Defaults to 1280. This is not a scale factor; a small value such as 2 produces a 2-pixel-wide input.