Quickly integrate face, hand, and/or pose tracking to your frontend projects in a snap ✨👌

Overview

⚠️ IMPORTANT UPDATE: July 13th, 2022

Hi, this is Oz Ramos and I wanted to quickly explain what happened to this project and what I plan to do moving forward.

I started Handsfree.js back in 2018 while homeless in order to help a friend recovering from a stroke at the shelter use the web with face gestures. Overtime and through the support and encouragement of many people (see the "Special Thanks" section below) this project grew to become much more than that. This Spring, I had a severe mental health breakdown from chronic burnout and in an effort to "move on" I deleted my entire body of work. I'm sorry.

I will pin an issue soon to explain what led to the breakdown and what I (and anyone in a similar situation) can do. The documentation is temporarily hosted at https://handsfreejs.netlify.app/ for now until I get everything back in order, although it may take some time for me to do.

Unfortunately, this is an older version of the repo and an even older version of the docs and may not be totally up to date to whatever was the last version I left off at this Spring. Fortunately, most of the work will just involve updating the models.

Please allow for some time for all the links to be restored. In the meantime if you have any issues or would like to discuss any of this with me publicly I will be responding to issues/discussions, and if you'd like to message me privately see my profile for links.

Finally, I will create a list of other resources that you can use. If anyone would like to become a collaborator or take over the project, please let me know. Oz Ramos/Midifungi


https://handsfreejs.netlify.app

Quickly integrate face, hand, and/or pose tracking to your frontend projects in a snap 👌

Powered by:

       








💻 Project Documentation

I'm still experimenting with various ways to create documentation. The docs can be found:

Sorry for the confusion! I'll likely be settling on Notion but am still trying to find the best docs. Thanks!








Contents

This repo is broken into 3 main parts: The actual library itself found in /src/, the documentation for it in /docs/, and the Handsfree Browser Extension in /extension/.








Quickstart

Installing from CDN

Note: models loaded from the CDN may load slower on the initial page load, but should load much faster once cached by the browser.

This option is great if you don't have or need a server, or if you're prototyping on a site like CodePen. You can also just download this repo and work with one of the /boilerplate/.

<head>
  <!-- Include Handsfree.js -->
  <link rel="stylesheet" href="https://unpkg.com/[email protected]/build/lib/assets/handsfree.css" />
  <script src="https://unpkg.com/[email protected]/build/lib/handsfree.js"></script>
</head>

<body>
  <!-- Your code must be inside body as it applies classes to it -->
  <script>
    // Let's use handtracking and show the webcam feed with wireframes
    const handsfree = new Handsfree({showDebug: true, hands: true})
    handsfree.start()

    // Create a plugin named "logger" to show data on every frame
    handsfree.use('logger', data => {
      console.log(data.hands)
    })
  </script>
</body>

Installing from NPM

# From your projects root
npm i handsfree
// Inside your app
import Handsfree from 'handsfree'

// Let's use handtracking and enable the plugins tagged with "browser"
const handsfree = new Handsfree({showDebug: true, hands: true})
handsfree.enablePlugins('browser')
handsfree.start()

Hosting the models yourself

The above will load models, some over 10Mb, from the Unpkg CDN. If you'd rather host these yourself (for example, to use offline) then you can eject the models from the npm package into your project's public folder:

# Move the models into your project's public directory
# - change PUBLIC below to where you keep your project's assets

# ON WINDOWS
xcopy /e node_modules\handsfree\build\lib PUBLIC
# EVERYWHERE ELSE
cp -r node_modules/handsfree/build/lib/* PUBLIC
import Handsfree from 'handsfree'

const handsfree = new Handsfree({
  hands: true,
  // Set this to your where you moved the models into
  assetsPath: '/PUBLIC/assets',
})
handsfree.enablePlugins('browser')
handsfree.start()







Example Workflow

The following aims to give you a quick overview of how things work. The key takeaway is that everything is centered around hooks/plugins, which are basically named callbacks which are run on every frame and can be toggled on and off.

Quickstart Workflow

The following workflow demonstrates how to use all features of Handsfree.js. Check out the Guides and References to dive deeper, and feel free to post on the Google Groups or Discord if you get stuck!

// Let's enable face tracking with the default Face Pointer
const handsfree = new Handsfree({weboji: true})
handsfree.enablePlugins('browser')

// Now let's start things up
handsfree.start()

// Let's create a plugin called "logger"
// - Plugins run on every frame and is how you "plug in" to the main loop
// - "this" context is the plugin itself. In this case, handsfree.plugin.logger
handsfree.use('logger', data => {
  console.log(data.weboji.morphs, data.weboji.rotation, data.weboji.pointer, data, this)
})

// Let's switch to hand tracking now. To demonstrate that you can do this live,
// let's create a plugin that switches to hand tracking when both eyebrows go up
handsfree.use('handTrackingSwitcher', {weboji} => {
  if (weboji.state.browsUp) {
    // Disable this plugin
    // Same as handsfree.plugin.handTrackingSwitcher.disable()
    this.disable()

    // Turn off face tracking and enable hand tracking
    handsfree.update({
      weboji: false,
      hands: true
    })
  }
})

// You can enable and disable any combination of models and plugins
handsfree.update({
  // Disable weboji which is currently running
  weboji: false,
  // Start the pose model
  pose: true,

  // This is also how you configure (or pre-configure) a bunch of plugins at once
  plugin: {
    fingerPointer: {enabled: false},
    faceScroll: {
      vertScroll: {
        scrollSpeed: 0.01
      }
    }
  }
})

// Disable all plugins
handsfree.disablePlugins()
// Enable only the plugins for making music (not actually implemented yet)
handsfree.enablePlugins('music')

// Overwrite our logger to display the original model APIs
handsfree.plugin.logger.onFrame = (data) => {
  console.log(handsfree.model.pose?.api, handsfree.model.weboji?.api, handsfree.model.pose?.api)
}







Examples

Face Tracking Examples

Face Pointers

Motion Parallax Display

Puppeteering Industrial Robots

Playing desktop games with face clicks


Hand Tracking Examples

Hand Pointers

Use with Three.js

Playing desktop games with pinch clicks

Laser pointers but with your finger


Pose Estimation Examples

Flappy Pose - Flappy Bird but where you have to flap your arms








Local Development

If you'd like to contribute to the library or documentation then the following will get you going:

  • Install NodeJS and git
  • Clone this repository: git clone https://github.com/handsfreejs/handsfree
  • Install dependencies by running npm i in a terminal from the project's root
  • Start development on localhost:8080 by running npm start
  • Hit CTRL+C from the terminal to close the server

Once you've run the above, you can just use npm start. If you pull the latest code, remember to run npm i to get any new dependencies (this shouldn't happen often).

Command line scripts

# Start local development on localhost:8080
npm start 

# Builds the library, documentation, and extension
npm run build

# Build only the library /dist/lib/
npm run build:lib

# Build only the documentation at /dist/docs/
npm run build:docs

# Build only the extension at /dist/extension
npm run build:extension

# Publish library to NPM
npm login
npm publish

# Deploy documentation to handsfree.js.org
deploy.sh

Dev Notes

  • See vuepress-component-font-awesome for adding new icons to the documentation. Remember to run npm run fa:build when adding new font icons so that they are copied over into the docs/.vuepress/components/FA folder
  • You may occasionally need to restart server when adding new files to the /docs, this is true when changing /docs/.vuepress.config.js as well







The Handsfree Browser Extension

The Browser Extension is a designed to help you browse the web handsfree through face and/or hand gestures. The goal is to develop a "Userscript Manager" like Tampermonkey, but for handsfree-ifying web pages, games, apps, WebXR and really any other type of content found the web.

How it works

  • When you first install the extension, /src/background/handsfree.js checks if you've approved the webcam. If not, then it'll open the options page in src/options/stream-capture.html
  • The popup panel has a "Start/Stop Webcam" button that communicates with the background script to start the webcam: /src/popup/index.html
  • The background page is where the models are stored and run. This keeps everything isolated and only asks for webcam permission once (vs on every domain): /src/background/handsfree.js
  • The background page also uses the "Picture in Picture" API to "pop the webcam" out of the browser. It renders the webcam feed and debug canvases into a single canvas, and uses that as the srcObject to a separate video element which is the PiP'ed

How to install

Google Chrome

Install as an unpacked chrome extension.

  1. Visit chrome://extensions
  2. Enable Developer Mode on the top right
  3. Then click Load unpacked and select this project's root folder

Handsfree Browsing

By default, each page will get a "Face Pointer" or a set of "Palm Pointers" for you to browse pages handsfree.

A person controlling a virtual mouse pointer by tilting their head around A person scrolling a page by pinching their index and thumb together and raising or lowering their pinched hand

However, in addition to the pointers you can add custom handsfree interactions. For example, here's a demonstration of handsfree-ifying different things:

Creating generative art with hand gestures A person pinching the air to "pinch" a blob. Moving a pinched blob causes it to sing in a different pitch








Explore the interactive docs at: https://handsfreejs.netlify.app

Or try it right away with the serverless boilerplates in /boilerplate/!








License & Attributions

License: Apache 2.0

The Handsfree.js core is available for free and commercial use under Apache 2.0. Each of the models are also available for free and commercial use under Apache 2.0:

Attributions

I'd like to also thank the following people and projects:








Special Thanks

This is an old repo and this section will be updated soon to more deeply express my gratitude
  • @Chris Coleman and the Clinic for Open Source Arts for hosting me during a residency in Spring 2021 and for a grant in the Summer of 2021!
  • @Golan and the The STUDIO for Creative Inquiry for hosting me for a residency during 2019 and 2021 and for helping me approach projects in a more expressive way. Also a thank you for a grant in the Spring of 2022
  • @AnilDash for supporting the project during Winter 2018 out of the blue and the opportunities to share my project on Glitch.com
  • The School of AI for the 2018 Fellowship in support of this project
  • @jessscon and Google PAIR for the very early support that made starting this project possible
  • Everyone who's previously supported the project through GitHub Sponsors, Patreon, GoFundMe, and through Twitter and everywhere else over the years
You might also like...

Hand gesture recognition with React.js, Tensorflow.js and Fingerpose

Hand gesture recognition with React.js, Tensorflow.js and Fingerpose

Dec 7, 2022

JSNation 2022 - Building a Solar System using Hand Recognition and Three.js

JSNation 2022 - Building a Solar System using Hand Recognition and Three.js

Building a Solar System using Hand Recognition and Three.js 🚀 Accompanying code for JSNation 2022 talk. Demo video here: https://www.youtube.com/watc

Dec 14, 2022

Collection of custom elements that appear hand drawn. Great for wireframes or a fun look.

Collection of custom elements that appear hand drawn. Great for wireframes or a fun look.

wired-elements 👉 wiredjs.com Wired Elements is a series of basic UI Elements that have a hand drawn look. These can be used for wireframes, mockups,

Jan 7, 2023

API4AI Samples: Face Detection and Recognition

 API4AI Samples: Face Detection and Recognition

API4AI is cloud-native computer vision & AI platform for startups, enterprises and individual developers. This repository contains sample mini apps that utilizes Facial Image Analysis API provided by API4AI.

May 24, 2022

Implement MTCNN with Tensorflow.js. A face detection framework with MTCNN and Tensorflow.js

Implement MTCNN with Tensorflow.js. A face detection framework with MTCNN and Tensorflow.js

mtcnn-tfjs Implement mtcnn with Tensorflow.js What is this? A face detection framework with MTCNN and Tensorflow.js Give me a ⭐️ , if you like it ❤️ (

Nov 23, 2022

Frontend, contracts, and merkle tree generator for use in quickly scaffolding ERC20 token airdrops.

Merkle Airdrop Starter Quickly bootstrap an ERC20 token airdrop to a Merkle tree of recipients. Steps: Generate Merkle tree of recipients by following

Dec 22, 2022

A facial recognition/detection app with Angular using Microsoft's Face API

A facial recognition/detection app with Angular using Microsoft's Face API

Deja-Vu Overview Deja-Vu is a client side application generated with Angular CLI version 13. The core function of this application is to detect, recog

Jul 30, 2022

A jquery plugin that makes images truly responsive, without sacrificing anyone's face. Give it more stars!

A jquery plugin that makes images truly responsive, without sacrificing anyone's face. Give it more stars!

Responsify.js A jquery plugin that makes images truly responsive, without sacrificing anyone's face :D When images are used in a responsive container

Dec 14, 2022

Marquee is a VS Code extension designed to naturally integrate with your development flow, so that you will no longer lose track of your thoughts while you're coding

Marquee Stay organized with minimal context switching, all inside your Visual Studio Code. Marquee is a VS Code extension designed to naturally integr

Dec 13, 2022
Comments
  • Repo restoration

    Repo restoration

    @ozramos @MIDIBlocks Earlier this year I came across this project whilst researching solutions for hands recognitions. It worked amazing. I feel really sorry for what you been going through, wish I could help somehow.

    Anyway, it seems that I forked this repo when I was working with it. Maybe you can restore some of your work from there. Last commit was from March 8, 2022.

    https://github.com/juanRabaa/handsfree

    Cheers!

    opened by juanRabaa 0
Owner
Oz
Update: July 13 2023 - I recently burned out severely and deleted my entire body of work. I'm sorry and I am restoring what I can
Oz
Smart-face-detector - A face detector application made with React JS, Node JS, Express JS, and PostgreSQL.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Ken Tandrian 1 Sep 24, 2022
A-Frame components for smooth locomotion and snap turning

A-Frame locomotion A collection of A-Frame components, systems and primitives that enable all sorts of locomotion in VR. It't built to be modular, fle

Noeri Huisman 18 Sep 1, 2022
🏆Open source, free project management/issue tracking software to manage your work and projects

WorkClever ?? Open source, free project management/issue tracking software to manage your work and projects Features General Free to use, open source

WorkClever 11 Dec 27, 2022
A prototype snap for injecting gas fee prices into a confirmation window that also serves as the basis for a 5-minute Snaps tutorial

@Montoya/gas-fee-snap A simple Snap example based on @MetaMask/template-snap. Read below for a tutorial! Prerequisites Before you begin, make sure you

Christian Montoya 18 Dec 8, 2022
Stop re-writing thirdweb snippets. Use thirdsnips to make it all snap!

?? thirdsnips Stop re-writing thirdweb snippets. Use thirdsnips to make it all snap! Thirdsnips is a tool which enhances the developer experience whil

Avneesh Agarwal 24 Dec 14, 2022
📷 Detects your face and adds filters from your webcam. You can capture and download images.

Snapchat Filters on WebCam ?? Detects your face and adds filters from your webcam. You can capture and download images. ?? Visit site ?? Screenshots ?

Orhan Emre Dikicigil 2 Apr 27, 2022
In Your Face shows you Doom 'Ouch Faces' that correlate to the number of errors in your code!

In Your Face Watch how I made this extension on YouTube here In Your Face is a VS Code extension that shows you Doom 'Ouch Faces' that correlate to th

Virej Dasani 125 Dec 25, 2022
This package is for developers to be able to easily integrate bad word checking into their projects.\r This package can return bad words in array or regular expression (regex) form.

Vietnamese Bad Words This package is for developers to be able to easily integrate bad word checking into their projects. This package can return bad

Nguyễn Quang Sáng 8 Nov 3, 2022
A web tool for you to record your face and turn it into a 3D animation file.

Web Face Capture A free, open-source web tool for you to record your face and turn it into a 3D animation file. Go to the website Allow camera permisi

James Lee 9 Jan 6, 2023
App that allows you to control and watch YouTube videos using hand gestures. Additionally, app that allows you to search for videos, playlists, and channels.

YouTube Alternative Interaction App An app I made with Edward Wu that allows you to search and watch videos from YouTube. Leverages Google's YouTube D

Aaron Lam 2 Dec 28, 2021