Coder Social home page Coder Social logo

oflow's Introduction

oflow.js - optical flow detection in JavaScript

I made this little toy just for fun when I was traveling and had really long flight. The library allows you to detect optical flow in a video.

Here is an optical flow detection demo which lets you to control a ball and see movements in each zone of the video.

And this little Ping Pong game was also created on a plane. Right bar is controlled by the webcamera. Move your hand slowly up and down, to change the position of the right bar. Just moe your hands slowly do it gradually. Left bar is controlled by computer.

I didn't have time to do the 'tutorial' or proper error handling, I'm sorry if it wouldn't work for you. Please let me know.

Usage

Include /dist/oflow.js into your page.

To detect flow from the webcamera:

var flow = new oflow.WebCamFlow();
// Every time when optical flow is calculated
// call the passed in callback:
flow.onCalculated(function (direction) {
    // direction is an object which describes current flow:
    // direction.u, direction.v {floats} general flow vector
    // direction.zones {Array} is a collection of flowZones. 
    // Each flow zone describes optical flow direction inside of it.
    // flowZone : {
    //  x, y // zone center
    //  u, v // vector of flow in the zone
    // }
});
// Starts capturing the flow from webcamera:
flow.startCapture();
// once you are done capturing call
flow.stopCapture();

To detect flow from <video> element:

var flow = new oflow.VideoFlow(videoDomElement);
// the remaining API is the same as in the WebCamFlow exapmle above.

videoDomElement is required argument.

oflow's People

Contributors

anvaka avatar

Watchers

James Cloos avatar Tynesha Brown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.