unit-tests-live-ds-common.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 
5 // This set of tests is valid only for the DS-device camera //
7 
8 #if !defined(MAKEFILE) || ( defined(LR200_TEST) || defined(R200_TEST) || defined(ZR300_TEST) )
9 
10 #define CATCH_CONFIG_MAIN
11 
12 #include <climits>
13 #include <sstream>
14 
16 
17 
18 // noexcept is not accepted by Visual Studio 2013 yet, but noexcept(false) is require on throwing destructors on gcc and clang
19 // It is normally advisable not to throw in a destructor, however, this usage is safe for require_error/require_no_error because
20 // they will only ever be created as temporaries immediately before being passed to a C ABI function. All parameters and return
21 // types are vanilla C types, and thus nothrow-copyable, and the function itself cannot throw because it is a C ABI function.
22 // Therefore, when a temporary require_error/require_no_error is destructed immediately following one of these C ABI function
23 // calls, we should not have any exceptions in flight, and can freely throw (perhaps indirectly by calling Catch's REQUIRE()
24 // macro) to indicate postcondition violations.
25 #ifdef WIN32
26 #define NOEXCEPT_FALSE
27 #else
28 #define NOEXCEPT_FALSE noexcept(false)
29 #endif
30 
31 
32 TEST_CASE("DS-dev metadata enumerates correctly", "[live] [DS-device]")
33 {
34  // Require at least one device to be plugged in
36  const int device_count = rs_get_device_count(ctx, require_no_error());
37  REQUIRE(device_count > 0);
38 
39  // For each device
40  for (int i = 0; i<device_count; ++i)
41  {
43  REQUIRE(dev != nullptr);
44 
45  SECTION("device name identification ")
46  {
47  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
48  {
49  bool b = (s == rs_get_device_name(dev, require_no_error()));
50  if (b) std::cout << "Camera type " << s << std::endl;
51  return b; }));
52  }
53 
54  SECTION("device serial number has ten decimal digits")
55  {
56  const char * serial = rs_get_device_serial(dev, require_no_error());
57  REQUIRE(strlen(serial) == 10);
58  for (int i = 0; i<10; ++i) REQUIRE(isdigit(serial[i]));
59  }
60  }
61 }
62 
63 TEST_CASE("DS-device devices support all required options", "[live] [DS-device]")
64 {
65  // Require at least one device to be plugged in
67  const int device_count = rs_get_device_count(ctx, require_no_error());
68  REQUIRE(device_count > 0);
69 
70  // For each device
71  for (int i = 0; i<device_count; ++i)
72  {
74  REQUIRE(dev != nullptr);
75 
76  SECTION("device supports standard picture options and DS-device extension options")
77  {
79 
80  const int supported_options[] = {
116  };
117 
118  std::stringstream ss;
119  for (int i = 0; i<RS_OPTION_COUNT; ++i)
120  {
121  ss.str(""); ss << "Verifying support for " << rs_option_to_string((rs_option)i);
122  INFO(ss.str().c_str());
123  if (std::find(std::begin(supported_options), std::end(supported_options), i) != std::end(supported_options))
124  {
126  }
127  // There is no ELSE by design , as the test is intended to check only the common options support
128  }
129  }
130  }
131 }
132 
133 TEST_CASE("DS-device head content verification", "[live] [DS-device]")
134 {
135  // Require at least one device to be plugged in
137  const int device_count = rs_get_device_count(ctx, require_no_error());
138  REQUIRE(device_count > 0);
139 
140  std::vector<std::string> invalid_keywords = { "", "N/A" };
141  // For each device
142  for (int i = 0; i<device_count; ++i)
143  {
145  REQUIRE(dev != nullptr);
146 
147  SECTION("device supports standard picture options and DS-device extension options")
148  {
150  {
153  {
155  REQUIRE(std::none_of(invalid_keywords.begin(), invalid_keywords.end(), [&](std::string const& s) {return s == val; }));
156  }
157  else
158  {
159  rs_error * e = nullptr;
160  REQUIRE(nullptr == rs_get_device_info(dev, rs_camera_info(param), &e));
161  REQUIRE(e != nullptr);
162  }
163  }
164  }
165  }
166 }
167 
169 // Calibration information tests //
171 
172 TEST_CASE("DS-device device extrinsics are within expected parameters", "[live] [DS-device]")
173 {
174  // Require at least one device to be plugged in
176  const int device_count = rs_get_device_count(ctx, require_no_error());
177  REQUIRE(device_count > 0);
178 
179  // For each device
180  for (int i = 0; i<device_count; ++i)
181  {
183  REQUIRE(dev != nullptr);
184 
185  SECTION("no extrinsic transformation between DEPTH and INFRARED")
186  {
187  rs_extrinsics extrin;
189 
192  }
193 
194  SECTION("only x-axis translation (~70 mm) between DEPTH and INFRARED2")
195  {
196  rs_extrinsics extrin;
198 
200  REQUIRE(extrin.translation[0] < -0.06f); // Some variation is allowed, but should report at least 60 mm in all cases
201  REQUIRE(extrin.translation[0] > -0.08f); // Some variation is allowed, but should report at most 80 mm in all cases
202  REQUIRE(extrin.translation[1] == 0.0f);
203  REQUIRE(extrin.translation[2] == 0.0f);
204  }
205 
206  SECTION("only translation between DEPTH and RECTIFIED_COLOR")
207  {
208  rs_extrinsics extrin;
210 
212  }
213 
214  SECTION("depth scale is 0.001 (by default)")
215  {
217  }
218  }
219 }
220 
221 TEST_CASE("DS-device infrared2 streaming modes exactly match infrared streaming modes", "[live] [DS-device]")
222 {
223  // Require at least one device to be plugged in
225  const int device_count = rs_get_device_count(ctx, require_no_error());
226  REQUIRE(device_count > 0);
227 
228  // For each device
229  for (int i = 0; i<device_count; ++i)
230  {
232  REQUIRE(dev != nullptr);
233 
234  // Require that there are a nonzero amount of infrared modes, and that infrared2 has the same number of modes
235  const int infrared_mode_count = rs_get_stream_mode_count(dev, RS_STREAM_INFRARED, require_no_error());
236  REQUIRE(infrared_mode_count > 0);
237  REQUIRE(rs_get_stream_mode_count(dev, RS_STREAM_INFRARED2, require_no_error()) == infrared_mode_count);
238 
239  // For each streaming mode
240  for (int j = 0; j<infrared_mode_count; ++j)
241  {
242  // Require that INFRARED and INFRARED2 streaming modes are exactly identical
243  int infrared_width = 0, infrared_height = 0, infrared_framerate = 0; rs_format infrared_format = RS_FORMAT_ANY;
244  rs_get_stream_mode(dev, RS_STREAM_INFRARED, j, &infrared_width, &infrared_height, &infrared_format, &infrared_framerate, require_no_error());
245 
246  int infrared2_width = 0, infrared2_height = 0, infrared2_framerate = 0; rs_format infrared2_format = RS_FORMAT_ANY;
247  rs_get_stream_mode(dev, RS_STREAM_INFRARED2, j, &infrared2_width, &infrared2_height, &infrared2_format, &infrared2_framerate, require_no_error());
248 
249  REQUIRE(infrared_width == infrared2_width);
250  REQUIRE(infrared_height == infrared2_height);
251  REQUIRE(infrared_format == infrared2_format);
252  REQUIRE(infrared_framerate == infrared2_framerate);
253 
254  // Require that the intrinsic for these streaming modes match exactly
255  rs_enable_stream(dev, RS_STREAM_INFRARED, infrared_width, infrared_height, infrared_format, infrared_framerate, require_no_error());
256  rs_enable_stream(dev, RS_STREAM_INFRARED2, infrared2_width, infrared2_height, infrared2_format, infrared2_framerate, require_no_error());
257 
260 
261  rs_intrinsics infrared_intrin = {}, infrared2_intrin = {};
264  REQUIRE(infrared_intrin.width == infrared_intrin.width);
265  REQUIRE(infrared_intrin.height == infrared_intrin.height);
266  REQUIRE(infrared_intrin.ppx == infrared_intrin.ppx);
267  REQUIRE(infrared_intrin.ppy == infrared_intrin.ppy);
268  REQUIRE(infrared_intrin.fx == infrared_intrin.fx);
269  REQUIRE(infrared_intrin.fy == infrared_intrin.fy);
270  REQUIRE(infrared_intrin.model == infrared_intrin.model);
271  for (int k = 0; k<5; ++k) REQUIRE(infrared_intrin.coeffs[k] == infrared_intrin.coeffs[k]);
272  }
273  }
274 }
275 
277 // Streaming tests //
279 
280 
282 // Depth streaming tests //
284 
285 TEST_CASE("DS-device streams 480x360 depth", "[live] [DS-device] [one-camera]")
286 {
288 }
289 
290 TEST_CASE("DS-device streams 628x468 depth", "[live] [DS-device] [one-camera]")
291 {
293 }
294 
295 TEST_CASE("DS-device streams 320x240 depth", "[live] [DS-device] [one-camera]")
296 {
298 }
299 
300 TEST_CASE("DS-device streams 480x360 depth (30 fps)", "[live] [DS-device] [one-camera]")
301 {
303 }
304 
305 TEST_CASE("DS-device streams 628x468 depth (30 fps)", "[live] [DS-device] [one-camera]")
306 {
308 }
309 
310 TEST_CASE("DS-device streams 320x240 depth (30 fps)", "[live] [DS-device] [one-camera]")
311 {
313 }
314 
315 TEST_CASE("DS-device streams 480x360 depth (90 fps)", "[live] [DS-device] [one-camera]")
316 {
318 }
319 
320 TEST_CASE("DS-device streams 628x468 depth (90 fps)", "[live] [DS-device] [one-camera]")
321 {
323 }
324 
325 TEST_CASE("DS-device streams 320x240 depth (90 fps)", "[live] [DS-device] [one-camera]")
326 {
328 }
329 
331 // Color streaming tests //
333 
334 TEST_CASE("DS-device streams HD color", "[live] [DS-device] [one-camera]")
335 {
336  test_ds_device_streaming({ { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
337 }
338 
339 TEST_CASE("DS-device streams VGA color", "[live] [DS-device] [one-camera]")
340 {
342 }
343 
344 TEST_CASE("DS-device streams VGA color (60 fps)", "[live] [DS-device] [one-camera]")
345 {
347 }
348 
349 TEST_CASE("DS-device streams 480x360 depth and HD color", "[live] [DS-device] [one-camera]")
350 {
352  { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
353 }
354 
355 TEST_CASE("DS-device streams 628x468 depth and HD color", "[live] [DS-device] [one-camera]")
356 {
358  { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
359 }
360 
361 TEST_CASE("DS-device streams 320x240 depth and HD color", "[live] [DS-device] [one-camera]")
362 {
364  { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
365 }
366 
367 TEST_CASE("DS-device streams 480x360 depth and VGA color", "[live] [DS-device] [one-camera]")
368 {
370  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
371 }
372 
373 TEST_CASE("DS-device streams 628x468 depth and VGA color", "[live] [DS-device] [one-camera]")
374 {
376  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
377 }
378 
379 TEST_CASE("DS-device streams 320x240 depth and VGA color", "[live] [DS-device] [one-camera]")
380 {
382  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
383 }
384 
385 TEST_CASE("DS-device streams 480x360 depth and VGA color (60 fps)", "[live] [DS-device] [one-camera]")
386 {
388  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 60 } });
389 }
390 
391 
393 // Infrared streaming tests //
395 
396 TEST_CASE("DS-device streams 640x480 infrared (left 8 bit)", "[live] [DS-device] [one-camera]")
397 {
399 }
400 
401 TEST_CASE("DS-device streams 640x480 infrared (left 16 bit)", "[live] [DS-device] [one-camera]")
402 {
404 }
405 
406 TEST_CASE("DS-device streams 640x480 infrared (right 8 bit)", "[live] [DS-device] [one-camera]")
407 {
409 }
410 
411 TEST_CASE("DS-device streams 640x480 infrared (right 16 bit)", "[live] [DS-device] [one-camera]")
412 {
414 }
415 
416 TEST_CASE("DS-device streams 640x480 infrared (left+right 8 bit)", "[live] [DS-device] [one-camera]")
417 {
419  { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60 } });
420 }
421 
422 TEST_CASE("DS-device streams 640x480 infrared (left+right 16 bit)", "[live] [DS-device] [one-camera]")
423 {
425  { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y16, 60 } });
426 }
427 
428 TEST_CASE("DS-device streams 480x360 depth and 492x372 infrared (left+right 16 bit)", "[live] [DS-device] [one-camera]")
429 {
431  { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
432  { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 } });
433 }
434 
435 TEST_CASE("DS-device streams 480x360 depth, VGA color, and 492x372 infrared", "[live] [DS-device] [one-camera]")
436 {
438  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
439  { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
440  { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 } });
441 }
442 
443 TEST_CASE("DS-device streams 628x468 depth, VGA color, and 640x480 infrared", "[live] [DS-device] [one-camera]")
444 {
446  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
447  { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y16, 60 },
448  { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y16, 60 } });
449 }
450 
451 TEST_CASE("DS-device streams 320x240 depth, VGA color, and 332x252 infrared", "[live] [DS-device] [one-camera]")
452 {
454  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
455  { RS_STREAM_INFRARED, 332, 252, RS_FORMAT_Y16, 60 },
456  { RS_STREAM_INFRARED2, 332, 252, RS_FORMAT_Y16, 60 } });
457 }
458 
460 // Cropped and padded modes //
462 
463 TEST_CASE("DS-device streams 640x480 depth and infrared", "[live] [DS-device] [one-camera]")
464 {
466  { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60 },
467  { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60 } });
468 }
469 
470 TEST_CASE("DS-device streams 628x468 depth and infrared", "[live] [DS-device] [one-camera]")
471 {
473  { RS_STREAM_INFRARED, 628, 468, RS_FORMAT_Y8, 60 },
474  { RS_STREAM_INFRARED2, 628, 468, RS_FORMAT_Y8, 60 } });
475 }
476 
477 TEST_CASE("DS-device streams 492x372 depth and infrared", "[live] [DS-device] [one-camera]")
478 {
480  { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y8, 60 },
481  { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y8, 60 } });
482 }
483 
484 TEST_CASE("DS-device streams 480x360 depth and infrared", "[live] [DS-device] [one-camera]")
485 {
487  { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
488  { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 } });
489 }
490 
491 TEST_CASE("DS-device streams 332x252 depth and infrared", "[live] [DS-device] [one-camera]")
492 {
494  { RS_STREAM_INFRARED, 332, 252, RS_FORMAT_Y8, 60 },
495  { RS_STREAM_INFRARED2, 332, 252, RS_FORMAT_Y8, 60 } });
496 }
497 
498 TEST_CASE("DS-device streams 320x240 depth and infrared", "[live] [DS-device] [one-camera]")
499 {
501  { RS_STREAM_INFRARED, 320, 240, RS_FORMAT_Y8, 60 },
502  { RS_STREAM_INFRARED2, 320, 240, RS_FORMAT_Y8, 60 } });
503 }
504 
506 // Options //
508 
509 
510 TEST_CASE("DS-device supports RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED", "[live] [DS-device]")
511 {
513 }
514 
515 TEST_CASE("DS-device RGB White Balance", "[live] [DS-device] [one-camera]")
516 {
517  // Invalid values do not produce exception
518  test_ds_device_option(RS_OPTION_COLOR_WHITE_BALANCE, { 2800, 3500, 4600, 5500, 6400 }, { /*100, 6510 */ }, BEFORE_START_DEVICE | AFTER_START_DEVICE);
519 }
520 
521 TEST_CASE("DS-device supports RS_OPTION_R200_LR_GAIN", "[live] [DS-device]")
522 {
523  test_ds_device_option(RS_OPTION_R200_LR_GAIN, { 100, 200, 400, 800, 1600 }, {}, BEFORE_START_DEVICE | AFTER_START_DEVICE); // Gain percentage
524 }
525 
526 TEST_CASE("DS-device supports RS_OPTION_R200_LR_EXPOSURE", "[live] [DS-device]")
527 {
528  test_ds_device_option(RS_OPTION_R200_LR_EXPOSURE, { 40, 80, 160 }, {}, BEFORE_START_DEVICE | AFTER_START_DEVICE); // Tenths of milliseconds
529 }
530 
531 // Note: The DS-device firmware has some complications regarding emitter state before the device has been started
532 // The emitter will never be on if the device is not streaming, but the firmware will remember and respect any
533 // specified preferences for emitter enabled that are specified prior to streaming.
534 
535 TEST_CASE("DS-device emitter defaults to off if depth is not enabled/streamed", "[live] [DS-device]")
536 {
539 
541  REQUIRE(dev != nullptr);
542 
543  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
544 
545  // Emitter enabled defaults to false
547 
548  // Enabling non-depth streams does not change the emitter's state
553 
554  // Starting the device does not change the emitter's state
556  std::this_thread::sleep_for(std::chrono::seconds(1));
558 }
559 
560 TEST_CASE("DS-device emitter defaults to on if depth is enabled/streamed", "[live] [DS-device]")
561 {
564 
566  REQUIRE(dev != nullptr);
567  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
568 
569  // Emitter enabled defaults to false
571 
572  // Enabling depth stream causes the emitter to be enabled
575 
576  // Starting the device does not change the emitter's state
578  std::this_thread::sleep_for(std::chrono::seconds(1));
580 }
581 
582 TEST_CASE("DS-device emitter can be enabled even if depth is not enabled/streamed", "[live] [DS-device]")
583 {
586 
588  REQUIRE(dev != nullptr);
589  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
590 
591  // Emitter enabled defaults to false
593 
594  // Enabling non-depth streams does not change the emitter's state
599 
600  // The emitter can be turned on even though no depth is streamed
603 
604  // Starting the device does not change the emitter's state
606  std::this_thread::sleep_for(std::chrono::seconds(1));
608 }
609 
610 TEST_CASE("DS-device emitter can be turned off even if depth is enabled/streamed", "[live] [DS-device]")
611 {
614 
616  REQUIRE(dev != nullptr);
617  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
618 
619  // Emitter enabled defaults to false
621 
622  // Enabling depth stream causes the emitter to be enabled
625 
626  // The emitter can be turned off even though depth is streamed
629 
630  // Starting the device does not change the emitter's state
632  std::this_thread::sleep_for(std::chrono::seconds(1));
634 }
635 
636 TEST_CASE("DS-device emitter can be turned on and off after streaming has begun", "[live] [DS-device]")
637 {
640 
642  REQUIRE(dev != nullptr);
643  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
644 
645  // The emitter defaults to on when depth is streamed
648  std::this_thread::sleep_for(std::chrono::seconds(1));
650 
651  // The emitter can be turned off
654 
655  // The emitter can be turned back on
658 }
659 
660 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_UNITS", "[live] [DS-device]")
661 {
664 
666  REQUIRE(dev != nullptr);
667  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
668 
669  // By default, depth unit is 1000 micrometers (1 mm)
672 
673  for (int value : {100, 500, 1000, 2000, 10000})
674  {
675  // Set depth units (specified in micrometers) and verify that depth scale (specified in meters) changes appropriately
678  REQUIRE(rs_get_device_depth_scale(dev, require_no_error()) == (float)value / 1000000);
679  }
680 }
681 
682 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_CLAMP_MIN", "[live] [DS-device]")
683 {
685 }
686 
687 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_CLAMP_MAX", "[live] [DS-device]")
688 {
689  test_ds_device_option(RS_OPTION_R200_DEPTH_CLAMP_MAX, { 500, 1000, 2000, USHRT_MAX }, {}, BEFORE_START_DEVICE);
690 }
691 
692 TEST_CASE("DS-device verify standard UVC Controls set/get", "[live] [DS-device]")
693 {
694  // Require only one device to be plugged in
696  const int device_count = rs_get_device_count(ctx, require_no_error());
697  REQUIRE(device_count == 1);
698 
699  // For each device
701  REQUIRE(dev != nullptr);
702 
703  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
704 
705  // Enabling non-depth streams does not change the emitter's state
708 
711  // Starting the device does not change the emitter's state
713 
714  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
716 
719 
720  std::vector<rs_option> test_options;
721  std::vector<double> initial_values;
722  std::vector<double> modified_values;
723  std::vector<double> verification_values;
724  for (int i=first; i<= last; i++)
725  test_options.push_back((rs_option)i);
726 
727  initial_values.resize(test_options.size());
728  modified_values.resize(test_options.size());
729  verification_values.resize(test_options.size());
730 
731  rs_get_device_options(dev,test_options.data(),(unsigned int)test_options.size(),initial_values.data(), require_no_error());
732 
733  //for (size_t i=first; i<= last; i++)
734  // std::cout << "Option " << rs_option_to_string((rs_option)i) << " : initial value " << initial_values[i] <<std::endl;
735 
736  double min=0, max=0, step=0;
737  for (int i=first; i<= last; i++)
738  {
739  rs_get_device_option_range(dev,(rs_option)i,&min,&max,&step,require_no_error());
740  if (initial_values[i] == max)
741  modified_values[i] = initial_values[i]- step;
742  else
743  modified_values[i] = initial_values[i]+ step;
744  }
745 
746  // Apply all properties with the modified values
747  rs_set_device_options(dev,test_options.data(),(unsigned int)test_options.size(),modified_values.data(), require_no_error());
748  std::this_thread::sleep_for(std::chrono::milliseconds(500));
749  // Verify
750  rs_get_device_options(dev,test_options.data(),(unsigned int)test_options.size(),verification_values.data(), require_no_error());
751 
752  //for (size_t i=first; i<= last; i++)
753  // std::cout << "Option " << rs_option_to_string((rs_option)i) << " Requested value = " << modified_values[i] << " Actual value = " << verification_values[i] << std::endl;
754 
755  for (int i=first; i<= last; i++)
756  {
757 #if defined(_WINDOWS) || defined(WIN32) || defined(WIN64)
759  continue;
760 #endif
761 
762  REQUIRE(modified_values[i]!=initial_values[i]);
763  REQUIRE(modified_values[i]==verification_values[i]);
764  }
765 
767 }
768 
770 // Stop, reconfigure, and restart tests //
772 
773 TEST_CASE("a single DS-device can stream a variety of reasonable streaming mode combinations", "[live] [DS-device] [one-camera]")
774 {
776 
777  SECTION("exactly one device is connected")
778  {
779  int device_count = rs_get_device_count(ctx, require_no_error());
780  REQUIRE(device_count == 1);
781  }
782 
784  REQUIRE(dev != nullptr);
785 
786  SECTION("device name identification ")
787  {
788  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
789  {
790  bool b = (s == rs_get_device_name(dev, require_no_error()));
791  if (b) std::cout << "Camera type " << s << std::endl;
792  return b; }));
793  }
794 
795  SECTION("streaming is possible in some reasonable configurations")
796  {
797  SECTION("streaming DEPTH 480, 360, RS_FORMAT_Z16, 60")
798  {
799  test_streaming(dev, {
800  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 }
801  });
802  }
803 
804  SECTION("streaming [DEPTH,480,360,Z16,60] [COLOR,480,360,RGB8,60]")
805  {
806  test_streaming(dev, {
807  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
808  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 }
809  });
810  }
811 
812  SECTION("streaming [DEPTH,480,360,Z16,60] [IR,480,360,Y8,60]")
813  {
814  test_streaming(dev, {
815  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
816  { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 }
817  });
818  }
819 
820  SECTION("streaming [IR,492,372,Y16,60] [IR2,492,372,Y16,60]")
821  {
822  test_streaming(dev, {
823  { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
824  { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 }
825  });
826  }
827 
828  SECTION("streaming [DEPTH,480,360,Z16,60] [COLOR,640,480,RGB8,60] [IR,480,360,Y8,60] [IR2,480,360,Y8,60]")
829  {
830  test_streaming(dev, {
831  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
832  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 },
833  { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
834  { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 }
835  });
836  }
837  }
838 }
839 
840 TEST_CASE("streaming five configurations sequentionally", "[live] [DS-device] [one-camera]")
841 {
843 
844  SECTION("exactly one device is connected")
845  {
846  int device_count = rs_get_device_count(ctx, require_no_error());
847  REQUIRE(device_count == 1);
848  }
849 
851  REQUIRE(dev != nullptr);
852 
853  REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
854  {
855  bool b = (s == rs_get_device_name(dev, require_no_error()));
856  if (b) std::cout << "Camera type " << s << std::endl;
857  return b; }));
858 
859  test_streaming(dev, {
860  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 }
861  });
862 
863  test_streaming(dev, {
864  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 60 }
865  });
866 
867  test_streaming(dev, {
868  { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
869  { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 }
870  });
871 
872  test_streaming(dev, {
873  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
874  { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 }
875  });
876 
877  test_streaming(dev, {
878  { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
879  { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 },
880  { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
881  { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 }
882  });
883 }
884 
885 #endif /* !defined(MAKEFILE) || ( defined(LR200_TEST) || defined(R200_TEST) || defined(ZR300_TEST) ) */
void rs_get_stream_intrinsics(const rs_device *device, rs_stream stream, rs_intrinsics *intrin, rs_error **error)
Retrieves intrinsic camera parameters for a specific stream.
Definition: rs.cpp:289
float coeffs[5]
Definition: rs.h:309
const GLint * first
Definition: glext.h:368
Definition: rs.cpp:16
rs_error * e
const char * rs_camera_info_to_string(rs_camera_info info)
Definition: rs.cpp:764
int rs_get_device_count(const rs_context *context, rs_error **error)
Determines number of connected devices.
Definition: rs.cpp:113
void rs_get_device_options(rs_device *device, const rs_option *options, unsigned int count, double *values, rs_error **error)
Efficiently retrieves the value of an arbitrary number of options, using minimal hardware IO...
void rs_set_device_options(rs_device *device, const rs_option *options, unsigned int count, const double *values, rs_error **error)
Efficiently sets the value of an arbitrary number of options, using minimal hardware IO...
float ppy
Definition: rs.h:305
GLsizei const GLchar *const * string
Definition: glext.h:683
#define REQUIRE(expr)
Definition: catch.hpp:9333
void rs_set_device_option(rs_device *device, rs_option option, double value, rs_error **error)
Sets the current value of a single option.
Definition: rs.cpp:712
const char * rs_get_device_name(const rs_device *device, rs_error **error)
Retrieves human-readable device model string.
Definition: rs.cpp:128
rs_option
Defines general configuration controls.
Definition: rs.h:128
float rs_get_device_depth_scale(const rs_device *device, rs_error **error)
Retrieves mapping between the units of the depth image and meters.
Definition: rs.cpp:420
void test_ds_device_streaming(std::initializer_list< stream_mode > modes)
void require_zero_vector(const float(&vector)[3])
void rs_get_stream_mode(const rs_device *device, rs_stream stream, int index, int *width, int *height, rs_format *format, int *framerate, rs_error **error)
Determines the properties of a specific streaming mode.
Definition: rs.cpp:198
int rs_get_stream_mode_count(const rs_device *device, rs_stream stream, rs_error **error)
Determines the number of streaming modes available for a given stream.
Definition: rs.cpp:190
float translation[3]
Definition: rs.h:335
rs_format rs_get_stream_format(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the pixel format for a specific stream.
Definition: rs.cpp:273
double rs_get_device_option(rs_device *device, rs_option option, rs_error **error)
Retrieves the current value of a single option.
Definition: rs.cpp:694
void rs_get_device_extrinsics(const rs_device *device, rs_stream from_stream, rs_stream to_stream, rs_extrinsics *extrin, rs_error **error)
Retrieves extrinsic transformation between the viewpoints of two different streams.
Definition: rs.cpp:163
GLuint GLuint end
Definition: glext.h:111
GLfloat param
Definition: glext.h:370
rs_camera_info
Read-only strings that can be queried from the device.
Definition: rs.h:237
GLfloat f
Definition: glext.h:1868
int rs_device_supports_option(const rs_device *device, rs_option option, rs_error **error)
Determines if the device allows a specific option to be queried and set.
Definition: rs.cpp:182
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
void test_streaming(rs_device *device, std::initializer_list< stream_mode > modes)
void rs_enable_stream(rs_device *device, rs_stream stream, int width, int height, rs_format format, int framerate, rs_error **error)
Enables a specific stream and requests specific properties.
Definition: rs.cpp:220
rs_format
Formats: defines how each stream can be encoded.
Definition: rs.h:53
const char * rs_get_device_info(const rs_device *device, rs_camera_info info, rs_error **error)
Retrieves camera specific information, such as versions of various internal componnents.
Definition: rs.cpp:142
auto ctx
int rs_supports_camera_info(rs_device *device, rs_camera_info info_param, rs_error **error)
Returns true if given camera information parameter is supported by the device.
Definition: rs.cpp:450
GLsizei const GLfloat * value
Definition: glext.h:693
int height
Definition: rs.h:303
float fy
Definition: rs.h:307
int width
Definition: rs.h:302
Video stream intrinsics.
Definition: rs.h:300
void require_identity_matrix(const float(&matrix)[9])
GLfloat seconds
Definition: wglext.h:657
GLboolean GLboolean GLboolean b
Definition: glext.h:1104
Cross-stream extrinsics: encode the topology describing how the different devices are connected...
Definition: rs.h:332
void rs_get_device_option_range(rs_device *device, rs_option option, double *min, double *max, double *step, rs_error **error)
Retrieves the available range of values for a supported option.
Definition: rs.cpp:635
void test_options(rs_device *device, rs_option *option_list, size_t options, std::vector< double > good_values, std::vector< double > bad_values, std::vector< double > &ret_values, const std::string &expected_success_msg, const std::string &expected_error_msg, bool bWrite)
int rs_get_stream_framerate(const rs_device *device, rs_stream stream, rs_error **error)
Retrieves the frame rate for a specific stream.
Definition: rs.cpp:281
float rotation[9]
Definition: rs.h:334
GLdouble s
Definition: glext.h:231
const char * rs_option_to_string(rs_option option)
Definition: rs.cpp:758
rs_device * dev
TEST_CASE("DS-dev metadata enumerates correctly","[live] [DS-device]")
float fx
Definition: rs.h:306
rs_device * rs_get_device(rs_context *context, int index, rs_error **error)
Retrieves connected device by index.
Definition: rs.cpp:120
const char * rs_get_device_serial(const rs_device *device, rs_error **error)
Retrieves unique serial number of the device.
Definition: rs.cpp:135
void rs_enable_stream_preset(rs_device *device, rs_stream stream, rs_preset preset, rs_error **error)
Enables a specific stream and requests properties using a preset.
Definition: rs.cpp:232
#define SECTION(name, description)
Definition: catch.hpp:9370
rs_distortion model
Definition: rs.h:308
void rs_start_device(rs_device *device, rs_error **error)
Begins streaming on all enabled streams for this device.
Definition: rs.cpp:383
void rs_stop_device(rs_device *device, rs_error **error)
Ends data acquisition for the specified source providers.
Definition: rs.cpp:398
#define INFO(msg)
Definition: catch.hpp:9353
float ppx
Definition: rs.h:304
void test_ds_device_option(rs_option option, std::initializer_list< int > values, std::initializer_list< int > bad_values, int when)
GLuint GLfloat * val
Definition: glext.h:1490
static const std::vector< std::string > ds_names


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