@snap/camera-kit
Version:
Camera Kit Web
42 lines • 1.67 kB
TypeScript
import { CameraKitSource } from "./CameraKitSource";
/** @internal */
export type FrameFormat = "rgb" | "yuv" | "nv12";
/** @internal */
export interface FrameInput {
format?: FrameFormat;
imageData: ImageData;
timestampMillis: number;
}
/** @internal */
export interface FrameOutput {
live: ImageData;
capture: ImageData;
}
/** @internal */
export interface MediaSourceFunction {
(render: (frame: FrameInput) => Promise<FrameOutput>): Promise<void>;
}
/**
* Function source options.
*/
export interface FunctionSourceOptions {
/**
* Specifies the camera type for which certain features are enabled or disabled.
* For example, surface tracking features are only active when the camera is set to "environment" mode.
* The default value is "user", which accommodates the majority of Lenses.
* "user" refers to the front-facing camera, while "environment" refers to the rear-facing camera.
*/
cameraType: "user" | "environment";
}
/**
* Creates a {@link CameraKitSource} from a function which provides per-frame pixel data to CameraKit.
*
* @param sourceFunction This function will be called in a requestAnimationFrame loop. Each time it is called, it is
* passed a `render` function. It may call `render` and CameraKit will process the pixel data passed to `render` and
* return a Promise of the processed pixels (along with rendering them to the normal output canvases).
* @param options Options.
*
* @internal
*/
export declare const createFunctionSource: (sourceFunction: MediaSourceFunction, options?: Partial<FunctionSourceOptions>) => CameraKitSource;
//# sourceMappingURL=FunctionSource.d.ts.map