This general-purpose class represents a source of media for a CameraKitSession.

When an instance is passed to CameraKitSession.setSource, it will be "attached" to the session. Later it may be "detached" from the session.

Passing a CameraKitSourceSubscriber to the constructor allows callers to specify behavior that will occur when the source is attached and detached. This can be used to e.g. update the render size.

Important: Once a source has been attached to a CameraKitSession, it cannot be reattached, even if it has been detached. You must supply a new instance of CameraKitSource to CameraKitSession.setSource. If you want to reuse the existing source, you can use its CameraKitSource.copy method to create a new instance.

Constructors

Methods

  • Set the resolution used to render this source.

    If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).

    By default (i.e. if this method is never called), then the render size will match the size of the input media. Best performance can be achieved by varying the size of the input media and allowing CameraKit to render at a resolution that matches the input media -- this method should only be used if the input media resolution cannot be changed to the desired size.

    It’s important to distinguish render size from display size. The size at which the output canvases are displayed on a web page is determined by the CSS of the page. It is distinct from the size at which CameraKit renders Lenses. Performance is dominated by render size, while any display scaling (using CSS) can most often be thought of as free.

    The size of the Live and Capture RenderTarget is always the same.

    Parameters

    • width: number

      pixels

    • height: number

      pixels

    Returns Promise<void>

    Promise resolves when the render size has been successfully updated.

    Currently it's only valid to call setRenderSize after CameraKitSession.play has been called. This constraint should be removed, so callers don't have to understand the underlying LensCore state machine.

  • Apply a 2D transformation to the source (e.g. translation, rotation, scale).

    Parameters

    • transform: Transform2D

      Specifies the 3x3 matrix describing the transformation.

    Returns Promise<void>

MMNEPVFCICPMFPCPTTAAATR