Class: RecorderDevice

RecorderDevice(file, device)

This class provides the ability to record a live session of streaming to a file There are 2 ways for users to create a RecorderDevice:

 Syntax 1. RecorderDevice.from(device);
 Syntax 2. new RecorderDevice(file, device);
Syntax 1 can only be applied to device that can be converted to RecorderDevice, see below example:

 const file = 'record.bag';
 let cfg = new rs2.Config();
 cfg.enableRecordToFile(file);
 let pipe = new rs2.Pipeline();
 pipe.start(cfg);
 let device = pipe.getActiveProfile().getDevice();
 let recorder = rs2.RecorderDevice.from(device);

 // record 10 frames.
 for (let i = 0; i < 10; i++) {
   let frames = pipe.waitForFrames();
 }

 pipe.stop();
 // cleanup and make sure the recorded frames are flushed to file
 rs2.cleanup();
Syntax 2 is to create a RecorderDevice from a live device, see below example:

 let ctx = new rs2.Context();
 let dev = ctx.queryDevices().devices[0];
 // record to file record.bag
 let recorder = new rs2.RecorderDevice('record.bag', dev);
 let sensors = recorder.querySensors();
 let sensor = sensors[0];
 let profiles = sensor.getStreamProfiles();

 for (let i =0; i < profiles.length; i++) {
   if (profiles[i].streamType === rs2.stream.STREAM_DEPTH &&
       profiles[i].fps === 30 &&
       profiles[i].width === 640 &&
       profiles[i].height === 480 &&
       profiles[i].format === rs2.format.FORMAT_Z16) {
     sensor.open(profiles[i]);
   }
 }

 // record 10 frames
 let cnt = 0;
 sensor.start((frame) => {
   cnt++;
   if (cnt === 10) {
     // stop recording
     recorder.reset();
     rs2.cleanup();
     console.log('Recorded ', cnt, ' frames');
   }
 })

Constructor

new RecorderDevice(file, device)

Parameters:
Name Type Description
file String the file name to store the recorded data
device Device the actual device to be recorded
Source:

Extends

Members

fileName

Gets the name of the file to which the recorder is writing
Source:

first

Get the first sensor
Overrides:
Source:

isValid

Check if everything is OK, e.g. if the device object is connected to underlying hardware
Overrides:
Source:

Methods

(static) from(device) → {RecorderDevice|undefined}

Create a RecorderDevice from another device
Parameters:
Name Type Description
device Device another existing device
Source:
Returns:
If the the input device can be converted to a RecorderDevice, return the newly created RecorderDevice, otherwise, undefined is returned.
Type
RecorderDevice | undefined

destroy()

Release resources associated with the object
Overrides:
Source:

getCameraInfo(infoopt) → {CameraInfoObject|String|undefined}

Get camera information There are 2 acceptable forms of syntax:

 Syntax 1. getCameraInfo()
 Syntax 2. getCameraInfo(info)
Parameters:
Name Type Attributes Description
info String | Integer <optional>
the camera_info type, see camera_info for available values
Overrides:
Source:
Returns:
if no argument is provided, {CameraInfoObject} is returned. If a camera_info is provided, the specific camera info value string is returned.
Type
CameraInfoObject | String | undefined

pause()

Pause the recording device without stopping the actual device from streaming.
Source:

querySensors() → {Array.<Sensor>}

get an array of adjacent sensors, sharing the same physical parent composite device
Overrides:
Source:
Returns:
Type
Array.<Sensor>

reset() → {undefined}

Send hardware reset request to the device.
Overrides:
Source:
Returns:
Type
undefined

resume()

Resume the recording
Source:

supportsCameraInfo(info) → {Boolean|undefined}

Check if specific camera info is supported.
Parameters:
Name Type Description
info String | Integer info type to query. See camera_info for available values
Overrides:
Source:
See:
Returns:
Returns undefined if an invalid info type was specified.
Type
Boolean | undefined
Example

Example of 3 equivalent calls of the same query

device.supportsCameraInfo('name');
device.supportsCameraInfo(realsense2.camera_info.camera_info_name);
device.supportsCameraInfo(realsense2.camera_info.CAMERA_INFO_NAME);