UnaNancyOwen
8/12/2018 - 2:09 PM

main.cpp

#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;
}