types.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #include "types.h"
5 #include "image.h"
6 #include "device.h"
7 
8 #include <cstring>
9 #include <algorithm>
10 #include <array>
11 #include <deque>
12 #include <algorithm>
13 #include <iomanip>
14 
15 #define unknown "UNKNOWN"
16 
17 namespace rsimpl
18 {
19  const char * get_string(rs_stream value)
20  {
21  #define CASE(X) case RS_STREAM_##X: return #X;
22  switch(value)
23  {
24  CASE(DEPTH)
25  CASE(COLOR)
26  CASE(INFRARED)
27  CASE(INFRARED2)
28  CASE(POINTS)
29  CASE(RECTIFIED_COLOR)
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)
35  CASE(FISHEYE)
36  default: assert(!is_valid(value)); return unknown;
37  }
38  #undef CASE
39  }
40 
41  const char * get_string(rs_format value)
42  {
43  #define CASE(X) case RS_FORMAT_##X: return #X;
44  switch(value)
45  {
46  CASE(ANY)
47  CASE(Z16)
48  CASE(DISPARITY16)
49  CASE(XYZ32F)
50  CASE(YUYV)
51  CASE(RGB8)
52  CASE(BGR8)
53  CASE(RGBA8)
54  CASE(BGRA8)
55  CASE(Y8)
56  CASE(Y16)
57  CASE(RAW10)
58  CASE(RAW16)
59  CASE(RAW8)
60  default: assert(!is_valid(value)); return unknown;
61  }
62  #undef CASE
63  }
64 
65  const char * get_string(rs_preset value)
66  {
67  #define CASE(X) case RS_PRESET_##X: return #X;
68  switch(value)
69  {
70  CASE(BEST_QUALITY)
71  CASE(LARGEST_IMAGE)
72  CASE(HIGHEST_FRAMERATE)
73  default: assert(!is_valid(value)); return unknown;
74  }
75  #undef CASE
76  }
77 
79  {
80  #define CASE(X) case RS_DISTORTION_##X: return #X;
81  switch(value)
82  {
83  CASE(NONE)
84  CASE(MODIFIED_BROWN_CONRADY)
85  CASE(INVERSE_BROWN_CONRADY)
86  CASE(FTHETA)
87  default: assert(!is_valid(value)); return unknown;
88  }
89  #undef CASE
90  }
91 
92  const char * get_string(rs_option value)
93  {
94  #define CASE(X) case RS_OPTION_##X: return #X;
95  switch(value)
96  {
97  CASE(COLOR_BACKLIGHT_COMPENSATION)
98  CASE(COLOR_BRIGHTNESS)
99  CASE(COLOR_CONTRAST)
100  CASE(COLOR_EXPOSURE)
101  CASE(COLOR_GAIN)
102  CASE(COLOR_GAMMA)
103  CASE(COLOR_HUE)
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)
110  CASE(F200_ACCURACY)
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)
126  CASE(R200_LR_GAIN)
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)
154  CASE(FISHEYE_GAIN)
155  CASE(FISHEYE_STROBE)
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;
166  }
167  #undef CASE
168  }
169 
170  const char * get_string(rs_source value)
171  {
172  #define CASE(X) case RS_SOURCE_##X: return #X;
173  switch(value)
174  {
175  CASE(VIDEO)
176  CASE(MOTION_TRACKING)
177  CASE(ALL)
178  default: assert(!is_valid(value)); return unknown;
179  }
180  #undef CASE
181  }
182 
184  {
185  #define CASE(X) case RS_CAPABILITIES_##X: return #X;
186  switch(value)
187  {
188  CASE(DEPTH)
189  CASE(COLOR)
190  CASE(INFRARED)
191  CASE(INFRARED2)
192  CASE(FISH_EYE)
193  CASE(MOTION_EVENTS)
194  CASE(MOTION_MODULE_FW_UPDATE)
195  CASE(ADAPTER_BOARD)
196  CASE(ENUMERATION)
197  default: assert(!is_valid(value)); return unknown;
198  }
199  #undef CASE
200  }
201 
203  {
204  #define CASE(X) case RS_EVENT_##X: return #X;
205  switch(value)
206  {
207  CASE(IMU_ACCEL)
208  CASE(IMU_GYRO)
209  CASE(IMU_DEPTH_CAM)
210  CASE(IMU_MOTION_CAM)
211  CASE(G0_SYNC)
212  CASE(G1_SYNC)
213  CASE(G2_SYNC)
214  default: assert(!is_valid(value)); return unknown;
215  }
216  #undef CASE
217  }
218 
220  {
221  #define CASE(X) case RS_BLOB_TYPE_##X: return #X;
222  switch(value)
223  {
224  CASE(MOTION_MODULE_FIRMWARE_UPDATE)
225  default: assert(!is_valid(value)); return unknown;
226  }
227  #undef CASE
228  }
229 
231  {
232  #define CASE(X) case RS_CAMERA_INFO_##X: return #X;
233  switch(value)
234  {
235  CASE(DEVICE_NAME)
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)
241  CASE(CAMERA_TYPE)
242  CASE(OEM_ID)
243  CASE(MODULE_VERSION)
244  CASE(BUILD_DATE)
245  CASE(CALIBRATION_DATE)
246  CASE(PROGRAM_DATE)
247  CASE(FOCUS_ALIGNMENT_DATE)
248  CASE(FOCUS_VALUE)
249  CASE(CONTENT_VERSION)
250  CASE(ISP_FW_VERSION)
251  CASE(LENS_TYPE)
252  CASE(LENS_COATING__TYPE)
253  CASE(NOMINAL_BASELINE)
254  CASE(3RD_LENS_TYPE)
255  CASE(3RD_LENS_COATING_TYPE)
256  CASE(3RD_NOMINAL_BASELINE)
257  CASE(EMITTER_TYPE)
258  default: assert(!is_valid(value)); return unknown;
259  }
260  #undef CASE
261  }
262 
264  {
265  #define CASE(X) case RS_FRAME_METADATA_##X: return #X;
266  switch (value)
267  {
268  CASE(ACTUAL_EXPOSURE)
269  CASE(ACTUAL_FPS)
270  default: assert(!is_valid(value)); return unknown;
271  }
272  #undef CASE
273  }
274 
276  {
277  #define CASE(X) case RS_TIMESTAMP_DOMAIN_##X: return #X;
278  switch (value)
279  {
280  CASE(CAMERA)
281  CASE(MICROCONTROLLER)
282  default: assert(!is_valid(value)); return unknown;
283  }
284  #undef CASE
285  }
286 
288  {
290  }
291 
293  {
294  output_format = in_output_format;
295  }
296 
297  void subdevice_mode_selection::unpack(byte * const dest[], const byte * source) const
298  {
299  const int MAX_OUTPUTS = 2;
300  const auto & outputs = get_outputs();
301  assert(outputs.size() <= MAX_OUTPUTS);
302 
303  // Determine input stride (and apply cropping)
304  const byte * in = source;
305  size_t in_stride = mode.pf.get_image_size(mode.native_dims.x, 1);
306  if(pad_crop < 0) in += in_stride * -pad_crop + mode.pf.get_image_size(-pad_crop, 1);
307 
308  // Determine output stride (and apply padding)
309  byte * out[MAX_OUTPUTS];
310  size_t out_stride[MAX_OUTPUTS] = { 0 };
311  for(size_t i=0; i<outputs.size(); ++i)
312  {
313  out[i] = dest[i];
314  out_stride[i] = rsimpl::get_image_size(get_width(), 1, outputs[i].second);
315  if(pad_crop > 0) out[i] += out_stride[i] * pad_crop + rsimpl::get_image_size(pad_crop, 1, outputs[i].second);
316  }
317 
318  // Unpack (potentially a subrect of) the source image into (potentially a subrect of) the destination buffers
319  const int unpack_width = get_unpacked_width(), unpack_height = get_unpacked_height();
320  if(mode.native_dims.x == get_width())
321  {
322  // If not strided, unpack as though it were a single long row
323  mode.pf.unpackers[unpacker_index].unpack(out, in, unpack_width * unpack_height);
324  }
325  else
326  {
327 
328  // Otherwise unpack one row at a time
329  assert(mode.pf.plane_count == 1); // Can't unpack planar formats row-by-row (at least not with the current architecture, would need to pass multiple source ptrs to unpack)
330  for(int i=0; i<unpack_height; ++i)
331  {
332  mode.pf.unpackers[unpacker_index].unpack(out, in, unpack_width);
333  for(size_t i=0; i<outputs.size(); ++i) out[i] += out_stride[i];
334  in += in_stride;
335  }
336  }
337  }
338 
340  {
341  return std::min(mode.native_intrinsics.width, get_width());
342  }
343 
345  {
346  return std::min(mode.native_intrinsics.height, get_height());
347  }
348 
350  // static_device_info //
352 
354  {
355  if (((format != RS_FORMAT_ANY && format != req.format) ||
356  (width != 0 && width != req.width) ||
357  (height != 0 && height != req.height) ||
358  (fps != 0 && fps != req.fps) ||
359  (output_format != req.output_format)))
360  return true;
361  return false;
362  }
363 
365  {
366  return width != 0 && height != 0 && format != RS_FORMAT_ANY && fps != 0;
367  }
368 
369  static_device_info::static_device_info() : num_libuvc_transfer_buffers(1), nominal_depth_scale(0.001f)
370  {
371  for(auto & s : stream_subdevices) s = -1;
372  for(auto & s : data_subdevices) s = -1;
373  for(auto & s : presets) for(auto & p : s) p = stream_request();
374  for(auto & p : stream_poses)
375  {
376  p = {{{1,0,0},{0,1,0},{0,0,1}}, {0,0,0}};
377  }
378  }
379 
380  // search_request_params are used to find first request that satisfies cameras set of constraints
381  // each search_request_params represents requests for each stream type + index of current stream type under examination
383  {
385  int stream;
387  : stream(i)
388  {
389  for (auto i = 0; i<RS_STREAM_NATIVE_COUNT; i++)
390  {
391  requests[i] = in_requests[i];
392  }
393  }
394  };
395 
397  {
398  for (auto i = 0; i<RS_STREAM_NATIVE_COUNT; i++)
399  {
400  if (requests[i].enabled &&
401  (requests[i].height == 0 ||
402  requests[i].width == 0 ||
403  requests[i].format == RS_FORMAT_ANY ||
404  requests[i].fps == 0))
405  return false;
406  }
407  return true;
408  }
409 
410  // find_good_requests_combination is used to find requests that satisfy cameras set of constraints.
411  // this is done using BFS search over the posibility space.
412  // the algorithm:
413  // start with initial combination of streams requests- the input requests, can be empty or partially filled by user
414  // insert initial combination to a queue data structure (dequeu for performance)
415  // loop until queue is empty - at each iteration pop from queue the next set of requests.
416  // for each one of the next stream request posibilties create new items by adding them to current item and pushing them back to queue.
417  // once there is a item that all its stream requsts are filled
418  // and validated to satisfies all interstream constraints
419  // copy it to requests parameter and return true.
420  bool device_config::find_good_requests_combination( stream_request(&requests)[RS_STREAM_NATIVE_COUNT], std::vector<stream_request> stream_requests[RS_STREAM_NATIVE_COUNT]) const
421  {
422  std::deque<search_request_params> calls;
423 
424  // initial parameter is the input requests
425  // and its stream index is 0 (depth)
426  search_request_params p = { requests, 0 };
427  calls.push_back(p);
428 
429  while (!calls.empty())
430  {
431  //pop one item
432  p = calls.front();
433  calls.pop_front();
434 
435  //check if found combination that satisfies all interstream constraints
436  if (all_requests_filled(p.requests) && validate_requests(p.requests))
437  {
438  for (auto i = 0; i < RS_STREAM_NATIVE_COUNT; i++)
439  {
440  requests[i] = p.requests[i];
441  }
442  return true;
443  }
444 
445  //if this stream is not enabled or already filled move to next item
446  if (!requests[p.stream].enabled || requests[p.stream].is_filled())
447  {
448  // push the new requests parameter with stream = stream + 1
449  search_request_params new_p = { p.requests, p.stream + 1 };
450  calls.push_back(new_p);
451  continue;
452  }
453 
454  //now need to go over all posibilities for the next stream
455  for (size_t i = 0; i < stream_requests[p.stream].size(); i++)
456  {
457 
458  //check that this spasific request is not contradicts the original user request
459  if (!requests[p.stream].contradict(stream_requests[p.stream][i]))
460  {
461  //add to request the next option from possible requests
462  p.requests[p.stream] = stream_requests[p.stream][i];
463 
464  //if after adding the next stream request if it doesn't satisfies all interstream constraints
465  //do not insert it to queue
466  if (validate_requests(p.requests))
467  {
468  // push the new requests parameter with stream = stream + 1
469  search_request_params new_p = { p.requests, p.stream + 1 };
470  calls.push_back(new_p);
471  }
472  }
473  }
474 
475  }
476  //if deque is empty and no good requests combination found return false
477  return false;
478  }
479 
481  {
482  //did the user filled all requests?
483  if(all_requests_filled(requests))
484  {
485  return true;
486  }
487 
488  //If the user did not fill all requests, we need to fill the missing requests
489 
490  std::vector<stream_request> stream_requests[RS_STREAM_NATIVE_COUNT];
491  //Get all requests posibilities in order to find the requests that satisfies interstream constraints
492  get_all_possible_requestes(stream_requests);
493 
494  //find stream requests combination that satisfies all interstream constraints
495  return find_good_requests_combination(requests, stream_requests);
496  }
497 
498  void device_config::get_all_possible_requestes(std::vector<stream_request>(&stream_requests)[RS_STREAM_NATIVE_COUNT]) const
499  {
500  for (size_t i = 0; i < info.subdevice_modes.size(); i++)
501  {
502  stream_request request;
503  auto mode = info.subdevice_modes[i];
504 
505  for (auto pad_crop : mode.pad_crop_options)
506  {
507  for (auto & unpacker : mode.pf.unpackers)
508  {
509  auto selection = subdevice_mode_selection(mode, pad_crop, int(&unpacker - mode.pf.unpackers.data()));
510 
511  request.enabled = true;
512  request.fps = selection.get_framerate();
513  request.height = selection.get_height();
514  request.width = selection.get_width();
515  auto outputs = selection.get_outputs();
516 
517  for (auto output : outputs)
518  {
519  request.format = output.second;
520  for (auto output_format = static_cast<int>(RS_OUTPUT_BUFFER_FORMAT_CONTINUOUS); output_format < static_cast<int>(RS_OUTPUT_BUFFER_FORMAT_COUNT); output_format++)
521  {
522  request.output_format = static_cast<rs_output_buffer_format>(output_format);
523  stream_requests[output.first].push_back(request);
524  }
525  }
526  }
527  }
528  }
529  }
530 
532  {
533  // Determine if the user has requested any streams which are supplied by this subdevice
534  auto any_stream_requested = false;
535  std::array<bool, RS_STREAM_NATIVE_COUNT> stream_requested = {};
536  for(int j = 0; j < RS_STREAM_NATIVE_COUNT; ++j)
537  {
538  if(requests[j].enabled && info.stream_subdevices[j] == subdevice_index)
539  {
540  stream_requested[j] = true;
541  any_stream_requested = true;
542  }
543  }
544 
545  // If no streams were requested, skip to the next subdevice
546  if(!any_stream_requested) return subdevice_mode_selection();
547 
548  // Look for an appropriate mode
549  for(auto & subdevice_mode : info.subdevice_modes)
550  {
551  // Skip modes that apply to other subdevices
552  if(subdevice_mode.subdevice != subdevice_index) continue;
553 
554 
555  for(auto pad_crop : subdevice_mode.pad_crop_options)
556  {
557  for(auto & unpacker : subdevice_mode.pf.unpackers)
558  {
559  auto selection = subdevice_mode_selection(subdevice_mode, pad_crop, (int)(&unpacker - subdevice_mode.pf.unpackers.data()));
560 
561  // Determine if this mode satisfies the requirements on our requested streams
562  auto stream_unsatisfied = stream_requested;
563  for(auto & output : unpacker.outputs)
564  {
565  const auto & req = requests[output.first];
566 
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))
571  && (req.fps == subdevice_mode.fps))
572  {
573  stream_unsatisfied[output.first] = false;
574  }
575  }
576 
577  // If any requested streams are still unsatisfied, skip to the next mode
578  if(std::any_of(begin(stream_unsatisfied), end(stream_unsatisfied), [](bool b) { return b; })) continue;
579  return selection;
580  }
581  }
582  }
583 
584  // If we did not find an appropriate mode, report an error
585  std::ostringstream ss;
586  ss << "uvc subdevice " << subdevice_index << " cannot provide";
587  bool first = true;
588  for(int j = 0; j < RS_STREAM_NATIVE_COUNT; ++j)
589  {
590  if(!stream_requested[j]) continue;
591  ss << (first ? " " : " and ");
592  ss << requests[j].width << 'x' << requests[j].height << ':' << get_string(requests[j].format);
593  ss << '@' << requests[j].fps << "Hz " << get_string((rs_stream)j);
594  first = false;
595  }
596  throw std::runtime_error(ss.str());
597  }
598 
599  std::vector<subdevice_mode_selection> device_config::select_modes(const stream_request (&reqs)[RS_STREAM_NATIVE_COUNT]) const
600  {
601  // Make a mutable copy of our array
603  for (int i = 0; i<RS_STREAM_NATIVE_COUNT; ++i) requests[i] = reqs[i];
604 
605  //Validate that user requests satisfy all interstream constraints
606  validate_requests(requests, true);
607 
608  //Fill the requests that user did not fill
609  fill_requests(requests);
610 
611  // Select subdevice modes needed to satisfy our 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)
616  {
617  auto selection = select_mode(requests, i);
618  if(selection.mode.pf.fourcc) selected_modes.push_back(selection);
619  }
620  return selected_modes;
621  }
622 
623  bool device_config::validate_requests(stream_request(&requests)[RS_STREAM_NATIVE_COUNT], bool throw_exception) const
624  {
625  // Check and modify requests to enforce all interstream constraints
626 
627  for (auto & rule : info.interstream_rules)
628  {
629  auto & a = requests[rule.a], &b = requests[rule.b]; auto f = rule.field;
630  if (a.enabled && b.enabled)
631  {
632  bool compat = true;
633  std::stringstream error_message;
634 
635  if (rule.same_format)
636  {
637  if ((a.format != RS_FORMAT_ANY) && (b.format != RS_FORMAT_ANY) && (a.format != b.format))
638  {
639  if (throw_exception) error_message << rule.a << " format (" << rs_format_to_string(a.format) << ") must be equal to " << rule.b << " format (" << rs_format_to_string(b.format) << ")!";
640  compat = false;
641  }
642  }
643  else if((a.*f != 0) && (b.*f != 0))
644  {
645  if ((rule.bigger == RS_STREAM_COUNT) && (!rule.divides && !rule.divides2))
646  {
647  // Check for incompatibility if both values specified
648  if ((a.*f + rule.delta != b.*f) && (a.*f + rule.delta2 != b.*f))
649  {
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) << "!";
651  compat = false;
652  }
653  }
654  else
655  {
656  if (((rule.bigger == rule.a) && (a.*f < b.*f)) || ((rule.bigger == rule.b) && (b.*f < a.*f)))
657  {
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 << "!";
659  compat = false;
660  }
661  if ((rule.divides && (a.*f % b.*f)) || (rule.divides2 && (b.*f % a.*f)))
662  {
663  if (throw_exception) error_message << " " << rule.a << " value " << a.*f << " must " << (rule.divides ? "be divided by" : "divide") << rule.b << " value " << b.*f << "!";
664  compat = false;
665  }
666  }
667  }
668  if (!compat)
669  {
670  if (throw_exception)
671  throw std::runtime_error(to_string() << "requested settings for " << rule.a << " and " << rule.b << " are incompatible!" << error_message.str());
672  return false;
673  }
674  }
675  }
676  return true;
677  }
678 
680  {
681  if (is_any) return "any";
682 
683  std::stringstream s;
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;
688  return s.str();
689  }
690 
691  std::vector<std::string> firmware_version::split(const std::string& str)
692  {
693  std::vector<std::string> result;
694  auto e = str.end();
695  auto i = str.begin();
696  while (i != e){
697  i = find_if_not(i, e, [](char c) { return c == '.'; });
698  if (i == e) break;
699  auto j = find(i, e, '.');
700  result.emplace_back(i, j);
701  i = j;
702  }
703  return result;
704  }
705 
707  {
708  return atoi(split(name)[part].c_str());
709  }
710 
711  calibration_validator::calibration_validator(std::function<bool(rs_stream, rs_stream)> extrinsic_validator, std::function<bool(rs_stream)> intrinsic_validator)
712  : extrinsic_validator(extrinsic_validator), intrinsic_validator(intrinsic_validator)
713  {
714  }
715 
717  : extrinsic_validator([](rs_stream, rs_stream) { return true; }), intrinsic_validator([](rs_stream) { return true; })
718  {
719  }
720 
722  {
723  return extrinsic_validator(from_stream, to_stream);
724  }
726  {
727  return intrinsic_validator(stream);
728  }
729 
730 }
stream_request requests[RS_STREAM_NATIVE_COUNT]
Definition: types.cpp:384
bool find_good_requests_combination(stream_request(&output_requests)[RS_STREAM_NATIVE_COUNT], std::vector< stream_request > stream_requests[RS_STREAM_NATIVE_COUNT]) const
Definition: types.cpp:420
const GLint * first
Definition: glext.h:368
bool is_filled() const
Definition: types.cpp:364
rs_error * e
pose stream_poses[RS_STREAM_NATIVE_COUNT]
Definition: types.h:277
GLint GLint GLsizei GLsizei height
Definition: glext.h:112
int get_unpacked_height() const
Definition: types.cpp:344
rs_blob_type
Proprietary formats for direct communication with device firmware.
Definition: rs.h:228
native_pixel_format pf
Definition: types.h:158
std::vector< int > pad_crop_options
Definition: types.h:162
bool validate_intrinsics(rs_stream stream) const
Definition: types.cpp:725
GLsizei const GLchar *const * string
Definition: glext.h:683
std::function< bool(rs_stream stream)> intrinsic_validator
Definition: types.h:640
Definition: archive.h:12
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:2478
rs_option
Defines general configuration controls.
Definition: rs.h:128
GLuint GLuint stream
Definition: glext.h:1774
rs_output_buffer_format
Output buffer format: sets how librealsense works with frame memory.
Definition: rs.h:73
rs_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: rs.h:292
search_request_params(stream_request in_requests[RS_STREAM_NATIVE_COUNT], int i)
Definition: types.cpp:386
stream_request presets[RS_STREAM_NATIVE_COUNT][RS_PRESET_COUNT]
Definition: types.h:275
rs_format get_format(rs_stream stream) const
Definition: types.h:316
const uint8_t RS_STREAM_NATIVE_COUNT
Definition: types.h:27
std::string to_string() const
Definition: types.cpp:679
int stream_subdevices[RS_STREAM_NATIVE_COUNT]
Definition: types.h:271
size_t get_image_size(rs_stream stream) const
Definition: types.cpp:287
const GLubyte * c
Definition: glext.h:11542
rs_output_buffer_format output_format
Definition: types.h:298
#define CASE(X)
GLuint GLuint end
Definition: glext.h:111
rs_camera_info
Read-only strings that can be queried from the device.
Definition: rs.h:237
GLfloat f
Definition: glext.h:1868
#define unknown
Definition: types.cpp:15
rs_format
Formats: defines how each stream can be encoded.
Definition: rs.h:53
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:1104
GLsizei const GLfloat * value
Definition: glext.h:693
const std::vector< std::pair< rs_stream, rs_format > > & get_outputs() const
Definition: types.h:308
GLenum mode
Definition: glext.h:1117
rs_source
Source: allows you to choose between available hardware subdevices.
Definition: rs.h:90
std::vector< pixel_format_unpacker > unpackers
Definition: types.h:144
GLboolean GLboolean GLboolean b
Definition: glext.h:1104
bool validate_requests(stream_request(&requests)[RS_STREAM_NATIVE_COUNT], bool throw_exception=false) const
Definition: types.cpp:623
bool all_requests_filled(const stream_request(&original_requests)[RS_STREAM_NATIVE_COUNT]) const
Definition: types.cpp:396
const char * get_string(rs_stream value)
Definition: types.cpp:19
rs_preset
Presets: general preferences that are translated by librealsense into concrete resolution and FPS...
Definition: rs.h:81
bool fill_requests(stream_request(&requests)[RS_STREAM_NATIVE_COUNT]) const
Definition: types.cpp:480
std::vector< subdevice_mode_selection > select_modes() const
Definition: types.h:469
uint8_t byte
Definition: types.h:42
GLdouble s
Definition: glext.h:231
const char * rs_format_to_string(rs_format format)
Definition: rs.cpp:755
GLuint in
Definition: glext.h:8313
rs_stream
Streams are different types of data provided by RealSense devices.
Definition: rs.h:33
rs_format format
Definition: types.h:169
GLint GLint GLsizei width
Definition: glext.h:112
GLuint const GLchar * name
Definition: glext.h:655
std::function< bool(rs_stream from_stream, rs_stream to_stream)> extrinsic_validator
Definition: types.h:639
GLsizei GLsizei GLchar * source
Definition: glext.h:672
int data_subdevices[RS_STREAM_NATIVE_COUNT]
Definition: types.h:272
size_t get_image_size(int width, int height, rs_format format)
Definition: image.cpp:22
static std::vector< std::string > split(const std::string &str)
Definition: types.cpp:691
rs_capabilities
Specifies various capabilities of a RealSense device.
Definition: rs.h:213
bool contradict(stream_request req) const
Definition: types.cpp:353
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:112
rs_output_buffer_format output_format
Definition: types.h:171
rs_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
Definition: rs.h:99
subdevice_mode_selection select_mode(const stream_request(&requests)[RS_STREAM_NATIVE_COUNT], int subdevice_index) const
Definition: types.cpp:531
rs_frame_metadata
Types of value provided from the device with each frame.
Definition: rs.h:203
void unpack(byte *const dest[], const byte *source) const
Definition: types.cpp:297
void set_output_buffer_format(const rs_output_buffer_format in_output_format)
Definition: types.cpp:292
static int parse_part(const std::string &name, int part)
Definition: types.cpp:706
GLfloat GLfloat p
Definition: glext.h:11539
GLuint64EXT * result
Definition: glext.h:9881
rs_event_source
Source device that triggered a specific timestamp event from the motion module.
Definition: rs.h:276
bool validate_extrinsics(rs_stream from_stream, rs_stream to_stream) const
Definition: types.cpp:721
void get_all_possible_requestes(std::vector< stream_request >(&stream_requests)[RS_STREAM_NATIVE_COUNT]) const
Definition: types.cpp:498


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Fri Mar 13 2020 03:16:17