Skip to content

Commit

Permalink
Merge pull request #1 from angular-adaptive/canary
Browse files Browse the repository at this point in the history
v0.1.0
  • Loading branch information
janantala committed Oct 20, 2013
2 parents 02e58ce + 4ff3a64 commit 4c4c123
Show file tree
Hide file tree
Showing 24 changed files with 16,947 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/components/
/bower_components/
node_modules/
*.log
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js
node_js:
- "0.8"

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install -g bower grunt-cli
- npm install
- bower install

script: "grunt"
38 changes: 38 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-jshint');

// Default task.
grunt.registerTask('default', ['karma', 'jshint']);

var karmaConfig = function(configFile, customOptions) {
var options = { configFile: configFile, keepalive: true };
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
return grunt.util._.extend(options, customOptions, travisOptions);
};

// Project configuration.
grunt.initConfig({
karma: {
unit: {
options: karmaConfig('test/test.conf.js')
}
},
jshint:{
files:['src/**/*.js', 'test/**/*.js'],
options: {
curly:true,
eqeqeq:true,
immed:true,
latedef:true,
newcap:true,
noarg:true,
sub:true,
boss:true,
eqnull:true,
devel:true,
globals:{}
}
}
});
}
180 changes: 177 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,178 @@
adaptive-motion
===============
# adaptive-motion v0.1.0 [![Build Status](https://travis-ci.org/angular-adaptive/adaptive-motion.png?branch=master)](https://travis-ci.org/angular-adaptive/adaptive-motion)

Want to control an AngularJS app using your body? Check it.
This module allows you to control an AngularJS app using web camera.

### Demo

Check out http://angular-adaptive.github.io/adaptive-motion/demo/

# Requirements

- AngularJS v 1.0+
- [getUserMedia Stream](http://caniuse.com/#feat=stream) support

# Usage

We use [bower](http://twitter.github.com/bower/) for dependency management. Add

dependencies: {
"angular-adaptive-motion": "latest"
}

To your `bower.json` file. Then run

bower install

This will copy the angular-adaptive-motion files into your `bower_components` folder, along with its dependencies. Load the script files in your application:

<script type="text/javascript" src="components/angular/angular.js"></script>
<script type="text/javascript" src="components/angular-adaptive-motion/src/adaptive-motion.js"></script>

Add the **adaptive.motion** module as a dependency to your application module:

var myAppModule = angular.module('MyApp', ['adaptive.motion']);

and include `$motion` service as a dependency to your controller:

angular.module('MyApp').controller('MainCtrl', function ['$scope', '$motion', ($scope, $motion) {

}]);

### Public methods

#### $motion.start();
Starts gesture recognition.

#### $motion.stop();
Stops gesture recognition.

#### $motion.onStart(cb);
On start callback.

#### $motion.onStop(cb);
On stop callback.

#### $motion.onError(cb);
On error callback.

#### $motion.onSwipeLeft(cb);
On swipe left gesture.
```
$motion.onSwipeLeft(function(data){
$scope.$apply(function(){
console.log('onSwipeLeft');
});
});
```

#### $motion.onSwipeRight(cb);
On swipe right gesture.
```
$motion.onSwipeRight(function(data){
$scope.$apply(function(){
console.log('onSwipeRight');
});
});
```

#### $motion.onSwipeUp(cb);
On swipe up gesture.
```
$motion.onSwipeUp(function(data){
$scope.$apply(function(){
console.log('onSwipeUp');
});
});
```

#### $motion.onSwipeDown(cb);
On swipe down gesture.
```
$motion.onSwipeDown(function(data){
$scope.$apply(function(){
console.log('onSwipeDown');
});
});
```


### Configuration

You can configure `$motionProvider` to a custom treshold options in app configuration.

```
$motionProvider.setTreshold({
'rgb': 150,
'move': 3,
'bright': 300
});
```

You can also set custom hsv filter.

```
$motionProvider.setHsvFilter({
'huemin': 0.0,
'huemax': 0.1,
'satmin': 0.0,
'satmax': 1.0,
'valmin': 0.4,
'valmax': 1.0
});
```

### Visualization

If you want to visualize you can add `adaptive-motion` attribute into your canvas element.
You can choose from following styles:


#### Video

```
<canvas adaptive-motion="video"></canvas>
```

![video](https://raw.github.com/angular-adaptive/adaptive-motion/canary/screens/video.png)

#### Skin

```
<canvas adaptive-motion="skin"></canvas>
```

![skin](https://raw.github.com/angular-adaptive/adaptive-motion/canary/screens/skin.png)

#### Edge

```
<canvas adaptive-motion="edge"></canvas>
```

![edge](https://raw.github.com/angular-adaptive/adaptive-motion/canary/screens/edges.png)

# Contributing

Contributions are welcome. Please make a pull request against canary branch and do not bump versions. Also include tests.

# Testing

We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:

npm install -g grunt-cli
npm install
bower install
grunt

The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in `test/test.config.js`

# References

Check out [willy-vvu`s](https://github.com/willy-vvu) webcam-based control of [reveal.js fork](https://github.com/willy-vvu/reveal.js).


# License

The MIT License

Copyright (c) 2013 Jan Antala, http://janantala.com
25 changes: 25 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "angular-adaptive-motion",
"version": "0.1.0",
"description": "This module allows you to control an angular app using your body.",
"author": "https://github.com/angular-adaptive/adaptive-motion/graphs/contributors",
"license": "MIT",
"homepage": "http://angular-adaptive.github.io",
"main": "./src/adaptive-motion.js",
"ignore": [
"**/.*",
"node_modules",
"components",
"test*",
"demo*",
"screens*",
"Gruntfile.js",
"package.json"
],
"dependencies": {
"angular": "~1.x"
},
"devDependencies": {
"angular-mocks": "~1.x"
}
}
Binary file added demo/assets/lightsaber.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/assets/lightsaber.wav
Binary file not shown.
7 changes: 7 additions & 0 deletions demo/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "motion",
"version": "0.0.0",
"dependencies": {
"angular": "~1.0.7"
}
}
Loading

0 comments on commit 4c4c123

Please sign in to comment.