<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ishita Kabra</title>
    <description>The latest articles on DEV Community by Ishita Kabra (@ishita1805).</description>
    <link>https://dev.to/ishita1805</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F692006%2F398d8ab6-8a6b-43ca-bbcd-9307c820b484.jpeg</url>
      <title>DEV Community: Ishita Kabra</title>
      <link>https://dev.to/ishita1805</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ishita1805"/>
    <language>en</language>
    <item>
      <title>Adding AR Filters to Video Calls Using DeepAR and Dyte</title>
      <dc:creator>Ishita Kabra</dc:creator>
      <pubDate>Wed, 05 Jul 2023 08:12:58 +0000</pubDate>
      <link>https://dev.to/dyte/adding-ar-filters-to-video-calls-using-deepar-and-dyte-i3a</link>
      <guid>https://dev.to/dyte/adding-ar-filters-to-video-calls-using-deepar-and-dyte-i3a</guid>
      <description>&lt;p&gt;Unless you live under a rock, you would have used social media platforms such as TikTok, Instagram, Facebook, or Snapchat. When posting a photo or video on these platforms, you usually have the option to enhance the photo or video using various filters.&lt;/p&gt;

&lt;p&gt;You can transform yourself in an image or video with a different hair color or wear a cap even though you didn't take the photo or record a video wearing one.&lt;/p&gt;

&lt;p&gt;Social media platforms use Augmented Reality (AR) filters to make all these photo or video enhancements possible. AR filters are digital effects that can be applied to images or videos in real time, using computer vision technology to track the movements and facial features of someone in an image or video.&lt;/p&gt;

&lt;p&gt;The AR filters are mainly used for entertainment, branding, and marketing because they offer a fun and engaging way to enhance visual content. These filters can also create immersive experiences, such as virtual try-ons for clothing, and showcase products uniquely and interactively.&lt;/p&gt;

&lt;p&gt;In this article, you will learn how to build a video calling app with AR filters using &lt;a href="https://dyte.io/video-sdk"&gt;Dyte video SDK&lt;/a&gt;, DeepAR, and web components UI kit. Dyte is a developer-friendly platform that offers robust SDKs to build live experiences within an application.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisites&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To follow through with this article, you will need the following software installed on your computer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A text editor:&lt;/strong&gt; I will use Visual Studio Code as a text editor for this article. To install VS Code, navigate to the &lt;a href="https://code.visualstudio.com/download"&gt;VS Code download page&lt;/a&gt; and download it for your operating system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create and set up a Dyte account&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Navigate to &lt;a href="https://dyte.io/"&gt;dyte.io&lt;/a&gt; and click the ‘Start building’ button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hGyUZ686--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hGyUZ686--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--1.png" alt="dyte.io home page" width="800" height="435"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Sign up for a free Dyte account on the next page using your Google or GitHub account.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lQpSPlBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lQpSPlBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--2.png" alt="sign up page for a free Dyte account using your Google or GitHub account" width="800" height="434"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; After creating a Dyte account, you will be redirected to the ‘API Keys’ page, with an Organization ID and API key provided. Keep your API key secure, and don’t share it with anyone.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e0cMQ8gg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/ARFilters--3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e0cMQ8gg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/ARFilters--3.png" alt="developer portal API Keys" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create Presets&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Dyte includes a bunch of pre-configured presets. You can simply use the default preset if you don't wish to create one.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g1sw4I2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g1sw4I2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--4.png" alt="Dyte's pre-configured presets" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create a Dyte Meeting&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Navigate to the &lt;a href="https://docs.dyte.io/api?v=v2#/operations/create_meeting"&gt;Create a Meeting page.&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RQWqbKzX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RQWqbKzX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--5.png" alt="Create a Meeting page" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; On the right side of the page, fill the Username input field with Organization ID and the Password input field with your API Key provided on the API Keys page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YOwSOC93--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YOwSOC93--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--6.png" alt="filling in Organization ID and API Key" width="515" height="172"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; In the Body section, give the meeting a title of “AR Filters.” Then click the Send API Request button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--icBmv221--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--icBmv221--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--7.png" alt="giving the meeting a title of “AR Filters”" width="513" height="307"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 4:&lt;/strong&gt; Navigate to the Meetings page in the &lt;a href="https://accounts.dyte.io/auth/login"&gt;Dyte Developer Portal&lt;/a&gt;, and you should see that a meeting titled AR Filters was created.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vGPCKi_l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vGPCKi_l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--8.png" alt="Meetings page should have a meeting titled &amp;amp;quot;AR Filters&amp;amp;quot;" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Add a participant to the meeting&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Navigate to the &lt;a href="https://docs.dyte.io/api?v=v2#/operations/add_participant"&gt;Add a Participant page&lt;/a&gt; and fill out the Organization ID and API Key (you can get these from the &lt;a href="https://accounts.dyte.io/auth/login"&gt;Dyte Developer Portal&lt;/a&gt;) input fields as shown in the step above.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dLgI-Fyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dLgI-Fyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--9.png" alt="add a participant page" width="800" height="473"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; In the Parameters section, add the Meeting ID of the AR Filters meeting we created earlier.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0KyWR7ZI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0KyWR7ZI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--10.png" alt="Parameters section" width="512" height="127"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; In the Body section, fill out the options as shown below. Then click the 'Send API Request' button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V7R3DH53--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V7R3DH53--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--11.png" alt="filling out options in the body section" width="515" height="320"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 4:&lt;/strong&gt; Obtain the &lt;code&gt;token&lt;/code&gt;. This token is unique for each participant in the meeting, and you would ideally want to fetch it for each participant by calling Dyte’s APIs in your own backend.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UaEaoen5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UaEaoen5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--13.png" alt="get authToken named as 'token' in the last line of the API response" width="522" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating your Dyte Meeting&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a folder called 'ARFilters' on your computer. Then open the folder in a text editor and add to it an index.html file.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vS9jdSTJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vS9jdSTJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--12.png" alt="adding ARFilters folder to an index.html file in a text editor" width="800" height="340"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Install the Dyte SDK.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
  &amp;lt;script type="module"&amp;gt;
      import { defineCustomElements } from '&amp;lt;https://cdn.jsdelivr.net/npm/@dytesdk/ui-kit@1.51.1/loader/index.es2017.js&amp;gt;';
      defineCustomElements();
  &amp;lt;/script&amp;gt;
  &amp;lt;!-- Import Web Core via CDN too --&amp;gt;
  &amp;lt;script src="&amp;lt;https://cdn.dyte.in/core/dyte-1.14.0.js&amp;gt;"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; In your &lt;code&gt;index.html&lt;/code&gt; build a basic meeting UI with two custom buttons to control the AR filters.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;div id="app"&amp;gt;
      &amp;lt;dyte-dialog-manager class="dyte"&amp;gt;&amp;lt;/dyte-dialog-manager&amp;gt;
      &amp;lt;dyte-participants-audio class="dyte"&amp;gt;&amp;lt;/dyte-participants-audio&amp;gt;
      &amp;lt;dyte-notifications class="dyte"&amp;gt;&amp;lt;/dyte-notifications&amp;gt;
      &amp;lt;dyte-header class="dyte"&amp;gt;&amp;lt;/dyte-header&amp;gt;
      &amp;lt;div class="dyte-grid"&amp;gt;
        &amp;lt;dyte-grid class="dyte"&amp;gt;&amp;lt;/dyte-grid&amp;gt;
        &amp;lt;dyte-sidebar class="dyte" default-section="none"&amp;gt;
        &amp;lt;/dyte-sidebar&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class="dyte-controlbar"&amp;gt;
        &amp;lt;div class="controlbar-section"&amp;gt;
          &amp;lt;dyte-settings-toggle class="dyte"&amp;gt;&amp;lt;/dyte-settings-toggle&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="controlbar-section"&amp;gt;
          &amp;lt;dyte-mic-toggle class="dyte"&amp;gt;&amp;lt;/dyte-mic-toggle&amp;gt;
          &amp;lt;dyte-camera-toggle class="dyte"&amp;gt;&amp;lt;/dyte-camera-toggle&amp;gt;
          &amp;lt;dyte-leave-button class="dyte"&amp;gt;&amp;lt;/dyte-leave-button&amp;gt;
          &amp;lt;dyte-controlbar-button
            label="Add Filter"
            size="lg"
            id="arFilter"
            style="background-color: black; color: white"&amp;gt;
          &amp;lt;/dyte-controlbar-button&amp;gt;
          &amp;lt;dyte-controlbar-button
            label="Change Filter"
            size="lg"
            id="switchFilter"
            style="background-color: black; color: white"&amp;gt;
          &amp;lt;/dyte-controlbar-button&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;div class="controlbar-section"&amp;gt;
          &amp;lt;dyte-chat-toggle class="dyte"&amp;gt;&amp;lt;/dyte-chat-toggle&amp;gt;
          &amp;lt;dyte-participants-toggle class="dyte"&amp;gt;&amp;lt;/dyte-participants-toggle&amp;gt;
          &amp;lt;dyte-polls-toggle class="dyte"&amp;gt;&amp;lt;/dyte-polls-toggle&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;script type="module" src="/main.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We use custom components offered by Dyte to create a default meeting UI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dyte Header:&lt;/strong&gt; This component loads all the basic meeting details like the title, participant count, clock, and much more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dyte Grid:&lt;/strong&gt; This component renders all the video streams from all the participants in the meeting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dyte Sidebar:&lt;/strong&gt; This component renders chat, polls, participants list, and more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dyte Controlbar:&lt;/strong&gt; This is where we add controls for our meeting. A user can toggle their camera and mic, adjust settings or manage the AR filters from this control bar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We also insert a script that links to &lt;code&gt;main.js&lt;/code&gt;, an external file that will contain all our business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Write the business logic&lt;/p&gt;

&lt;p&gt;We initialize a basic Dyte Meeting using our &lt;code&gt;authToken&lt;/code&gt; and pass the meeting object to all our components.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import icons from './icons.json';

const init = async () =&amp;gt; {
  // Initialize Dyte Meeting
  const meeting = await DyteClient.init({
    authToken: import.meta.env.VITE_AUTH_TOKEN,
    defaults: {
      audio: false,
      video: false,
    },
  });

    // Passing the `meeting` prop to all our components
    const els = document.getElementsByClassName('dyte');
  els[0].config = meeting.self.config;
  for (const el of els) {
    el.meeting = meeting;
  }

    // Adding state management for the sidebar component
    document.body.addEventListener('dyteStateUpdate', ({ detail }) =&amp;gt; {
      document.querySelector('dyte-sidebar').style.display = detail.activeSidebar ? 'flex' : 'none';
      document.querySelector('dyte-sidebar').states = { sidebar: detail.activeSidebar ? detail.sidebar : 'none' };
    });

    // Adding icons to our custom buttons
  const AddFilter = document.getElementById("arFilter");
  const SwitchFilter = document.getElementById("switchFilter");

  AddFilter.icon = icons.addFilter;
  SwitchFilter.icon = icons.switchFilter;
};

init();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Adding CSS to our meeting.&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;style.css&lt;/code&gt;; this file will hold all our styles for the meeting.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body, html {
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: rgb(8, 8, 8);
}

#app {
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  flex-grow: 1;
  color: white;
}

.ended-screen {
  align-items: center;
  justify-content: center;
}

.dyte-grid {
  flex-grow: 1;
  display: flex;
  flex-direction: row;
}

dyte-grid {
 flex-grow: 1;
}

dyte-sidebar {
  margin: 10px 20px;
  border-radius: 10px;
}

.dyte-controlbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 20px;
  margin:10px 0;
  width: 100%;
}

.controlbar-section {
  display: flex;
  flex-direction: row;
  align-items: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Open the HTML file on a browser, and you will be prompted to allow access to your microphone and camera. You should see yourself on the screen if your camera is enabled.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--upPUhUOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Screenshot-2023-06-30-at-4.09.35-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--upPUhUOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Screenshot-2023-06-30-at-4.09.35-PM.png" alt="meeting with camera enabled" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setting up a DeepAR account&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Navigate to the &lt;a href="https://developer.deepar.ai/"&gt;DeepAR developer home page&lt;/a&gt; and click the ‘Get Started’ button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---U4Hj26a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---U4Hj26a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--15.png" alt="DeepAR home page" width="800" height="415"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Sign up for a free DeepAR account using your Google or GitHub account on the next page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ogh6ECZc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ogh6ECZc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--16.png" alt="DeepAR sign up page" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create a DeepAR project&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; After you’ve signed up and logged in to your DeepAR account, you will be redirected to the projects page.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_RmYf5EN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_RmYf5EN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--17.png" alt="DeepAR projects page" width="800" height="336"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Click the ‘Create A Project’ button. Name the project AR Filters, agree to the terms and conditions, then click the continue button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tAr83XnF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tAr83XnF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--18.png" alt="Create a project dialog box" width="800" height="661"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; After creating the project, you will be redirected to add an app. In this case, go to the Web App section and select &lt;code&gt;Add App&lt;/code&gt; option. You will be prompted to add a domain name. Add your domain name and click the continue button.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kveNqMJB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Vector--1-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kveNqMJB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Vector--1-.png" alt="DeepAR Web App" width="800" height="455"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Step 4:&lt;/strong&gt; You will receive DeepAR App Key after creating the web app. The key will initialize the DeepAR filter as a license key.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iJZkQutg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iJZkQutg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/05/ARFilters--20.png" alt="DeepAR app key" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Adding AR Filters to your video calling app&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that you have obtained your License key and have a basic Dyte Meeting up and running. It is time to add fun AR filters to your meeting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Install DeepAR&lt;/p&gt;

&lt;p&gt;You can import DeepAR into your project using CDN.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="&amp;lt;https://cdn.jsdelivr.net/npm/deepar/js/deepar.js&amp;gt;"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Initialize the DeepAR module&lt;/p&gt;

&lt;p&gt;Add some filters to our project repositories and provide a path to those filters.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Initialize DeepAR
  const filters = [
    "./effects/lion",
    "./effects/flowers",
    "./effects/dalmatian",
    "./effects/background_segmentation",
    "./effects/background_blur",
    "./effects/aviators",
  ];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, we create a canvas element and initialize the DeepAR module.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const deepARCanvas = document.createElement("canvas");
  deepARCanvas.width = 680;
  deepARCanvas.height = 480;
  const deepAR = await deepar.initialize({
    licenseKey: import.meta.env.VITE_DEEP_AR_TOKEN,
    canvas: deepARCanvas,
    effect: filters[0],
    additionalOptions: {
      cameraConfig: {
        disableDefaultCamera: true,
      },
    },
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Add AR filters to your Dyte video call&lt;/p&gt;

&lt;p&gt;Here, we are creating two functions, one to toggle the AR filter on/off and the other to switch between filters.&lt;/p&gt;

&lt;p&gt;We add middleware to Dyte using its &lt;code&gt;AddVideoMiddleware&lt;/code&gt; API, which takes in a middleware function.&lt;/p&gt;

&lt;p&gt;To switch between filters, we use DeepAR’s &lt;code&gt;switchEffect&lt;/code&gt; method.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let count = 0;
let filterIndex = 0;

const AddFilter = document.getElementById("arFilter");
const SwitchFilter = document.getElementById("switchFilter");

AddFilter.icon = icons.addFilter;
SwitchFilter.icon = icons.switchFilter;

AddFilter.addEventListener("click", toggleAR);
SwitchFilter.addEventListener("click", filterChangeHandler);

function toggleAR() {
  count++;

  if (count % 2 == 0) {
    AddFilter.label = 'Add Filter'
    meeting.self.removeVideoMiddleware(AddTheme);
  } else {
    AddFilter.label = 'Remove Filter'
    meeting.self.addVideoMiddleware(AddTheme);
  }
}

async function filterChangeHandler() {
  filterIndex = (filterIndex + 1) % filters.length;
  await deepAR.switchEffect(filters[filterIndex]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, let’s create our video middleware function using DeepAR.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function AddTheme() {
  let lastProcessedImage = null;
  const intermediatoryCanvas = document.createElement("canvas");
  intermediatoryCanvas.width = 640;
  intermediatoryCanvas.height = 480;
  const intermediatoryCanvasCtx = intermediatoryCanvas.getContext("2d");

  return async (canvas, ctx) =&amp;gt; {
    intermediatoryCanvasCtx.drawImage(canvas, 0, 0);
    if (lastProcessedImage) {
      ctx.drawImage(
        lastProcessedImage, 0, 0,
        lastProcessedImage.width,
        lastProcessedImage.height, 0, 0,
        canvas.width, canvas.height
      );
    }
    await deepAR.processImage(intermediatoryCanvas);
    const image = new Image();
    image.id = "picture";
    image.src = await deepAR.takeScreenshot();
    lastProcessedImage = image;
  };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With that done, we have built a video calling app with AR filters using &lt;a href="https://dyte.io/video-sdk"&gt;Dyte video SDK&lt;/a&gt; and DeepAR! Get your AR filters on to look something like this.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RVkd5mnB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Screenshot-2023-06-14-at-3.17.46-PM--1-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RVkd5mnB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dyte.io/blog/content/images/2023/06/Screenshot-2023-06-14-at-3.17.46-PM--1-.png" alt="DeepAR demo" width="800" height="403"&gt;&lt;/a&gt;&lt;br&gt;
You can try out the live demo of the sample application &lt;a href="https://dyte-io.github.io/video-calling-with-ar-filters/"&gt;here&lt;/a&gt;, and the entire source code for the project is available &lt;a href="https://github.com/dyte-io/video-calling-with-ar-filters"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In conclusion, we have walked you through how to build a video calling app with AR filters using the Dyte video and DeepAR SDKs. With Dyte’s customizable UI Kit, you can easily manage controls, add or remove buttons, create custom controls, and do much more with just a few lines of code.&lt;/p&gt;

&lt;p&gt;If this article tickled the builder in you, then check out &lt;a href="https://dyte.io/live-streaming-sdk"&gt;Dyte’s live streaming SDK&lt;/a&gt;. We provide easy-to-use SDKs to deliver interactive live streams at scale with much lower latency than traditional HLS. Feel at home with the same friendly developer experience and extensibility. Dyte’s live streaming SDK is &lt;a href="https://dyte.io/ph"&gt;launching soon on Product Hunt&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Get better insights on leveraging Dyte’s technology and discover how it can revolutionize your app’s communication capabilities with its &lt;a href="https://dyte.io/video-sdk"&gt;SDKs&lt;/a&gt;. You can reach us at &lt;a href="//mailto:support@dyte.io"&gt;support@dyte.io&lt;/a&gt; or ask our &lt;a href="https://community.dyte.io/"&gt;developer community&lt;/a&gt; if you have any questions.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>deepar</category>
      <category>dyte</category>
      <category>videosdk</category>
      <category>arfilters</category>
    </item>
  </channel>
</rss>
