Skip to content

Commit

Permalink
refactor to node-addon-api
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterverweirder committed Apr 14, 2020
1 parent 121f90c commit 8b026b3
Showing 375 changed files with 227,365 additions and 9,657 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=NUZP3U3QZEQV2&currency_code=EUR&source=url"]
121 changes: 118 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,120 @@
node_modules
npm-debug.log
Thumbs.db
build/
.node_pre_gyprc
.node_pre_gyprc
.vscode/

# Ignore the downloaded SDK
/sdk

# Ignore the dll files in the root of this module and the examples folders and script folders
/*.dll
/*.onnx
/examples/**/*.dll
/examples/**/*.onnx
/scripts/*.dll
/scripts/*.onnx

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 Wouter Verweirder <wouter.verweirder@gmail.com>
Copyright (c) 2019 Wouter Verweirder <wouter.verweirder@gmail.com>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
73 changes: 30 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,46 @@
# Node-Kinect2
# Kinect2 Library for Node / Electron

Nodejs library to access the kinect 2 data from the official MS SDK on Windows.
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=NUZP3U3QZEQV2&currency_code=EUR&source=url)

![Screenshot](https://raw.githubusercontent.com/wouterverweirder/node-kinect2/master/node-kinect2-skeleton.png)
This library enables you to use the Kinect v2 in your nodejs or electron apps.

![screenshot of multi stream demo](examples/screenshots/multi-source-reader.png)

Features:

- get rgb camera feed
- get depth feed
- get ir feed
- point cloud (greyscale and colored)
- get skeleton joints (2d and 3d)
- user masking

## Installation

You will need to install [the official Kinect 2 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=44561) before you can use this module.

### node.js
Just npm install like you would do with any regular module.

You need at least node version 0.12 to use this module. Older versions do not work. Just use npm install:

``` bash
npm install kinect2
```
$ npm install kinect2
```

### electron
There are no precompiled binaries yet, so you need to have [node-gyp installed on your system](https://github.com/nodejs/node-gyp).

If you want to use this module inside an electron application, you will need to [build this module for electron usage](https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md). I've provided a build script which does just that.
## Examples

You will need to have node-gyp & it's dependencies installed (https://github.com/nodejs/node-gyp) before you can continue.
There are nodejs and electron examples in the examples/ folder of this repo. To run them, execute npm install and npm start:

``` bash
# cd into the directory of kinect2
cd node_modules\kinect2
# run my build script to create a native binary for electron
npm run build:electron
```
$ cd examples/electron
$ npm install
$ npm start
```

## Usage
The electron examples have the javascript code inside the html files. You can find these html files in [examples/electron/renderer/demos](examples/electron/renderer/demos).

```
var Kinect2 = require('kinect2');
var kinect = new Kinect2();
if(kinect.open()) {
console.log("Kinect Opened");
//listen for body frames
kinect.on('bodyFrame', function(bodyFrame){
for(var i = 0; i < bodyFrame.bodies.length; i++) {
if(bodyFrame.bodies[i].tracked) {
console.log(bodyFrame.bodies[i]);
}
}
});
//request body frames
kinect.openBodyReader();
//close the kinect after 5 seconds
setTimeout(function(){
kinect.close();
console.log("Kinect Closed");
}, 5000);
}
```
## Donate

Like this library? Always welcome to buy me a beer 🍺

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=NUZP3U3QZEQV2&currency_code=EUR&source=url)
20 changes: 6 additions & 14 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"targets": [
'targets': [
{
"target_name": "kinect2",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [ "src/kinect2.cc" ],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"<!@(node -p \"require('node-addon-api').include\")",
"$(KINECTSDK20_DIR)\\inc"
],
"conditions" : [
@@ -14,18 +16,8 @@
["target_arch=='x64'", {
"libraries": [ "-l$(KINECTSDK20_DIR)\\lib\\x64\\kinect20.lib" ]
}]
]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
}
]
}
26 changes: 0 additions & 26 deletions examples/basicexample.js

This file was deleted.

64 changes: 0 additions & 64 deletions examples/color-feed-browser-lwip/index.js

This file was deleted.

16 changes: 0 additions & 16 deletions examples/color-feed-browser-lwip/package.json

This file was deleted.

Loading

0 comments on commit 8b026b3

Please sign in to comment.