CameraModule.StreamConfig
ClassStream configuration for creating a camera session.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- 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
Since Lens Scripting v368Exposes user data
Stream configuration for creating a camera session.
Index
Remarks
The stream capability (from CameraModule.CameraInfo#getStreams) defines the camera, resolution, image format and quality; CameraModule.StreamConfig#minFrameRate sets the minimum frame rate you need. Tuning parameters (auto-exposure region, MFNR) are set via CameraModule.StreamConfig#setConfig; a snapshot crop region via CameraModule.StreamConfig#crop.
Example
let cameraModule = require('LensStudio:CameraModule');
let rgb = cameraModule.getCameras().find(function (c) { return c.type == CameraModule.CameraType.Rgb; });
// The largest JPEG snapshot capability of the RGB camera.
let config = new CameraModule.StreamConfig();
config.stream = rgb ? (rgb.getStreams().find(function (s) {
return s.operation == CameraModule.Operation.Capture && s.imageFormat == CameraModule.ImageFormat.Jpeg;
}) || null) : null;
config.setConfig(CameraModule.ConfigKey.SnapshotMfnrEnable, [1]); // multi-frame noise reduction
// Centered 50% crop in [-1, 1] normalized image space (full image = -1..1 on each axis).
config.crop = Rect.create(-0.5, 0.5, -0.5, 0.5);
Extends
Constructors
Constructor
new StreamConfig():
StreamConfig
Returns
StreamConfig
Overrides
ScriptObject.constructor
Properties
crop
crop:
Rect
Exposes user dataSPECS
Snapshot crop region in [-1, 1] normalized image space, y up: the full
image spans [-1, 1] on each axis, with top = 1 at the top edge and
right = 1 at the right edge. A centered 50% crop is
Rect.create(-0.5, 0.5, -0.5, 0.5); the top-left quadrant is
Rect.create(-1, 0, 0, 1). Null means "no crop / full image".
Remarks
Coordinates must be finite. Bounds are clamped to [-1, 1], and each pair of edges is ordered before conversion to output pixels. The cropped region is scaled to the still's size: outputWidth x outputHeight, or the capability's size. Give the crop the same aspect ratio as that size.
Applies to capture sessions (and per-shot overrides) only — ignored on streaming sessions.
Since
Lens Scripting Version 368
Default Value
null
@exposesUserData
@snapOS
minFrameRate
minFrameRate:
number
Exposes user dataSPECS
Minimum frame rate you need, in Hz. 0 (the default) requests the capability's advertised rate.
Remarks
Requests are rounded up to a whole Hz. Assigning a negative value throws, and start() throws when the rounded request exceeds CameraModule.StreamInfo#maxFrameRate.
The camera may run faster when another client requests a higher rate. This requests a camera rate; it does not guarantee the frequency of onNewFrame callbacks or still captures. Frames can be dropped when the lens cannot keep up. CameraModule.MetadataKey FrameRate reports the camera service's rate when available.
Since
Lens Scripting Version 387
Default Value
0
@exposesUserData
@snapOS
outputHeight
outputHeight:
number
Exposes user dataSPECS
Height in pixels of the stills a CameraModule.CaptureSession returns. Null (the default) uses the capability's height. See CameraModule.StreamConfig#outputWidth.
Since
Lens Scripting Version 387
Default Value
null
@exposesUserData
@snapOS
outputWidth
outputWidth:
number
Exposes user dataSPECS
Width in pixels of the stills a CameraModule.CaptureSession returns. Null (the default) uses the capability's width. Set it together with CameraModule.StreamConfig#outputHeight.
Remarks
Any positive, even size up to the capability's width and height works, for example 756x1008 from a 4032x3024 capability. A size with another aspect ratio than the capability is a centered crop of its view, so the image is never stretched. Assigning zero, a negative or an odd value throws. start() throws when only one of the two is set, when the size is larger than the capability, or when either is set on a CameraModule.StreamingSession: streams have the capability's fixed size.
Since
Lens Scripting Version 387
Default Value
null
@exposesUserData
@snapOS
stream
stream:
StreamInfo
Exposes user dataSPECS
Stream capability from CameraModule.CameraInfo#getStreams. Defines the camera, resolution, image format and quality. Its CameraModule.StreamInfo#operation must match the session.
Since
Lens Scripting Version 368
Default Value
null
@exposesUserData
@snapOS
Methods
getTypeName()
staticgetTypeName():TypeName<StreamConfig>
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<StreamConfig>
Since
Lens Scripting Version 368
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
setConfig()
setConfig(
key,values):void
Exposes user dataSPECS
Set a tuning parameter.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | ConfigKey | Config key (e.g. CameraModule.ConfigKey.AutoExposureRegion). |
values | number[] | Values array (e.g. [0.25, 0.75, 0.25, 0.75] for AutoExposureRegion). |
Returns
void
Since
Lens Scripting Version 368