Repository navigation
Expand file tree
/
Copy pathkinect2.js
More file actions
105 lines (84 loc) · 3.16 KB
/
Copy pathkinect2.js
File metadata and controls
105 lines (84 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var edge = require('edge'),
path = require('path')
events = require('events'),
_ = require('lodash'),
util = require('util');
function Kinect2(options) {
events.EventEmitter.call(this);
var dllProperties = {
assemblyFile: __dirname + path.sep + 'NodeKinect2.dll',
typeName: 'NodeKinect2.Startup'
};
this.edge = {};
this.edge.create = edge.func(_.assign({}, dllProperties));
this.edge.open = edge.func(_.assign({ methodName: 'Open' }, dllProperties));
this.edge.openDepthReader = edge.func(_.assign({ methodName: 'OpenDepthReader' }, dllProperties));
this.edge.openBodyIndexReader = edge.func(_.assign({ methodName: 'OpenBodyIndexReader' }, dllProperties));
this.edge.openColorReader = edge.func(_.assign({ methodName: 'OpenColorReader' }, dllProperties));
this.edge.openInfraredReader = edge.func(_.assign({ methodName: 'OpenInfraredReader' }, dllProperties));
this.edge.openLongExposureInfraredReader = edge.func(_.assign({ methodName: 'OpenLongExposureInfraredReader' }, dllProperties));
this.edge.openBodyReader = edge.func(_.assign({ methodName: 'OpenBodyReader' }, dllProperties));
this.edge.close = edge.func(_.assign({ methodName: 'Close' }, dllProperties));
this.edge.create({
logCallback: this.logCallback.bind(this)
}, true);
}
util.inherits(Kinect2, events.EventEmitter);
Kinect2.prototype.open = function() {
return this.edge.open(null, true);
};
Kinect2.prototype.openDepthReader = function() {
return this.edge.openDepthReader({
depthFrameCallback: this.depthFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.openBodyIndexReader = function () {
return this.edge.openBodyIndexReader({
bodyIndexFrameCallback: this.bodyIndexFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.openColorReader = function() {
return this.edge.openColorReader({
colorFrameCallback: this.colorFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.openInfraredReader = function() {
return this.edge.openInfraredReader({
infraredFrameCallback: this.infraredFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.openLongExposureInfraredReader = function() {
return this.edge.openLongExposureInfraredReader({
longExposureInfraredFrameCallback: this.longExposureInfraredFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.openBodyReader = function() {
return this.edge.openBodyReader({
bodyFrameCallback: this.bodyFrameCallback.bind(this)
}, true);
};
Kinect2.prototype.close = function() {
return this.edge.close(null, true);
};
Kinect2.prototype.logCallback = function(msg) {
console.log('[Kinect2]', msg);
};
Kinect2.prototype.bodyFrameCallback = function(input, callback) {
this.emit('bodyFrame', input);
};
Kinect2.prototype.depthFrameCallback = function(data) {
this.emit('depthFrame', data);
};
Kinect2.prototype.bodyIndexFrameCallback = function (data) {
this.emit('bodyIndexFrame', data);
};
Kinect2.prototype.colorFrameCallback = function(data) {
this.emit('colorFrame', data);
};
Kinect2.prototype.infraredFrameCallback = function(data) {
this.emit('infraredFrame', data);
};
Kinect2.prototype.longExposureInfraredFrameCallback = function(data) {
this.emit('longExposureInfraredFrame', data);
};
module.exports = Kinect2;