Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
Last active August 13, 2018 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnaNancyOwen/46461fb78f38fea69b9b461cc52374fd to your computer and use it in GitHub Desktop.
Save UnaNancyOwen/46461fb78f38fea69b9b461cc52374fd to your computer and use it in GitHub Desktop.
#include <librealsense2/rs.hpp>
int main( int argc, char* argv[] )
{
// Set Device Config
rs2::config config;
config.enable_stream( rs2_stream::RS2_STREAM_INFRARED, 1, width, height, rs2_format::RS2_FORMAT_Y8, fps ); // Left
config.enable_stream( rs2_stream::RS2_STREAM_INFRARED, 2, width, height, rs2_format::RS2_FORMAT_Y8, fps ); // Right
// Start Pipeline
r2::pipeline pipeline;
rs2::pipeline_profile pipeline_profile = pipeline.start( config );
// Set Sensor Option
// IR Emitter
rs2::depth_sensor depth_sensor = pipeline_profile.get_device().first<rs2::depth_sensor>();
if( depth_sensor.supports( rs2_option::RS2_OPTION_EMITTER_ENABLED ) ){
depth_sensor.set_option( rs2_option::RS2_OPTION_EMITTER_ENABLED, 0.0f ); // Disable IR Emitter
// depth_sensor.set_option( rs2_option::RS2_OPTION_EMITTER_ENABLED, 1.0f ); // Enable IR Emitter
}
// Exposure
if( depth_sensor.supports( rs2_option::RS2_OPTION_EXPOSURE ) ){
const rs2::option_range option_range = depth_sensor.get_option_range( rs2_option::RS2_OPTION_EXPOSURE );
depth_sensor.set_option( rs2_option::RS2_OPTION_EXPOSURE, option_range.def ); // def:8500 (min:20 - max:166000), step:20
}
// Gain
if( depth_sensor.supports( rs2_option::RS2_OPTION_GAIN ) ){
const rs2::option_range option_range = depth_sensor.get_option_range( rs2_option::RS2_OPTION_GAIN );
depth_sensor.set_option( rs2_option::RS2_OPTION_GAIN, option_range.def ); // def:16 (min:16 - max:248), step:1
}
/* ... */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment