Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="video-wrapper">
  <video onloadedmetadata="onPlay(this)" autoplay muted playsinline></video>
  <canvas id="overlay"></canvas>
  <div id="emotion">🤬</div>


                * {
  box-sizing: border-box;

.video-wrapper {
  position: relative;
  width: 400px;
  height: 300px;
  border: 1px solid red;

video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

#emotion {
  position: absolute;
  min-width: 20px;
  min-height: 20px;
  /*   border: 1px solid cyan; */
  z-index: 100;



                const videoEl = document.querySelector("video");
const output = document.getElementById("overlay");
const models = "";
const emotionDiv = document.getElementById("emotion");

const faceapi = window.faceapi;

async function initVideo() {
  const stream = await navigator.mediaDevices.getUserMedia({ video: {} });
  videoEl.srcObject = stream;


async function onPlay() {
  // TODO get faceDetectorOptions
  const options = new faceapi.TinyFaceDetectorOptions();
  const result = await faceapi
    .detectSingleFace(videoEl, options)

  if (result) {
    const dimensions = faceapi.matchDimensions(output, videoEl, true);
    const faceLocation = {
      x: result.detection._box._x,
      y: result.detection._box._y,
      width: result.detection._box._width,
      height: result.detection._box._height
    const emotions = {
      happy: "😀",
      angry: "😡",
      disgusted: "🤢",
      fearful: "😱",
      neutral: "😐",
      surprised: "😳"
    const currentEmotion = result.expressions.asSortedArray()[0].expression;
    emotionDiv.innerText = emotions[currentEmotion] || currentEmotion; = `
      top: ${faceLocation.y - faceLocation.height / 2}px;
      left: ${faceLocation.x + 30 /*- faceLocation.width / 4*/}px;
      width: ${faceLocation.width}px;
      font-size: ${faceLocation.width * 0.6}px;
    // faceapi.draw.drawDetections(output, faceapi.resizeResults(result, dimensions));

  requestAnimationFrame(() => onPlay());

// { happy: '😀', angry: '😡', disgusted: '🤢', fearful: '😱', neutral: '😐', surprised: '😮' }