15 #define unknown "UNKNOWN" 21 #define CASE(X) case RS_STREAM_##X: return #X; 30 CASE(COLOR_ALIGNED_TO_DEPTH)
31 CASE(DEPTH_ALIGNED_TO_COLOR)
32 CASE(DEPTH_ALIGNED_TO_RECTIFIED_COLOR)
33 CASE(INFRARED2_ALIGNED_TO_DEPTH)
34 CASE(DEPTH_ALIGNED_TO_INFRARED2)
36 default: assert(!is_valid(value));
return unknown;
43 #define CASE(X) case RS_FORMAT_##X: return #X; 60 default: assert(!is_valid(value));
return unknown;
67 #define CASE(X) case RS_PRESET_##X: return #X; 72 CASE(HIGHEST_FRAMERATE)
73 default: assert(!is_valid(value));
return unknown;
80 #define CASE(X) case RS_DISTORTION_##X: return #X; 84 CASE(MODIFIED_BROWN_CONRADY)
85 CASE(INVERSE_BROWN_CONRADY)
87 default: assert(!is_valid(value));
return unknown;
94 #define CASE(X) case RS_OPTION_##X: return #X; 97 CASE(COLOR_BACKLIGHT_COMPENSATION)
98 CASE(COLOR_BRIGHTNESS)
104 CASE(COLOR_SATURATION)
105 CASE(COLOR_SHARPNESS)
106 CASE(COLOR_WHITE_BALANCE)
107 CASE(COLOR_ENABLE_AUTO_EXPOSURE)
108 CASE(COLOR_ENABLE_AUTO_WHITE_BALANCE)
109 CASE(F200_LASER_POWER)
111 CASE(F200_MOTION_RANGE)
112 CASE(F200_FILTER_OPTION)
113 CASE(F200_CONFIDENCE_THRESHOLD)
114 CASE(F200_DYNAMIC_FPS)
115 CASE(SR300_AUTO_RANGE_ENABLE_MOTION_VERSUS_RANGE)
116 CASE(SR300_AUTO_RANGE_ENABLE_LASER)
117 CASE(SR300_AUTO_RANGE_MIN_MOTION_VERSUS_RANGE)
118 CASE(SR300_AUTO_RANGE_MAX_MOTION_VERSUS_RANGE)
119 CASE(SR300_AUTO_RANGE_START_MOTION_VERSUS_RANGE)
120 CASE(SR300_AUTO_RANGE_MIN_LASER)
121 CASE(SR300_AUTO_RANGE_MAX_LASER)
122 CASE(SR300_AUTO_RANGE_START_LASER)
123 CASE(SR300_AUTO_RANGE_UPPER_THRESHOLD)
124 CASE(SR300_AUTO_RANGE_LOWER_THRESHOLD)
125 CASE(R200_LR_AUTO_EXPOSURE_ENABLED)
127 CASE(R200_LR_EXPOSURE)
128 CASE(R200_EMITTER_ENABLED)
129 CASE(R200_DEPTH_UNITS)
130 CASE(R200_DEPTH_CLAMP_MIN)
131 CASE(R200_DEPTH_CLAMP_MAX)
132 CASE(R200_DISPARITY_MULTIPLIER)
133 CASE(R200_DISPARITY_SHIFT)
134 CASE(R200_AUTO_EXPOSURE_MEAN_INTENSITY_SET_POINT)
135 CASE(R200_AUTO_EXPOSURE_BRIGHT_RATIO_SET_POINT)
136 CASE(R200_AUTO_EXPOSURE_KP_GAIN)
137 CASE(R200_AUTO_EXPOSURE_KP_EXPOSURE)
138 CASE(R200_AUTO_EXPOSURE_KP_DARK_THRESHOLD)
139 CASE(R200_AUTO_EXPOSURE_TOP_EDGE)
140 CASE(R200_AUTO_EXPOSURE_BOTTOM_EDGE)
141 CASE(R200_AUTO_EXPOSURE_LEFT_EDGE)
142 CASE(R200_AUTO_EXPOSURE_RIGHT_EDGE)
143 CASE(R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_DECREMENT)
144 CASE(R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_INCREMENT)
145 CASE(R200_DEPTH_CONTROL_MEDIAN_THRESHOLD)
146 CASE(R200_DEPTH_CONTROL_SCORE_MINIMUM_THRESHOLD)
147 CASE(R200_DEPTH_CONTROL_SCORE_MAXIMUM_THRESHOLD)
148 CASE(R200_DEPTH_CONTROL_TEXTURE_COUNT_THRESHOLD)
149 CASE(R200_DEPTH_CONTROL_TEXTURE_DIFFERENCE_THRESHOLD)
150 CASE(R200_DEPTH_CONTROL_SECOND_PEAK_THRESHOLD)
151 CASE(R200_DEPTH_CONTROL_NEIGHBOR_THRESHOLD)
152 CASE(R200_DEPTH_CONTROL_LR_THRESHOLD)
153 CASE(FISHEYE_EXPOSURE)
156 CASE(FISHEYE_EXTERNAL_TRIGGER)
157 CASE(FRAMES_QUEUE_SIZE)
158 CASE(TOTAL_FRAME_DROPS)
159 CASE(FISHEYE_ENABLE_AUTO_EXPOSURE)
160 CASE(FISHEYE_AUTO_EXPOSURE_MODE)
161 CASE(FISHEYE_AUTO_EXPOSURE_ANTIFLICKER_RATE)
162 CASE(FISHEYE_AUTO_EXPOSURE_PIXEL_SAMPLE_RATE)
163 CASE(FISHEYE_AUTO_EXPOSURE_SKIP_FRAMES)
164 CASE(HARDWARE_LOGGER_ENABLED)
165 default: assert(!is_valid(value));
return unknown;
172 #define CASE(X) case RS_SOURCE_##X: return #X; 176 CASE(MOTION_TRACKING)
178 default: assert(!is_valid(value));
return unknown;
185 #define CASE(X) case RS_CAPABILITIES_##X: return #X; 194 CASE(MOTION_MODULE_FW_UPDATE)
197 default: assert(!is_valid(value));
return unknown;
204 #define CASE(X) case RS_EVENT_##X: return #X; 214 default: assert(!is_valid(value));
return unknown;
221 #define CASE(X) case RS_BLOB_TYPE_##X: return #X; 224 CASE(MOTION_MODULE_FIRMWARE_UPDATE)
225 default: assert(!is_valid(value));
return unknown;
232 #define CASE(X) case RS_CAMERA_INFO_##X: return #X; 236 CASE(DEVICE_SERIAL_NUMBER)
237 CASE(CAMERA_FIRMWARE_VERSION)
238 CASE(ADAPTER_BOARD_FIRMWARE_VERSION)
239 CASE(MOTION_MODULE_FIRMWARE_VERSION)
240 CASE(IMAGER_MODEL_NUMBER)
245 CASE(CALIBRATION_DATE)
247 CASE(FOCUS_ALIGNMENT_DATE)
249 CASE(CONTENT_VERSION)
252 CASE(LENS_COATING__TYPE)
253 CASE(NOMINAL_BASELINE)
255 CASE(3RD_LENS_COATING_TYPE)
256 CASE(3RD_NOMINAL_BASELINE)
258 default: assert(!is_valid(value));
return unknown;
265 #define CASE(X) case RS_FRAME_METADATA_##X: return #X; 268 CASE(ACTUAL_EXPOSURE)
270 default: assert(!is_valid(value));
return unknown;
277 #define CASE(X) case RS_TIMESTAMP_DOMAIN_##X: return #X; 281 CASE(MICROCONTROLLER)
282 default: assert(!is_valid(value));
return unknown;
299 const int MAX_OUTPUTS = 2;
301 assert(outputs.size() <= MAX_OUTPUTS);
305 size_t in_stride =
mode.pf.get_image_size(
mode.native_dims.x, 1);
309 byte * out[MAX_OUTPUTS];
310 size_t out_stride[MAX_OUTPUTS] = { 0 };
311 for(
size_t i=0; i<outputs.size(); ++i)
329 assert(
mode.pf.plane_count == 1);
330 for(
int i=0; i<unpack_height; ++i)
333 for(
size_t i=0; i<outputs.size(); ++i) out[i] += out_stride[i];
358 (fps != 0 && fps != req.
fps) ||
376 p = {{{1,0,0},{0,1,0},{0,0,1}}, {0,0,0}};
391 requests[i] = in_requests[i];
401 (requests[i].
height == 0 ||
402 requests[i].
width == 0 ||
404 requests[i].fps == 0))
422 std::deque<search_request_params> calls;
429 while (!calls.empty())
446 if (!requests[p.
stream].enabled || requests[p.
stream].is_filled())
450 calls.push_back(new_p);
455 for (
size_t i = 0; i < stream_requests[p.
stream].size(); i++)
459 if (!requests[p.
stream].contradict(stream_requests[p.
stream][i]))
470 calls.push_back(new_p);
483 if(all_requests_filled(requests))
492 get_all_possible_requestes(stream_requests);
495 return find_good_requests_combination(requests, stream_requests);
500 for (
size_t i = 0; i < info.subdevice_modes.size(); i++)
503 auto mode = info.subdevice_modes[i];
505 for (
auto pad_crop :
mode.pad_crop_options)
507 for (
auto & unpacker :
mode.pf.unpackers)
512 request.
fps = selection.get_framerate();
513 request.
height = selection.get_height();
514 request.
width = selection.get_width();
515 auto outputs = selection.get_outputs();
517 for (
auto output : outputs)
519 request.
format = output.second;
523 stream_requests[output.first].push_back(request);
534 auto any_stream_requested =
false;
535 std::array<bool, RS_STREAM_NATIVE_COUNT> stream_requested = {};
538 if(requests[j].
enabled && info.stream_subdevices[j] == subdevice_index)
540 stream_requested[j] =
true;
541 any_stream_requested =
true;
562 auto stream_unsatisfied = stream_requested;
563 for(
auto & output : unpacker.outputs)
565 const auto & req = requests[output.first];
567 selection.set_output_buffer_format(req.output_format);
568 if(req.enabled && (req.width == selection.get_width() )
569 && (req.height == selection.get_height())
570 && (req.format == selection.get_format(output.first))
573 stream_unsatisfied[output.first] =
false;
578 if(std::any_of(begin(stream_unsatisfied),
end(stream_unsatisfied), [](
bool b) {
return b; }))
continue;
585 std::ostringstream ss;
586 ss <<
"uvc subdevice " << subdevice_index <<
" cannot provide";
590 if(!stream_requested[j])
continue;
591 ss << (first ?
" " :
" and ");
592 ss << requests[j].width <<
'x' << requests[j].height <<
':' <<
get_string(requests[j].
format);
596 throw std::runtime_error(ss.str());
606 validate_requests(requests,
true);
609 fill_requests(requests);
612 int num_subdevices = 0;
613 for(
auto &
mode : info.subdevice_modes) num_subdevices = std::max(num_subdevices,
mode.subdevice+1);
614 std::vector<subdevice_mode_selection> selected_modes;
615 for(
int i = 0; i < num_subdevices; ++i)
617 auto selection = select_mode(requests, i);
618 if(selection.mode.pf.fourcc) selected_modes.push_back(selection);
620 return selected_modes;
627 for (
auto & rule : info.interstream_rules)
629 auto &
a = requests[rule.a], &
b = requests[rule.b];
auto f = rule.field;
630 if (
a.enabled && b.enabled)
633 std::stringstream error_message;
635 if (rule.same_format)
643 else if((
a.*
f != 0) && (b.*
f != 0))
645 if ((rule.bigger ==
RS_STREAM_COUNT) && (!rule.divides && !rule.divides2))
648 if ((
a.*
f + rule.delta != b.*
f) && (
a.*
f + rule.delta2 != b.*
f))
650 if (throw_exception) error_message <<
" " << rule.b <<
" value " << b.*
f <<
" must be equal to either " << (
a.*
f + rule.delta) <<
" or " << (
a.*
f + rule.delta2) <<
"!";
656 if (((rule.bigger == rule.a) && (
a.*
f < b.*
f)) || ((rule.bigger == rule.b) && (b.*
f <
a.*
f)))
658 if (throw_exception) error_message <<
" " << rule.a <<
" value " <<
a.*
f <<
" must be " << ((rule.bigger == rule.a) ?
"bigger" :
"smaller") <<
" then " << rule.b <<
" value " << b.*
f <<
"!";
661 if ((rule.divides && (
a.*
f % b.*
f)) || (rule.divides2 && (b.*f %
a.*f)))
663 if (throw_exception) error_message <<
" " << rule.a <<
" value " <<
a.*f <<
" must " << (rule.divides ?
"be divided by" :
"divide") << rule.b <<
" value " << b.*f <<
"!";
671 throw std::runtime_error(
to_string() <<
"requested settings for " << rule.a <<
" and " << rule.b <<
" are incompatible!" << error_message.str());
681 if (is_any)
return "any";
684 s << std::setfill(
'0') << std::setw(2) << m_major <<
"." 685 << std::setfill(
'0') << std::setw(2) << m_minor <<
"." 686 << std::setfill(
'0') << std::setw(2) << m_patch <<
"." 687 << std::setfill(
'0') << std::setw(2) << m_build;
693 std::vector<std::string>
result;
695 auto i = str.begin();
697 i = find_if_not(i,
e, [](
char c) {
return c ==
'.'; });
699 auto j = find(i,
e,
'.');
700 result.emplace_back(i, j);
708 return atoi(split(name)[part].c_str());
712 : extrinsic_validator(extrinsic_validator), intrinsic_validator(intrinsic_validator)
stream_request requests[RS_STREAM_NATIVE_COUNT]
bool find_good_requests_combination(stream_request(&output_requests)[RS_STREAM_NATIVE_COUNT], std::vector< stream_request > stream_requests[RS_STREAM_NATIVE_COUNT]) const
pose stream_poses[RS_STREAM_NATIVE_COUNT]
GLint GLint GLsizei GLsizei height
int get_unpacked_height() const
rs_blob_type
Proprietary formats for direct communication with device firmware.
std::vector< int > pad_crop_options
bool validate_intrinsics(rs_stream stream) const
GLsizei const GLchar *const * string
std::function< bool(rs_stream stream)> intrinsic_validator
GLenum GLenum GLsizei const GLuint GLboolean enabled
rs_option
Defines general configuration controls.
rs_output_buffer_format
Output buffer format: sets how librealsense works with frame memory.
rs_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
search_request_params(stream_request in_requests[RS_STREAM_NATIVE_COUNT], int i)
stream_request presets[RS_STREAM_NATIVE_COUNT][RS_PRESET_COUNT]
rs_format get_format(rs_stream stream) const
int get_unpacked_width() const
const uint8_t RS_STREAM_NATIVE_COUNT
std::string to_string() const
int stream_subdevices[RS_STREAM_NATIVE_COUNT]
size_t get_image_size(rs_stream stream) const
rs_output_buffer_format output_format
rs_camera_info
Read-only strings that can be queried from the device.
rs_format
Formats: defines how each stream can be encoded.
GLboolean GLboolean GLboolean GLboolean a
GLsizei const GLfloat * value
const std::vector< std::pair< rs_stream, rs_format > > & get_outputs() const
rs_source
Source: allows you to choose between available hardware subdevices.
GLboolean GLboolean GLboolean b
bool validate_requests(stream_request(&requests)[RS_STREAM_NATIVE_COUNT], bool throw_exception=false) const
bool all_requests_filled(const stream_request(&original_requests)[RS_STREAM_NATIVE_COUNT]) const
const char * get_string(rs_stream value)
rs_preset
Presets: general preferences that are translated by librealsense into concrete resolution and FPS...
bool fill_requests(stream_request(&requests)[RS_STREAM_NATIVE_COUNT]) const
std::vector< subdevice_mode_selection > select_modes() const
const char * rs_format_to_string(rs_format format)
rs_stream
Streams are different types of data provided by RealSense devices.
GLint GLint GLsizei width
GLuint const GLchar * name
std::function< bool(rs_stream from_stream, rs_stream to_stream)> extrinsic_validator
GLsizei GLsizei GLchar * source
int data_subdevices[RS_STREAM_NATIVE_COUNT]
size_t get_image_size(int width, int height, rs_format format)
static std::vector< std::string > split(const std::string &str)
rs_capabilities
Specifies various capabilities of a RealSense device.
bool contradict(stream_request req) const
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
rs_output_buffer_format output_format
rs_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
subdevice_mode_selection select_mode(const stream_request(&requests)[RS_STREAM_NATIVE_COUNT], int subdevice_index) const
rs_frame_metadata
Types of value provided from the device with each frame.
void unpack(byte *const dest[], const byte *source) const
void set_output_buffer_format(const rs_output_buffer_format in_output_format)
static int parse_part(const std::string &name, int part)
rs_event_source
Source device that triggered a specific timestamp event from the motion module.
bool validate_extrinsics(rs_stream from_stream, rs_stream to_stream) const
void get_all_possible_requestes(std::vector< stream_request >(&stream_requests)[RS_STREAM_NATIVE_COUNT]) const