How to use rs2 method in wpt

Best JavaScript code snippet using wpt

test-functional.js

Source:test-functional.js Github

copy

Full Screen

1// Copyright (c) 2017 Intel Corporation. All rights reserved.2// Use of this source code is governed by an Apache 2.0 license3// that can be found in the LICENSE file.4'use strict';5/* global describe, it, before, after */6const assert = require('assert');7const rs2 = require('../index.js');8describe('Pipeline tests', function() {9 it('Default pipeline', () => {10 const pipe = new rs2.Pipeline();11 pipe.start();12 const frames = pipe.waitForFrames();13 assert.equal(frames.size > 0, true);14 pipe.stop();15 pipe.destroy();16 frames.destroy();17 });18 it('Pipeline with context', () => {19 const ctx = new rs2.Context();20 const pipe = new rs2.Pipeline(ctx);21 pipe.start();22 const frames = pipe.waitForFrames();23 assert.equal(frames.size > 0, true);24 pipe.stop();25 pipe.destroy();26 frames.destroy();27 });28});29describe('Frameset test', function() {30 let pipe;31 let frameset;32 before(function() {33 pipe = new rs2.Pipeline();34 pipe.start();35 frameset = pipe.waitForFrames();36 });37 after(function() {38 frameset.destroy();39 pipe.stop();40 pipe.destroy();41 });42 it('depthFrame test', () => {43 let depth = frameset.depthFrame;44 if (depth) {45 assert.equal(depth instanceof rs2.DepthFrame, true);46 depth.destroy();47 }48 });49 it('colorFrame test', () => {50 let color = frameset.colorFrame;51 if (color) {52 assert.equal(color instanceof rs2.VideoFrame, true);53 color.destroy();54 }55 });56 it('at test', () => {57 for (let i=0; i<frameset.size; i++) {58 let frame = frameset.at(i);59 assert.equal(frame instanceof rs2.Frame, true);60 frame.destroy();61 }62 });63 it('getFrame test', () => {64 let color = frameset.getFrame(rs2.stream.STREAM_COLOR);65 let depth = frameset.getFrame(rs2.stream.STREAM_DEPTH);66 if (color) {67 assert.equal(color instanceof rs2.VideoFrame, true);68 color.destroy();69 }70 if (depth) {71 assert.equal(depth instanceof rs2.DepthFrame, true);72 depth.destroy();73 }74 });75});76describe('Frame test', function() {77 let pipe;78 let frameset;79 let color;80 let depth;81 before(function() {82 pipe = new rs2.Pipeline();83 pipe.start();84 frameset = pipe.waitForFrames();85 color = frameset.colorFrame;86 depth = frameset.depthFrame;87 });88 after(function() {89 if (color) color.destroy();90 if (depth) depth.destroy();91 frameset.destroy();92 pipe.stop();93 pipe.destroy();94 pipe = undefined;95 frameset = undefined;96 color = undefined;97 depth = undefined;98 });99 it('format/stream/width/height/frameNumber/timestamp/isValid test', () => {100 if (depth) {101 assert.equal(depth.format, rs2.format.FORMAT_Z16);102 assert.equal(depth.streamType, rs2.format.STREAM_DEPTH);103 assert.equal(depth.isValid, true);104 assert.equal(depth.timestamp > 0, true);105 assert.equal(depth.frameNumber > 0, true);106 assert.equal(depth.width > 0, true);107 assert.equal(depth.height > 0, true);108 }109 if (color) {110 assert.equal(color.format, rs2.format.FORMAT_RGB8);111 assert.equal(color.streamType, rs2.format.STREAM_COLOR);112 assert.equal(color.isValid, true);113 assert.equal(color.timestamp > 0, true);114 assert.equal(color.frameNumber > 0, true);115 assert.equal(color.width > 0, true);116 assert.equal(color.height > 0, true);117 }118 });119 it('frame metadata test', () => {120 for (let i=0; i<rs2.frame_metadata.FRAME_METADATA_COUNT; i++) {121 if (depth && depth.supportsFrameMetadata(i)) {122 assert.equal(depth.frameMetadata(i) != undefined, true);123 }124 if (color && color.supportsFrameMetadata(i)) {125 assert.equal(color.frameMetadata(i) != undefined, true);126 }127 }128 });129 it('frame data test', () => {130 if (depth) {131 assert.equal(depth.data.length*2, depth.dataByteLength);132 }133 if (color) {134 assert.equal(color.data.length, color.dataByteLength);135 }136 });137 it('strideInBytes test', () => {138 if (depth) {139 assert.equal(depth.strideInBytes, depth.width*2);140 }141 if (color) {142 assert.equal(color.strideInBytes, color.width*3);143 }144 });145 it('getData test', () => {146 if (depth) {147 const buf1 = new Buffer(depth.dataByteLength);148 let buf2 = depth.getData(buf1);149 const buf3 = Buffer.from(depth.data.buffer);150 assert.equal(buf3.equals(buf1), true);151 assert.equal(buf3.equals(buf2), true);152 }153 if (color) {154 const buf1 = new Buffer(color.dataByteLength);155 let buf2 = color.getData(buf1);156 const buf3 = Buffer.from(color.data.buffer);157 assert.equal(buf3.equals(buf1), true);158 assert.equal(buf3.equals(buf2), true);159 }160 });161});162describe('Colorizer test', function() {163 let pipe;164 let frameset;165 let color;166 let depth;167 let colorizer;168 before(function() {169 pipe = new rs2.Pipeline();170 pipe.start();171 frameset = pipe.waitForFrames();172 color = frameset.colorFrame;173 depth = frameset.depthFrame;174 colorizer = new rs2.Colorizer();175 });176 after(function() {177 if (color) color.destroy();178 if (depth) depth.destroy();179 frameset.destroy();180 pipe.stop();181 pipe.destroy();182 colorizer.destroy();183 pipe = undefined;184 frameset = undefined;185 color = undefined;186 depth = undefined;187 colorizer = undefined;188 });189 it('colorize test', () => {190 if (depth) {191 const depthRGB = colorizer.colorize(depth);192 assert.equal(depthRGB.height, depth.height);193 assert.equal(depthRGB.width, depth.width);194 assert.equal(depthRGB.format, rs2.format.FORMAT_RGB8);195 depthRGB.destroy();196 depth.destroy();197 }198 });199});200describe('Pointcloud and Points test', function() {201 let pipe;202 let frameset;203 let color;204 let depth;205 let pc;206 let ctx;207 before(function() {208 ctx = new rs2.Context();209 pc = new rs2.Pointcloud();210 pipe = new rs2.Pipeline(ctx);211 pipe.start();212 frameset = pipe.waitForFrames();213 while (frameset.size != 2) {214 frameset.destroy();215 frameset = pipe.waitForFrames();216 }217 color = frameset.colorFrame;218 depth = frameset.depthFrame;219 });220 after(function() {221 if (color) color.destroy();222 if (depth) depth.destroy();223 frameset.destroy();224 pipe.stop();225 pipe.destroy();226 pc.destroy();227 ctx.destroy();228 pc = undefined;229 ctx = undefined;230 pipe = undefined;231 frameset = undefined;232 color = undefined;233 depth = undefined;234 });235 it('map and calculate test', () => {236 assert.equal(pc instanceof rs2.Pointcloud, true);237 pc.mapTo(color);238 const points = pc.calculate(depth);239 const cnt = depth.width*depth.height;240 assert.equal(points instanceof rs2.Points, true);241 assert.equal(points.size, cnt);242 const vertices = points.getVertices();243 const texCoordinates = points.getTextureCoordinates();244 assert.equal(vertices instanceof Float32Array, true);245 assert.equal(texCoordinates instanceof Int32Array, true);246 assert.equal(vertices.length, cnt*3);247 assert.equal(texCoordinates.length, cnt*2);248 });249});250describe('Context tests', function() {251 let ctx;252 before(() => {253 ctx = new rs2.Context();254 });255 after(() => {256 ctx.destroy();257 });258 it('Query devices', () => {259 const devs = ctx.queryDevices();260 assert.equal(devs.length, 1);261 assert.equal(devs[0] instanceof rs2.Device, true);262 devs.forEach((dev) => {263 dev.destroy();264 });265 });266 it('Query sensors', () => {267 const sensors = ctx.querySensors();268 assert.equal(sensors.length, 2);269 assert.equal(sensors[0] instanceof rs2.Sensor, true);270 assert.equal(sensors[1] instanceof rs2.Sensor, true);271 sensors.forEach((sensor) => {272 sensor.destroy();273 });274 });275});276describe('Sensor tests', function() {277 let ctx;278 let sensors;279 before(() => {280 ctx = new rs2.Context();281 sensors = ctx.querySensors();282 });283 after(() => {284 ctx.destroy();285 sensors.forEach((sensor) => {286 sensor.destroy();287 });288 ctx = undefined;289 sensors = undefined;290 });291 it('Stream profiles', () => {292 const profiles0 = sensors[0].getStreamProfiles();293 const profiles1 = sensors[1].getStreamProfiles();294 assert.equal(profiles1.length > 0, true);295 assert.equal(profiles0.length > 0, true);296 profiles0.forEach((p) => {297 assert.equal(p instanceof rs2.StreamProfile, true);298 assert.equal(p instanceof rs2.StreamProfile, true);299 assert.equal(p.streamType >= rs2.stream.STREAM_DEPTH &&300 p.streamType < rs2.stream.STREAM_COUNT, true);301 assert.equal(p.format >= rs2.format.FORMAT_Z16 && p.format < rs2.format.FORMAT_COUNT, true);302 assert.equal(p.fps>0, true);303 assert.equal(typeof p.uniqueID, 'number');304 assert.equal(typeof p.isDefault, 'boolean');305 });306 profiles1.forEach((p) => {307 assert.equal(p instanceof rs2.StreamProfile, true);308 assert.equal(p instanceof rs2.StreamProfile, true);309 });310 });311 it('Open and start', () => {312 return new Promise((resolve, reject) => {313 const profiles0 = sensors[0].getStreamProfiles();314 sensors[0].open(profiles0[0]);315 sensors[0].start((frame) => {316 assert.equal(frame instanceof rs2.Frame, true);317 frame.destroy();318 sensors[0].stop();319 sensors[0].close();320 resolve();321 });322 });323 });324 it('Get depth scale', () => {325 for (let i = 0; i < sensors.length; i++) {326 if (sensors[i] instanceof rs2.DepthSensor) {327 assert.equal(typeof sensors[i].depthScale === 'number', true);328 }329 }330 });331 it('getOptionDescription', () => {332 sensors.forEach((s) => {333 for (let i = rs2.option.OPTION_BACKLIGHT_COMPENSATION; i < rs2.option.OPTION_COUNT; i++) {334 let des = s.getOptionDescription(i);335 assert.equal((des === undefined) || (typeof des === 'string'), true);336 }337 });338 });339 it('getOption', () => {340 sensors.forEach((s) => {341 for (let i = rs2.option.OPTION_BACKLIGHT_COMPENSATION; i < rs2.option.OPTION_COUNT; i++) {342 let value = s.getOption(i);343 assert.equal((value === undefined) || (typeof value === 'number'), true);344 }345 });346 });347 it('getOptionValueDescription', () => {348 sensors.forEach((s) => {349 for (let i = rs2.option.OPTION_BACKLIGHT_COMPENSATION; i < rs2.option.OPTION_COUNT; i++) {350 let des = s.getOptionValueDescription(i, 1);351 assert.equal((des === undefined) || (typeof des === 'string'), true);352 }353 });354 });355 it('setOption', () => {356 sensors.forEach((s) => {357 for (let i = rs2.option.OPTION_BACKLIGHT_COMPENSATION; i < rs2.option.OPTION_COUNT; i++) {358 if (s.supportsOption(i) && !s.isOptionReadOnly(i)) {359 let range = s.getOptionRange(i);360 for (let j = range.minvalue; j <= range.maxValue; j += range.step) {361 s.setOption(i, j);362 let val = s.getOption(i);363 assert.equal(val, j);364 }365 }366 }367 });368 });369});370describe('Align tests', function() {371 let ctx;372 let align;373 let pipe;374 before(() => {375 ctx = new rs2.Context();376 align = new rs2.Align(rs2.stream.STREAM_COLOR);377 pipe = new rs2.Pipeline();378 });379 after(() => {380 pipe.stop();381 pipe.destroy();382 align.destroy();383 ctx.destroy();384 ctx = undefined;385 align = undefined;386 pipe = undefined;387 });388 it('process', () => {389 pipe.start();390 const frameset = pipe.waitForFrames();391 if (!frameset) {392 return;393 }394 const output = align.process(frameset);395 if (!output) {396 frameset.destroy();397 return;398 }399 const color = output.colorFrame;400 const depth = output.depthFrame;401 if (color) {402 assert.equal(color instanceof rs2.VideoFrame, true);403 color.destroy();404 }405 if (depth) {406 assert.equal(depth instanceof rs2.DepthFrame, true);407 depth.destroy();408 }409 output.destroy();410 frameset.destroy();411 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3test.runTest(url, function(err, data) {4 if (err) return console.error(err);5 console.dir(data);6});7### wpt(apikey, options)8### wpt.runTest(url, callback)9### wpt.getLocations(callback)10### wpt.getTesters(callback)11### wpt.getTestStatus(testId, callback)12Gets the status of the given `testId`. `callback` is called with `callback(err, data)`, where `err` is an error object and `data` is an

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, info) {4 console.log(info);5});6var wptools = require('wptools');7var page = wptools.page('Albert Einstein');8page.get(function(err, info) {9 console.log(info);10});11var wptools = require('wptools');12var page = wptools.page('Albert Einstein');13page.get(function(err, info) {14 console.log(info);15});16var wptools = require('wptools');17var page = wptools.page('Albert Einstein');18page.get(function(err, info) {19 console.log(info);20});21var wptools = require('wptools');22var page = wptools.page('Albert Einstein');23page.get(function(err, info) {24 console.log(info);25});26var wptools = require('wptools');27var page = wptools.page('Albert Einstein');28page.get(function(err, info) {29 console.log(info);30});31var wptools = require('wptools');32var page = wptools.page('Albert Einstein');33page.get(function(err, info) {34 console.log(info);35});36var wptools = require('wptools');37var page = wptools.page('Albert Einstein');38page.get(function(err, info) {39 console.log(info);40});41var wptools = require('wptools');42var page = wptools.page('Albert Einstein');43page.get(function(err, info) {44 console.log(info);45});46var wptools = require('wptools');47var page = wptools.page('Albert Einstein');48page.get(function(err, info) {49 console.log(info);50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var rs2 = require('wptoolkit').rs2;2var folder = "C:\\Users\\Public\\Documents\\My Games\\Sid Meier's Civilization V\\Saves";3rs2.getFiles(folder, function (err, files) {4 if (err) {5 console.log(err);6 return;7 }8 console.log(files);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org','A.1b8f8d2f2c9d2c7f0e8c8e7a6b1f1f1f');3var location = 'Dulles_MotoG4:Chrome';4var runs = 3;5var timeout = 1000;6var firstViewOnly = false;7var pollResults = 5;8var video = true;9var pollResults = 5;10var video = true;11var private = false;12var breakDown = true;13var connectivity = 'Cable';14var label = 'test';15var script = 'test.js';16var connectivity = 'Cable';17var label = 'test';18var script = 'test.js';19wpt.runTest(url, {20}, function(err, data) {21 if (err) return console.error(err);22 console.log(data);23});24var wpt = require('webpagetest');25var wpt = new WebPageTest('www.webpagetest.org','A.1b8f8d2f2c9d2c7f0e8c8e7a6b1f1f1f');26var location = 'Dulles_MotoG4:Chrome';27var runs = 3;28var timeout = 1000;29var firstViewOnly = false;30var pollResults = 5;31var video = true;32var pollResults = 5;33var video = true;34var private = false;35var breakDown = true;36var connectivity = 'Cable';37var label = 'test';38var script = 'test.js';39var connectivity = 'Cable';40var label = 'test';41var script = 'test.js';42wpt.runTest(url, {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful