Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Initial version of realsense node javascript API testing #3831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions misc/nodeapi-realsense-tests/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2016 Intel Corporation.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of works must retain the original copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the original copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this work without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions misc/nodeapi-realsense-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# RealSense Node JavaScript Test Suite

## Introduction

This test suite is for checking compliance with RealSense node API specification:
* https://github.com/otcshare/node-realsense/tree/master/src

## Authors

* Hao, Yunfei <[email protected]>
* Zhao, Ming <[email protected]>

## LICENSE

Copyright (c) 2016 Intel Corporation.
Except as noted, this software is licensed under BSD-3-Clause License.
Please see the COPYING file for the BSD-3-Clause License.
32 changes: 32 additions & 0 deletions misc/nodeapi-realsense-tests/realsense-manual/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var emitter = require('events').EventEmitter;
function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}
function getInstance(module, instanceConfig, cameraConfig) {
var module = module;
inherits(module.Instance, emitter);
if (cameraConfig) {
return new module.Instance(instanceConfig, cameraConfig);
} else {
return new module.Instance(instanceConfig);
}
}
var getObj = function getObj(module, name, instanceConfig, cameraConfig) {
var m = getInstance(module, instanceConfig, cameraConfig);
if (name == 'Instance') {
return m;
}
if (name == 'PersonTracking') {
return m.personTracking
}
else if (name == 'SkelonArea') {
m.getInstanceConfig.then(
data => {
return data.skeleton.traingArea;
}
);
}
}
exports.getObj = getObj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"use strict"
var emitter = require('events').EventEmitter;
const assert = require('assert');
var module = require('bindings')('realsense_pt');

function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}

inherits(module.Instance, emitter);

describe('check PersonTrackingResult', function(done){
var PersonTrackingResult = null;
var persons = null;
var person =null;

before(function(done){
var instanceConfig = {
tracking: {
enable: true,
enableSegmentation: true,
enableHeadPose: true,
enableBlob: true,
enablePersonOrientation: true,
enableHeadBoundingBox: true,
enableFaceLandmarks: true,
enableDetectionFromFar: true,
maxTrackedPerson: 1,
trackingMode: 'following',
detectMode: 'auto'
}
}
var instance = new module.Instance(instanceConfig);
instance.on('persontracked', function(result) {
PersonTrackingResult = result;
persons = PersonTrackingResult.persons;
person = persons[0];
done();
});
instance.start().then(function(){console.log('Start camera')});
this.timeout(10000);
})
it('check BoundingBox2DInfo interface: rect exist', function() {
var trackInfo = person.trackInfo;
var boundingBox = trackInfo.boundingBox;
var rect = boundingBox.rect;
assert.ok(rect);
});
it('check BoundingBox2DInfo interface: rect type', function() {
var trackInfo = person.trackInfo;
var boundingBox = trackInfo.boundingBox;
var rect = boundingBox.rect;
assert.equal(typeof(rect), 'object');
});
it('check BoundingBox2DInfo interface: confidence exist', function() {
var trackInfo = person.trackInfo;
var boundingBox = trackInfo.boundingBox;
var confidence = boundingBox.confidence;
assert.ok(confidence);
});
it('check BoundingBox2DInfo interface: confidence type', function() {
var trackInfo = person.trackInfo;
var boundingBox = trackInfo.boundingBox;
var confidence = boundingBox.confidence;
assert.equal(typeof(confidence), 'number');
});
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use strict"
var emitter = require('events').EventEmitter;
const assert = require('assert');
var module = require('bindings')('realsense_pt');

function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}

inherits(module.Instance, emitter);

describe('check PersonTrackingResult', function(done){
var PersonTrackingResult = null;
var persons = null;
var person =null;

before(function(done){
var instanceConfig = {
gesture: {
enable: true
}
}
var instance = new module.Instance(instanceConfig);
instance.on('persontracked', function(result) {
PersonTrackingResult = result;
persons = PersonTrackingResult.persons;
person = persons[0];
done();
});
instance.start().then(function(){console.log('Start camera')});
this.timeout(60000);
})
it('check GestureData interface: isPointing exist', function() {
var gesttureInfo = person.gestureInfo;
var isPointing = gesttureInfo.isPointing;
assert.ok(isPointing != undefined);
});
it('check GestureData interface: isPointing type', function() {
var gesttureInfo = person.gestureInfo;
var isPointing = gesttureInfo.isPointing;
assert.equal(typeof(isPointing), 'boolean');
});
it('check GestureData interface: thePointingInfo exist', function() {
var gesttureInfo = person.gestureInfo;
var thePointingInfo = gesttureInfo.thePointingInfo;
assert.ok(thePointingInfo != undefined);
});
it('check GestureData interface: thePointingInfo type', function() {
var gesttureInfo = person.gestureInfo;
var thePointingInfo = gesttureInfo.thePointingInfo;
assert.equal(typeof(thePointingInfo), 'object');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"use strict"
var emitter = require('events').EventEmitter;
const assert = require('assert');
var module = require('bindings')('realsense_pt');

function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}

inherits(module.Instance, emitter);
var boolean_group = [true, false];
var number_group = [0, 1, 2];
var trackingArea = ['upper-body', 'upper-body-rough', 'full-body-rough', 'full-body'];

var SkeletonConfig_enable = boolean_group;
var SkeletonConfig_maxTrackedPerson = number_group;
var SkeletonConfig_trackingArea = trackingArea;

function _test(i) {
describe('check enum SkeletonArea', function(done){
it('checking member of SkeletonArea: '+ i.enable + i.maxTrackedPerson + i.trackingArea, function(done) {
var cfg = {};
cfg['skeleton'] = i;
console.log(cfg);
var instance = new module.Instance(cfg);
instance.start().then(function(){
console.log('Start camera');
instance.stop().then(function(){console.log('Stop camera');});
assert.ok(true);
done();
}).catch(function(){
instance.stop().then(function(){console.log('Stop camera');});
assert.ok(false);
done();
});
});
});
}

for (var i in SkeletonConfig_enable) {
for (var j in SkeletonConfig_maxTrackedPerson) {
for (var k in SkeletonConfig_trackingArea) {
var config = {enable: SkeletonConfig_enable[i],
maxTrackedPerson: SkeletonConfig_maxTrackedPerson[j],
trackingArea: SkeletonConfig_trackingArea[k]
}
console.log(config);
_test(config);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"use strict"
var emitter = require('events').EventEmitter;
const assert = require('assert');
var module = require('bindings')('realsense_pt');

function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}

inherits(module.Instance, emitter);
//var boolean_group = [true, false];
var boolean_group = [true];
//var number_group = [0, 1, 2];
var number_group = [1];
//var trackingMode = ['following', 'interactive', 'single-person'];
var trackingMode = ['following','interactive'];
//var detectMode = ['auto', 'close-range', 'mid-range', 'far-range', 'all'];
var detectMode = ['auto'];

var TrackingConfig_enable = boolean_group;
var TrackingConfig_enableSegmentation = boolean_group;
var TrackingConfig_enableHeadPose = boolean_group;
var TrackingConfig_enableBlob = boolean_group;
var TrackingConfig_enablePersonOrientation = boolean_group;
var TrackingConfig_enableHeadBoundingBox = boolean_group;
var TrackingConfig_enableFaceLandmarks = boolean_group;
var TrackingConfig_enableDetectionFromFar = boolean_group;
var TrackingConfig_maxTrackedPerson = number_group;
var TrackingConfig_trackingMode = trackingMode;
var TrackingConfig_detectMode = detectMode;

function _test(i) {
describe('check enum SkeletonArea', function(done){
it('checking member of SkeletonArea: '+
i.enable + ' ' +
i.enableSegmentation + ' ' +
i.enableHeadPose + ' ' +
i.enableBlob + ' ' +
i.enablePersonOrientation + ' ' +
i.enableHeadBoundingBox + ' ' +
i.enableFaceLandmarks + ' ' +
i.enableDetectionFromFar+ ' ' +
i.maxTrackedPerson+ ' ' +
i.trackingMode + ' ' +
i.detectMode, function(done) {
var cfg = {};
cfg['tracking'] = i;
var instance = new module.Instance(cfg);
instance.start().then(function(){
console.log('Start camera');
//instance.stop().then(function(){console.log('Stop camera');});
assert.ok(true);
done();
}).catch(function(){
//instance.stop().then(function(){console.log('Stop camera');});
assert.ok(false);
done();
});
});
});
}

for (var i in TrackingConfig_enable) {
for (var j in TrackingConfig_enableSegmentation) {
for (var k in TrackingConfig_enableHeadPose) {
for (var l in TrackingConfig_enableBlob) {
for (var m in TrackingConfig_enablePersonOrientation) {
for (var n in TrackingConfig_enableHeadBoundingBox) {
for (var o in TrackingConfig_enableFaceLandmarks) {
for (var p in TrackingConfig_enableDetectionFromFar) {
for (var q in TrackingConfig_maxTrackedPerson) {
for (var r in TrackingConfig_trackingMode) {
for (var s in TrackingConfig_detectMode) {
var config = {enable: TrackingConfig_enable[i],
enableSegmentation: TrackingConfig_enableSegmentation[j],
enableHeadPose: TrackingConfig_enableHeadPose[k],
enableBlob: TrackingConfig_enableBlob[l],
enablePersonOrientation: TrackingConfig_enablePersonOrientation[m],
enableHeadBoundingBox: TrackingConfig_enableHeadBoundingBox[n],
enableFaceLandmarks: TrackingConfig_enableFaceLandmarks[o],
enableDetectionFromFar: TrackingConfig_enableDetectionFromFar[p],
maxTrackedPerson: TrackingConfig_maxTrackedPerson[q],
trackingMode: TrackingConfig_trackingMode[r],
detectMode: TrackingConfig_detectMode[s]
}
_test(config);
}
}
}
}
}
}
}
}
}
}
}
Loading