Skip to content

Instantly share code, notes, and snippets.

@zhuchen115
Created June 13, 2019 04:56
Show Gist options
  • Save zhuchen115/d13fe6062fbe23d0e3b8ebc4e196df45 to your computer and use it in GitHub Desktop.
Save zhuchen115/d13fe6062fbe23d0e3b8ebc4e196df45 to your computer and use it in GitHub Desktop.
Reterive all the options of Realsense using librealsense2
#include <iostream>
#include <librealsense2/rs.hpp>
using namespace std;
using namespace rs2;
const char* rs2_option_enum_name(int i);
int main()
{
rs2::config rscfg;
rscfg.enable_stream(RS2_STREAM_COLOR, 1280, 720, RS2_FORMAT_BGR8, 30);
rscfg.enable_stream(RS2_STREAM_INFRARED, 1280, 720, RS2_FORMAT_Y8, 30);
rscfg.enable_stream(RS2_STREAM_DEPTH, 1280, 720, RS2_FORMAT_Z16, 30);
pipeline pipe;
pipeline_profile selection = pipe.start(rscfg);
auto sensors = selection.get_device().query_sensors();
for (auto sr : sensors)
{
cout << sr.get_info(RS2_CAMERA_INFO_NAME) << endl;
for (int i = 0; i < 48; i++)
{
if (sr.supports((rs2_option)i))
{
option_range ora = sr.get_option_range((rs2_option)i);
cout << rs2_option_enum_name(i) << ":\t" << rs2_option_to_string((rs2_option)i) << " Range: \tMin:" << ora.min << " Max:" << ora.max << " Step:" << ora.step << " Default:" << ora.def;
bool optro;
if (optro = sr.is_option_read_only((rs2_option)i))
{
cout << " ro" << endl;
}
else
{
cout << " rw" << endl;
}
if ((ora.max - ora.min) / ora.step < 20 && (!optro))
{
cout << "--------------------------------------" << endl;
for (float val = ora.min; val <= ora.max; val += ora.step)
{
if(sr.get_option_value_description((rs2_option)i, val))
cout << val << ": " << sr.get_option_value_description((rs2_option)i, val) << endl;
}
cout << "--------------------------------------" << endl;
}
}
}
}
getchar();
}
const char* rs2_option_enum_name(int i)
{
switch (i)
{
case (int)RS2_OPTION_BACKLIGHT_COMPENSATION: return "RS2_OPTION_BACKLIGHT_COMPENSATION";
case (int)RS2_OPTION_BRIGHTNESS: return "RS2_OPTION_BRIGHTNESS";
case (int)RS2_OPTION_CONTRAST: return "RS2_OPTION_CONTRAST";
case (int)RS2_OPTION_EXPOSURE: return "RS2_OPTION_EXPOSURE";
case (int)RS2_OPTION_GAIN: return "RS2_OPTION_GAIN";
case (int)RS2_OPTION_GAMMA: return "RS2_OPTION_GAMMA";
case (int)RS2_OPTION_HUE: return "RS2_OPTION_HUE";
case (int)RS2_OPTION_SATURATION: return "RS2_OPTION_SATURATION";
case (int)RS2_OPTION_SHARPNESS: return "RS2_OPTION_SHARPNESS";
case (int)RS2_OPTION_WHITE_BALANCE: return "RS2_OPTION_WHITE_BALANCE";
case (int)RS2_OPTION_ENABLE_AUTO_EXPOSURE: return "RS2_OPTION_ENABLE_AUTO_EXPOSURE";
case (int)RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE: return "RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE";
case (int)RS2_OPTION_VISUAL_PRESET: return "RS2_OPTION_VISUAL_PRESET";
case (int)RS2_OPTION_LASER_POWER: return "RS2_OPTION_LASER_POWER";
case (int)RS2_OPTION_ACCURACY: return "RS2_OPTION_ACCURACY";
case (int)RS2_OPTION_MOTION_RANGE: return "RS2_OPTION_MOTION_RANGE";
case (int)RS2_OPTION_FILTER_OPTION: return "RS2_OPTION_FILTER_OPTION";
case (int)RS2_OPTION_CONFIDENCE_THRESHOLD: return "RS2_OPTION_CONFIDENCE_THRESHOLD";
case (int)RS2_OPTION_EMITTER_ENABLED: return "RS2_OPTION_EMITTER_ENABLED";
case (int)RS2_OPTION_FRAMES_QUEUE_SIZE: return "RS2_OPTION_FRAMES_QUEUE_SIZE";
case (int)RS2_OPTION_TOTAL_FRAME_DROPS: return "RS2_OPTION_TOTAL_FRAME_DROPS";
case (int)RS2_OPTION_AUTO_EXPOSURE_MODE: return "RS2_OPTION_AUTO_EXPOSURE_MODE";
case (int)RS2_OPTION_POWER_LINE_FREQUENCY: return "RS2_OPTION_POWER_LINE_FREQUENCY";
case (int)RS2_OPTION_ASIC_TEMPERATURE: return "RS2_OPTION_ASIC_TEMPERATURE";
case (int)RS2_OPTION_ERROR_POLLING_ENABLED: return "RS2_OPTION_ERROR_POLLING_ENABLED";
case (int)RS2_OPTION_PROJECTOR_TEMPERATURE: return "RS2_OPTION_PROJECTOR_TEMPERATURE";
case (int)RS2_OPTION_OUTPUT_TRIGGER_ENABLED: return "RS2_OPTION_OUTPUT_TRIGGER_ENABLED";
case (int)RS2_OPTION_MOTION_MODULE_TEMPERATURE: return "RS2_OPTION_MOTION_MODULE_TEMPERATURE";
case (int)RS2_OPTION_DEPTH_UNITS: return "RS2_OPTION_DEPTH_UNITS";
case (int)RS2_OPTION_ENABLE_MOTION_CORRECTION: return "RS2_OPTION_ENABLE_MOTION_CORRECTION";
case (int)RS2_OPTION_AUTO_EXPOSURE_PRIORITY: return "RS2_OPTION_AUTO_EXPOSURE_PRIORITY";
case (int)RS2_OPTION_COLOR_SCHEME: return "RS2_OPTION_COLOR_SCHEME";
case (int)RS2_OPTION_HISTOGRAM_EQUALIZATION_ENABLED: return "RS2_OPTION_HISTOGRAM_EQUALIZATION_ENABLED";
case (int)RS2_OPTION_MIN_DISTANCE: return "RS2_OPTION_MIN_DISTANCE";
case (int)RS2_OPTION_MAX_DISTANCE: return "RS2_OPTION_MAX_DISTANCE";
case (int)RS2_OPTION_TEXTURE_SOURCE: return "RS2_OPTION_TEXTURE_SOURCE";
case (int)RS2_OPTION_FILTER_MAGNITUDE: return "RS2_OPTION_FILTER_MAGNITUDE";
case (int)RS2_OPTION_FILTER_SMOOTH_ALPHA: return "RS2_OPTION_FILTER_SMOOTH_ALPHA";
case (int)RS2_OPTION_FILTER_SMOOTH_DELTA: return "RS2_OPTION_FILTER_SMOOTH_DELTA";
case (int)RS2_OPTION_HOLES_FILL: return "RS2_OPTION_HOLES_FILL";
case (int)RS2_OPTION_STEREO_BASELINE: return "RS2_OPTION_STEREO_BASELINE";
case (int)RS2_OPTION_AUTO_EXPOSURE_CONVERGE_STEP: return "RS2_OPTION_AUTO_EXPOSURE_CONVERGE_STEP";
case (int)RS2_OPTION_INTER_CAM_SYNC_MODE: return "RS2_OPTION_INTER_CAM_SYNC_MODE";
case (int)RS2_OPTION_STREAM_FILTER: return "RS2_OPTION_STREAM_FILTER";
case (int)RS2_OPTION_STREAM_FORMAT_FILTER: return "RS2_OPTION_STREAM_FORMAT_FILTER";
case (int)RS2_OPTION_STREAM_INDEX_FILTER: return "RS2_OPTION_STREAM_INDEX_FILTER";
case (int)RS2_OPTION_EMITTER_ON_OFF: return "RS2_OPTION_EMITTER_ON_OFF";
case (int)RS2_OPTION_COUNT: return "RS2_OPTION_COUNT";
default:
return "NOT EXIST";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment