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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!DOCTYPE html>
<html lang="en">


  <meta charset="UTF-8">
  <title>Handtrack.js : A library for prototyping realtime handtracking in the browser. </title>
  <link rel="stylesheet" href="" />
  <link rel="stylesheet" href="track.css">

<body class="bx--body p20">
  <!-- <img id="img" src="hand.jpg"/>  -->
  <div class="p20">
    Handtrack.js allows you prototype handtracking interactions in the browser in 10 lines of code.
  <div class="mb10">
    <button onclick="toggleVideo()" id="trackbutton" class="bx--btn bx--btn--secondary" type="button">
      Toggle Video
    <div id="updatenote" class="updatenote mt10"> loading model ..</div>
  <video class="videobox canvasbox" autoplay="autoplay" id="myvideo"></video>

  <canvas id="canvas" class="border canvasbox"></canvas>

  <script src=""></script>
  <script src=""> </script>
  <script src="track.js"></script>

              body {
    padding: 20px;

.p20 {
    padding: 20px;

.canvasbox {
    border-radius: 3px;
    margin-right: 10px;
    width: 450px;
    height: 338px;
    border-bottom: 3px solid #0063FF;
    box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2), 0 4px 10px 0 #00000030;
  background: #333;


.mb10 {
    margin-bottom: 10px

.mt10 {
    margin-top: 10px

.updatenote {
    padding: 10px;
    background: rgb(245, 147, 20);
    color: white;
    display: inline;
              const video = document.getElementById("myvideo");
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");
let trackButton = document.getElementById("trackbutton");
let updateNote = document.getElementById("updatenote");

let isVideo = false;
let model = null;

const modelParams = {
    flipHorizontal: true,   // flip e.g for video  
    maxNumBoxes: 20,        // maximum number of boxes to detect
    iouThreshold: 0.5,      // ioU threshold for non-max suppression
    scoreThreshold: 0.6,    // confidence threshold for predictions.

function startVideo() {
    handTrack.startVideo(video).then(function (status) {
        console.log("video started", status);
        if (status) {
            updateNote.innerText = "Video started. Now tracking"
            isVideo = true
        } else {
            updateNote.innerText = "Please enable video"

function toggleVideo() {
    if (!isVideo) {
        updateNote.innerText = "Starting video"
    } else {
        updateNote.innerText = "Stopping video"
        isVideo = false;
        updateNote.innerText = "Video stopped"

function runDetection() {
    model.detect(video).then(predictions => {
        console.log("Predictions: ", predictions);
        model.renderPredictions(predictions, canvas, context, video);
        if (isVideo) {

// Load the model.
handTrack.load(modelParams).then(lmodel => {
    // detect objects in the image.
    model = lmodel
    updateNote.innerText = "Loaded Model!"
    trackButton.disabled = false

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.