@snap/camera-kit
Version:
Camera Kit Web
139 lines • 67.1 kB
HTML
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CameraKit Web SDK - v0.22.0</title><meta name="description" content="Documentation for CameraKit Web SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">CameraKit Web SDK - v0.22.0</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h2>CameraKit Web SDK - v0.22.0</h2></div><div class="tsd-panel tsd-typography"><a id="md:snap-camera-kit-web-sdk" class="tsd-anchor"></a><h1><a href="#md:snap-camera-kit-web-sdk">Snap Camera Kit Web SDK</a></h1><p>The Camera Kit Web SDK allows web developers to build Snap's core AR Lens technology into their applications.</p>
<a id="md:minimum-browser-requirements" class="tsd-anchor"></a><h2><a href="#md:minimum-browser-requirements">Minimum browser requirements</a></h2><ul>
<li><strong>Chrome 73+</strong></li>
<li><strong>Safari 15+</strong><ul>
<li>MacOS 12+, iOS 15+, iPadOS 15+</li>
<li>SIMD: Unsupported</li>
<li>Web Worker Mode*: Unsupported</li>
</ul>
</li>
<li><strong>Edge 79+</strong><ul>
<li>Edge is still currently under evaluation. However, since New Edge is Chromium based, the expectations are similar to that of Chrome.</li>
</ul>
</li>
<li><strong>Firefox</strong> - Under Evaluation<ul>
<li>Web Worker Mode*: Firefox 105+</li>
</ul>
</li>
</ul>
<p>*Web Worker Mode requires <code>OffscreenCanvas</code> support.</p>
<a id="md:prerequisites" class="tsd-anchor"></a><h2><a href="#md:prerequisites">Prerequisites</a></h2><a id="md:snap-developer-set-up" class="tsd-anchor"></a><h3><a href="#md:snap-developer-set-up">Snap Developer set up</a></h3><p>You'll need a Snap Developer account, and you'll need to apply for access to Camera Kit Web SDK. You can find more info on that <a href="https://docs.snap.com/camera-kit/getting-started/setting-up-accounts">here</a>.</p>
<p>You may also want to familiarize yourself with how to access and manage AR content (i.e. Lenses). You read about that <a href="https://docs.snap.com/camera-kit/ar-content/camera-kit-portal">here</a>.</p>
<a id="md:development-environment" class="tsd-anchor"></a><h3><a href="#md:development-environment">Development environment</a></h3><p>This guide assumes you've already set up an <a href="https://www.npmjs.com/">NPM</a> package, you're using <a href="https://www.typescriptlang.org/">TypeScript</a>, and have some way to build and host your project during development (e.g. using <a href="https://webpack.js.org/">Webpack</a>).</p>
<a id="md:using-the-sdk-in-a-javascript-project" class="tsd-anchor"></a><h4><a href="#md:using-the-sdk-in-a-javascript-project">Using the SDK in a JavaScript project</a></h4><p>The SDK is authored in TypeScript, and distributes type definitions. All the examples here are presented in TypeScript. We encourage the use of TypeScript in projects that consume the SDK – but it's also fully compatible with JavaScript projects as well.</p>
<a id="md:content-security-policy" class="tsd-anchor"></a><h3><a href="#md:content-security-policy">Content Security Policy</a></h3><p>If your project already has a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy">Content Security Policy</a> in place, you'll likely need to make some changes in order for Camera Kit Web SDK to work.</p>
<p>When it bootstraps, Camera Kit Web SDK downloads an executable WebAssembly file containing the Lens rendering engine. This file is served from an optimized CDN managed by Snap. You'll need to make sure your Content Security Policy allows this file to be executed.</p>
<ul>
<li><code>connect-src</code> must include <code>https://*.snapar.com</code>, otherwise Camera Kit Web will fail to initialize.</li>
<li><code>script-src</code> must include <code>https://cf-st.sc-cdn.net/ blob: 'wasm-unsafe-eval'</code>.</li>
</ul>
<p><em>Note: Some older browser versions may not support the <code>'wasm-unsafe-eval'</code> source value, and it may be necessary to use <code>'unsafe-eval'</code> to allow Camera Kit's downloaded WebAssembly to run.</em></p>
<a id="md:installing-the-sdk" class="tsd-anchor"></a><h2><a href="#md:installing-the-sdk">Installing the SDK</a></h2><pre><code><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-0">install</span><span class="hl-1"> @</span><span class="hl-0">snap</span><span class="hl-1">/</span><span class="hl-0">camera</span><span class="hl-1">-</span><span class="hl-0">kit</span>
</code><button>Copy</button></pre>
<p>You can find the Camera Kit Web SDK package on npmjs.com <a href="https://www.npmjs.com/package/@snap/camera-kit">here</a>.</p>
<a id="md:importing-camera-kit" class="tsd-anchor"></a><h3><a href="#md:importing-camera-kit">Importing Camera Kit</a></h3><p>Currently, the SDK distributes <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">JavaScript modules</a>. We may support other module formats in the future (e.g. CommonJS), but for now you'll need to use <code>import</code> syntax to use the Camera Kit Web SDK.</p>
<a id="md:bootstrapping-the-sdk" class="tsd-anchor"></a><h2><a href="#md:bootstrapping-the-sdk">Bootstrapping the SDK</a></h2><p>With the SDK installed and imported, the first thing to do is bootstrap the SDK. When bootstrapping, the SDK will download the WebAssembly runtime which is used to render Lenses. This is also where you'll configure the SDK according to your needs.</p>
<p>To call <a href="functions/bootstrapCameraKit.html" class="tsd-kind-function">bootstrapCameraKit</a>, you'll need to provide a <code>apiToken</code>. Once you've completed the <a href="https://docs.snap.com/camera-kit/guides/quick-start/integrate-sdk/setting-up-accounts">Getting set up in our portals</a> section of the Getting Started guide, you'll be able to find this in the <a href="https://devportal.snap.com/manage">Snap Kit Portal</a>.</p>
<pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">"@snap/camera-kit"</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">"Your API Token value copied from the Camera Kit Portal"</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><span class="hl-1">})();</span>
</code><button>Copy</button></pre>
<a id="md:creating-a-camerakitsession" class="tsd-anchor"></a><h2><a href="#md:creating-a-camerakitsession">Creating a <code>CameraKitSession</code></a></h2><p>In order to render Lenses, you must first create a <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a>. Each session represents a rendering pipeline - it connects an input media source (e.g. a webcam) to Camera Kit's AR engine, applies a Lens, and renders the output to a <code><canvas></code> element.</p>
<p>There are two ways to create a session. If you already have a <code><canvas></code> element on your page that you'd like for the <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a> to render into, you can pass it to Camera Kit when creating the session. Otherwise, the session will create a new <code><canvas></code> element which you can add to the DOM.</p>
<pre><code class="language-ts"><span class="hl-7">// Using an existing canvas</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvas</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">"my-canvas"</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">(</span><span class="hl-0">canvas</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Let Camera Kit create a new canvas, then append it to the DOM</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvasContainer</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">"canvas-container"</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">();</span><br/><span class="hl-0">canvasContainer</span><span class="hl-1">.</span><span class="hl-5">appendChild</span><span class="hl-1">(</span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">output</span><span class="hl-1">.</span><span class="hl-0">live</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<p>There are actually two different output canvases:</p>
<ul>
<li><code>live</code>: This canvas renders content intended for the Lens user. Depending on the Lens being used, this canvas may include UI elements, prompts, or other content that is only meant to be seen by the user of the Lens.</li>
<li><code>capture</code>: This canvas renders content intended for presenting to other users.</li>
</ul>
<p>These two output canvases correspond to the two different <a href="https://docs.snap.com/lens-studio/references/guides/lens-features/scene-set-up/camera#render-target">RenderTargets</a> a Lens may use to render its content. Not all Lenses will render different content to <code>live</code> vs. <code>capture</code>, so it's important to understand how the Lenses you'll be using use these two different outputs.</p>
<blockquote>
<p>No rendering will happen yet, and the output canvas associated with this new <code>CameraKitSession</code> will be blank. Frames are not processed until you start <a href="#md:playback">playback</a> by calling the <code>CameraKitSession</code>'s <code>play()</code> method. This will be discussed below.</p>
</blockquote>
<a id="md:creating-a-camerakitsource" class="tsd-anchor"></a><h2><a href="#md:creating-a-camerakitsource">Creating a <code>CameraKitSource</code></a></h2><p>In order for Camera Kit Web SDK to render anything, it must have a source of imagery to be processed by the AR engine. The Lens content will be rendered on top of this source media.</p>
<p>The most common source of input media is the user's webcam. Camera Kit Web SDK provides a helper method to create a <code>CameraKitSource</code> object from a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream"><code>MediaStream</code></a>. You can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a> to obtain a <code>MediaStream</code> with video from the user's webcam.</p>
<blockquote>
<p>Note that calling <code>getUserMedia</code> will prompt the user to grant the webpage access to their camera.</p>
</blockquote>
<p>Once we have a <code>CameraKitSource</code>, we can tell the <code>CameraKitSession</code> to use this source for rendering.</p>
<pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1">, </span><span class="hl-0">Transform2D</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">"@snap/camera-kit"</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">, </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">'user'</span><span class="hl-1"> });</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<p>In this example, we also mirror the source stream (which feels more natural in most cases), and we indicate this source comes from a front-facing camera. To read more about these options, see <a href="#md:customizing-camerakitsource">below</a>.</p>
<p>Camera Kit Web SDK has helper methods to create a <code>CameraKitSource</code> from:</p>
<ul>
<li>A <code>MediaStream</code> object, which could come from the user's camera, a WebRTC connection, a <code><canvas></code> via the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream"><code>captureStream()</code> method</a>, or elsewhere.</li>
<li>A <code><video></code> element (i.e. <code>HTMLVideoElement</code>)</li>
<li>An <code><img></code>element (i.e. <code>HTMLImageElement</code>)</li>
</ul>
<a id="md:loading-applying-and-removing-lenses" class="tsd-anchor"></a><h2><a href="#md:loading-applying-and-removing-lenses">Loading, applying, and removing Lenses</a></h2><p>In Camera Kit Web SDK -- just like in the Snapchat app itself -- each individual AR experience is called a Lens. Lenses are created using <a href="https://ar.snap.com/en-US/lens-studio">Lens Studio</a>. You can find more information about acquiring Lenses <a href="https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/ar-overview">here</a>.</p>
<p>You can find Lens and Lens Groups in the <a href="https://camera-kit.snapchat.com/">Camera Kit Portal</a>. This is where you can manage your Lenses and Lens Groups and where you can find Lens IDs and Lens Group IDs. You can read more about managing Lenses in the Camera Kit Portal <a href="https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/camera-kit-portal">here</a>.</p>
<p>Before applying a Lens to our session, we have to load metadata about that Lens. Lenses can be loaded either one at a time, or entire Lens Groups can be loaded at once. You'll need a Lens ID and its Lens Group ID to complete this step.</p>
<pre><code class="language-ts"><span class="hl-7">// Loading a single lens</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">"<Lens ID>"</span><span class="hl-1">, </span><span class="hl-3">"<Lens Group ID>"</span><span class="hl-1">);</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Loading one or more Lens Groups – Lenses from all groups are returned as a single array of lenses.</span><br/><span class="hl-4">const</span><span class="hl-1"> { </span><span class="hl-6">lenses</span><span class="hl-1"> } = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLensGroups</span><span class="hl-1">([</span><br/><span class="hl-1"> </span><span class="hl-3">"<Lens Group ID 1>"</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">"<Lens Group ID 2>"</span><span class="hl-1">,</span><br/><span class="hl-1">]);</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lenses</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">]);</span>
</code><button>Copy</button></pre>
<a id="md:removing-the-lens" class="tsd-anchor"></a><h3><a href="#md:removing-the-lens">Removing the Lens</a></h3><p>You can also remove the currently-applied Lens:</p>
<pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">removeLens</span><span class="hl-1">();</span>
</code><button>Copy</button></pre>
<p>After removing the Lens, when the session renders it will simply render the input media directly to the output canvas.</p>
<a id="md:playback" class="tsd-anchor"></a><h2><a href="#md:playback">Playback</a></h2><p>The <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a> will only process input video frames and render them to the output when you tell it to do so – this way, you can control when Camera Kit is using a client's resources (e.g. CPU and GPU compute cycles). You can tell the session to <code>play</code> or <code>pause</code>.</p>
<pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">();</span><br/><br/><span class="hl-7">// ...sometime later</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">();</span>
</code><button>Copy</button></pre>
<a id="md:playing-and-pausing-the-different-rendertargets" class="tsd-anchor"></a><h3><a href="#md:playing-and-pausing-the-different-rendertargets">Playing and pausing the different RenderTargets</a></h3><p>By default, <code>play()</code> will only begin rendering the <code>live</code> output canvas. You can specify which canvas to render by passing an argument:</p>
<pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">(</span><span class="hl-3">'live'</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">(</span><span class="hl-3">'capture'</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<p>Calling <code>pause()</code> with no arguments will pause both outputs. But just like with <code>play()</code>, you can pass an argument to select which canvas to pause.</p>
<pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">(</span><span class="hl-3">'live'</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">(</span><span class="hl-3">'capture'</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<blockquote>
<ul>
<li><em><code>live</code>: This canvas renders content intended for the Lens user. Depending on the Lens being used, this canvas may include UI elements, prompts, or other content that is only meant to be seen by the user of the Lens.</em></li>
<li><em><code>capture</code>: This canvas renders content intended for presenting to other users.</em></li>
</ul>
</blockquote>
<a id="md:error-handling" class="tsd-anchor"></a><h2><a href="#md:error-handling">Error Handling</a></h2><p>Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the <a href="https://kit.snapchat.com/reference/CameraKit/web/0.22.0/index.html">API docs</a>. It is good practice to handle such cases, to provide a good experience to your users.</p>
<p>Errors may also occur during Lens rendering. For example, Lenses contain their own scripting, which could throw an error. A rendering error could also occur if a Lens attempts to use a feature that is not supported by Camera Kit Web SDK.</p>
<p>When a <code>LensExecutionError</code> such as these occurs, the Lens is <strong>automatically removed</strong> from the <code>CameraKitSession</code>. An error event is emitted so that your application can respond appropriately. You can listen to these error events like so:</p>
<pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">events</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">'error'</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">error</span><span class="hl-1">(</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">if</span><span class="hl-1"> (</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">.</span><span class="hl-0">name</span><span class="hl-1"> === </span><span class="hl-3">'LensExecutionError'</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-7">// The currently-applied Lens encountered a problem that is most likely unrecoverable and the Lens has been removed.</span><br/><span class="hl-1"> </span><span class="hl-7">// Your application may want to prevent this Lens from being applied again.</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span>
</code><button>Copy</button></pre>
<a id="md:putting-it-all-together" class="tsd-anchor"></a><h2><a href="#md:putting-it-all-together">Putting it all together</a></h2><p>Using the examples above, here's a complete example of the minimal Camera Kit Web SDK integration:</p>
<pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1">, </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">"@snap/camera-kit"</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">"Your API Token value copied from the SnapKit developer portal"</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvas</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">"my-canvas"</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">({ </span><span class="hl-0">liveRenderTarget:</span><span class="hl-1"> </span><span class="hl-0">canvas</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">events</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">'error'</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">if</span><span class="hl-1"> (</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">.</span><span class="hl-0">name</span><span class="hl-1"> === </span><span class="hl-3">'LensExecutionError'</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">'The current Lens encountered an error and was removed.'</span><span class="hl-1">, </span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">, </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">'user'</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">"<Lens ID>"</span><span class="hl-1">, </span><span class="hl-3">"<Lens Group ID>"</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">"Lens rendering has started!"</span><span class="hl-1">);</span><br/><span class="hl-1">})();</span><br/><br/><span class="hl-5">main</span><span class="hl-1">();</span>
</code><button>Copy</button></pre>
<a id="md:advanced-use-cases" class="tsd-anchor"></a><h2><a href="#md:advanced-use-cases">Advanced use cases</a></h2><a id="md:logging" class="tsd-anchor"></a><h3><a href="#md:logging">Logging</a></h3><p>By default, Camera Kit Web SDK does very minimal logging. Specifying <code>'console'</code> as logger will cause more log statements to be printed to the browser's console, which may be useful during development.</p>
<pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">apiToken:</span><span class="hl-1"> </span><span class="hl-3">'<apiToken>'</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-0">logger:</span><span class="hl-1"> </span><span class="hl-3">'console'</span><span class="hl-1">,</span><br/><span class="hl-1">});</span>
</code><button>Copy</button></pre>
<a id="md:keyboard-support-for-lenses" class="tsd-anchor"></a><h3><a href="#md:keyboard-support-for-lenses">Keyboard support for Lenses</a></h3><p>Some Lenses allow for keyboard input. The SDK provides a <code><textarea></code> (<code>HTMLTextAreaElement</code>) element that can be added to your page, and will send its text to the active Lens whenever the user presses the <code>Enter</code> key.</p>
<pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">textAreaContainer</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">'text-area-container'</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">textArea</span><span class="hl-1"> = </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">getElement</span><span class="hl-1">();</span><br/><span class="hl-0">textAreaContainer</span><span class="hl-1">.</span><span class="hl-5">appendChild</span><span class="hl-1">(</span><span class="hl-0">textArea</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<p>Alternatively, an event is emitted when a Lens is expecting text input. You can then implement your own UI and logic for obtaining text input from your users, and then send it back to the Lens. For example, something like:</p>
<pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">input</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">'my-text-area'</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">'active'</span><span class="hl-1">, () </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-0">classList</span><span class="hl-1">.</span><span class="hl-5">remove</span><span class="hl-1">(</span><span class="hl-3">'hidden'</span><span class="hl-1">);</span><br/><span class="hl-1">});</span><br/><br/><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">'keyup'</span><span class="hl-1">, () </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">sendInputToLens</span><span class="hl-1">(</span><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-0">value</span><span class="hl-1">);</span><br/><span class="hl-1">})</span>
</code><button>Copy</button></pre>
<p>See an example of this <a href="https://camera-kit.snapchat.com/websdk/sample/keyboard">here</a>.</p>
<a id="md:customizing-camerakitsource" class="tsd-anchor"></a><h3><a href="#md:customizing-camerakitsource">Customizing <code>CameraKitSource</code></a></h3><a id="md:setting-the-render-size" class="tsd-anchor"></a><h4><a href="#md:setting-the-render-size">Setting the render size</a></h4><p>By default, Camera Kit will render its output at the same resolution as the video input you provided. But you can also tell Camera Kit to render at a different resolution.</p>
<p>Keep in mind that this controls Camera Kit's render resolution, and not (necessarily) the size at which the output canvas is displayed to the user. The output canvas may be sized using HTML and CSS, and may apply its own scaling to the rendered output.</p>
<p>Most of the time you'll not need to set the render size – but it could be useful if your video source is, say, very high resolution. In that case, you may observe better performance by telling Camera Kit to render at a lower resolution.</p>
<pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">)</span><br/><span class="hl-7">// This must be done *after* calling `setSource()`</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">source</span><span class="hl-1">.</span><span class="hl-5">setRenderSize</span><span class="hl-1">(</span><span class="hl-0">width</span><span class="hl-1">, </span><span class="hl-0">height</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<blockquote>
<p>When calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a>, best performance can be achieved by requesting the resolution at which you want to render. This can be done using <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters">constraints</a>. Then you won't have to use <code>setRenderSize</code> at all.</p>
</blockquote>
<a id="md:camera-type" class="tsd-anchor"></a><h4><a href="#md:camera-type">Camera type</a></h4><p>When setting up a <code>CameraKitSource</code>, you can specify whether or not it is a front facing camera or a back facing camera. By default, the media source will be treated as a front facing camera. If it is a back facing camera be sure to specify it as such when you create your source; this ensures that Lenses created for back facing camera's (e.g. World AR) render properly.</p>
<pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">(</span><span class="hl-0">constraints</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">'environment'</span><span class="hl-1"> });</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<a id="md:fps-limit" class="tsd-anchor"></a><h4><a href="#md:fps-limit">FPS limit</a></h4><p>In some cases, it may be desirable to set a limit on the FPS at which Camera Kit renders. By default, Camera Kit will attempt to render frames at the same rate as the source media. But, for example, if your input media source has a very high framerate you may want to limit Camera Kit's rendering framerate to achieve better performance.</p>
<p>This can be done at the <code>CameraKitSession</code> level:</p>
<pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setFPSLimit</span><span class="hl-1">(</span><span class="hl-8">60</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<p>Or at the <code>CameraKitSource</code> level:</p>
<pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">(</span><span class="hl-0">constraints</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">fpsLimit:</span><span class="hl-1"> </span><span class="hl-8">60</span><span class="hl-1"> });</span>
</code><button>Copy</button></pre>
<p>These options can also be used with any of the <a href="#md:creating-a-camerakitsource">create source helpers</a>.</p>
<a id="md:2d-transforms" class="tsd-anchor"></a><h4><a href="#md:2d-transforms">2D transforms</a></h4><p>Any <code>CameraKitSource</code> can be transformed using a matrix, to rotate, scale, or mirror the source media. This is most often used to mirror a front-facing camera stream so that it appears more natural to the user.</p>
<pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">Transform2D</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">"@snap/camera-kit"</span><span class="hl-1">;</span><br/><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">)</span><br/><span class="hl-7">// This must be done *after* calling `setSource()`</span><br/><span class="hl-0">source</span><span class="hl-1">.</span><span class="hl-5">setTransform</span><span class="hl-1">(</span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">);</span>
</code><button>Copy</button></pre>
<a id="md:metrics-reporting" class="tsd-anchor"></a><h3><a href="#md:metrics-reporting">Metrics reporting</a></h3><p>Camera Kit Web SDK reports certain important events which may be of interest to the application.</p>
<blockquote>
<p>This is an unstable portion of the Camera Kit Web SDK's public API -- the specific events and their properties may change between versions of the SDK, without warning. We currently offer these events as a convenient way to gather more information from the SDK, but if you need to report accurate metrics (e.g. number of lens views), that is currently something you will have to implement in your application.</p>
</blockquote>
<p>Currently, the only event that may be of interest is the <code>lensView</code> event. It is emitted whenever a lens is <em>removed</em> from the <code>CameraKitSession</code>, indicating a complete lens view. It contains information about the lens' performance (e.g. fps, frame processing times, etc.) and how long the lens was applied.</p>
<p>You may listen to these events like so:</p>
<pre><code class="language-ts"><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">metrics</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">'lensView'</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">debug</span><span class="hl-1">(</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">);</span><br/><span class="hl-1">});</span>
</code><button>Copy</button></pre>
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-index-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><ul><li><ul><li><a href="#md:snap-camera-kit-web-sdk"><span>Snap <wbr/>Camera <wbr/>Kit <wbr/>Web SDK</span></a></li><li><ul><li><a href="#md:minimum-browser-requirements"><span>Minimum browser requirements</span></a></li><li><a href="#md:prerequisites"><span>Prerequisites</span></a></li><li><ul><li><a href="#md:snap-developer-set-up"><span>Snap <wbr/>Developer set up</span></a></li><li><a href="#md:development-environment"><span>Development environment</span></a></li><li><ul><li><a href="#md:using-the-sdk-in-a-javascript-project"><span>Using the SDK in a <wbr/>Java<wbr/>Script project</span></a></li></ul></li><li><a href="#md:content-security-policy"><span>Content <wbr/>Security <wbr/>Policy</span></a></li></ul></li><li><a href="#md:installing-the-sdk"><span>Installing the SDK</span></a></li><li><ul><li><a href="#md:importing-camera-kit"><span>Importing <wbr/>Camera <wbr/>Kit</span></a></li></ul></li><li><a href="#md:bootstrapping-the-sdk"><span>Bootstrapping the SDK</span></a></li><li><a href="#md:creating-a-camerakitsession"><span>Creating a <wbr/>Camera<wbr/>Kit<wbr/>Session</span></a></li><li><a href="#md:creating-a-camerakitsource"><span>Creating a <wbr/>Camera<wbr/>Kit<wbr/>Source</span></a></li><li><a href="#md:loading-applying-and-removing-lenses"><span>Loading, applying, and removing <wbr/>Lenses</span></a></li><li><ul><li><a href="#md:removing-the-lens"><span>Removing the <wbr/>Lens</span></a></li></ul></li><li><a href="#md:playback"><span>Playback</span></a></li><li><ul><li><a href="#md:playing-and-pausing-the-different-rendertargets"><span>Playing and pausing the different <wbr/>Render<wbr/>Targets</span></a></li></ul></li><li><a href="#md:error-handling"><span>Error <wbr/>Handling</span></a></li><li><a href="#md:putting-it-all-together"><span>Putting it all together</span></a></li><li><a href="#md:advanced-use-cases"><span>Advanced use cases</span></a></li><li><ul><li><a href="#md:logging"><span>Logging</span></a></li><li><a href="#md:keyboard-support-for-lenses"><span>Keyboard support for <wbr/>Lenses</span></a></li><li><a href="#md:customizing-camerakitsource"><span>Customizing <wbr/>Camera<wbr/>Kit<wbr/>Source</span></a></li><li><ul><li><a href="#md:setting-the-render-size"><span>Setting the render size</span></a></li><li><a href="#md:camera-type"><span>Camera type</span></a></li><li><a href="#md:fps-limit"><span>FPS limit</span></a></li><li><a href="#md:2d-transforms"><span>2<wbr/>D transforms</span></a></li></ul></li><li><a href="#md:metrics-reporting"><span>Metrics reporting</span></a></li></ul></li></ul></li></ul></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-1"></use></svg><span>CameraKit Web SDK - v0.22.0</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base="."><li><a href="enums/Lens_CameraFacing.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-8"></use></svg>Lens_CameraFacing</a></li><li><a href="classes/CameraKit.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>CameraKit</a></li><li><a href="classes/TypedCustomEvent.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>TypedCustomEvent</a></li><li><a href="classes/TypedEventTarget.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>TypedEventTarget</a></li><li><a href="classes/LensRepository.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>LensRepository</a></li><li><a href="classes/CameraKitSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>CameraKitSource</a></li><li><a href="classes/CameraKitSession.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>CameraKitSession</a></li><li><a href="classes/LensPerformanceMeasurement.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>LensPerformanceMeasurement</a></li><li><a href="classes/LensPerformanceMetrics.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>LensPerformanceMetrics</a></li><li><a href="classes/Transform2D.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg>Transform2D</a></li><li><a href="interfaces/CreateSessionOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>CreateSessionOptions</a></li><li><a href="interfaces/EstimatedLensPerformance.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>EstimatedLensPerformance</a></li><li><a href="interfaces/CameraKitBootstrapConfiguration.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>CameraKitBootstrapConfiguration</a></li><li><a href="interfaces/RemoteApiRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>RemoteApiRequest</a></li><li><a href="interfaces/RemoteApiResponse.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>RemoteApiResponse</a></li><li><a href="interfaces/RemoteApiService.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>RemoteApiService</a></li><li><a href="interfaces/UriRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>UriRequest</a></li><li><a href="interfaces/UriResponse.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>UriResponse</a></li><li><a href="interfaces/UriCancelRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>UriCancelRequest</a></li><li><a href="interfaces/LensCreator.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>LensCreator</a></li><li><a href="interfaces/Lens.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg>Lens</a></li><li>Loading...</li></ul></nav></div></div></div><div class="tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><svg style="display: none"><g id="icon-1"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-2"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g><g id="icon-16"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-32"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)"></path></g><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-128"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g><g id="icon-512"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-1024"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-2048"><rect fill="var(--color-icon-background)" stroke="#FF4DB8" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-4096"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-8192"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-16384"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-32768"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-65536"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-131072"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-262144"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-524288"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-1048576"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-4194304"><rect fill="var(--color-icon-background)" stroke="#FF4D82" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M10.354 17V8.24H13.066C13.586 8.24 14.042 8.348 14.434 8.564C14.826 8.772 15.13 9.064 15.346 9.44C15.562 9.816 15.67 10.256 15.67 10.76C15.67 11.352 15.514 11.86 15.202 12.284C14.898 12.708 14.482 13 13.954 13.16L15.79 17H14.518L12.838 13.28H11.434V17H10.354ZM11.434 12.308H13.066C13.514 12.308 13.874 12.168 14.146 11.888C14.418 11.6 14.554 11.224 14.554 10.76C14.554 10.288 14.418 9.912 14.146 9.632C13.874 9.352 13.514 9.212 13.066 9.212H11.434V12.308Z" fill="var(--color-text)"></path></g><g id="icon-chevronDown"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></g><g id="icon-chevronSmall"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></g><g id="icon-menu"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></g><g id="icon-search"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></g><g id="icon-anchor"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></g></svg></body></html>