Intel® RealSense™ Developer Documentation

These Examples demonstrate how to use the Node.js wrapper for the SDK.

List of Examples

Sample code source code is available on GitHub

For full Node.js AP documentation please open wrappers/nodejs/doc/index.html for full reference document. If it isn't there, run the following commands to generate it:

cd wrappers/nodejs
node scripts/generate-doc.js
#
Example
Description
Camera/SKU
Link to GitHub

1

Stream Depth and Color

This examples demonstrates how to stream depth and color

D400/L500

2

Pointcloud

This examples demonstrates pointcloude visualization

D400/L500

3

Remove background and align

Demonstrates
background removal by aligning depth images to color images

D400/L500

4

Save to Sisk

Demonstrates how to save a png and csv files to disk

D400/L500

5

Sensor Control

A tutorial for using the more advanced API that the RealSense SDK provides.

D400/L500

Stream Depth and Color code example

#!/usr/bin/env node

// Copyright (c) 2017 Intel Corporation. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license
// that can be found in the LICENSE file.

'use strict';

const rs2 = require('../index.js');
const {GLFWWindow} = require('./glfw-window.js');
const {glfw} = require('./glfw-window.js');

// A GLFW Window to display the captured image
const win = new GLFWWindow(1280, 720, 'Node.js Capture Example');

// Colorizer is used to map distance in depth image into different colors
const colorizer = new rs2.Colorizer();

// The main work pipeline of camera
const pipeline = new rs2.Pipeline();

// Start the camera
pipeline.start();

while (! win.shouldWindowClose()) {
  const frameset = pipeline.waitForFrames();
  // Build the color map
  const depthMap = colorizer.colorize(frameset.depthFrame);
  if (depthMap) {
    // Paint the images onto the window
    win.beginPaint();
    const color = frameset.colorFrame;
    glfw.draw2x2Streams(win.window, 2,
        depthMap.data, 'rgb8', depthMap.width, depthMap.height,
        color.data, 'rgb8', color.width, color.height);
    win.endPaint();
  }
}

pipeline.stop();
pipeline.destroy();
win.destroy();
rs2.cleanup();

Installation and Build Guidelines

Please refer to installation guideline at Node.js Installation and build guidelines

Updated 11 months ago

Node.js


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.