00001
00002
00003
00005
00007
00008 #if !defined(MAKEFILE) || ( defined(LR200_TEST) || defined(R200_TEST) || defined(ZR300_TEST) )
00009
00010 #define CATCH_CONFIG_MAIN
00011
00012 #include <climits>
00013 #include <sstream>
00014
00015 #include "unit-tests-live-ds-common.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef WIN32
00026 #define NOEXCEPT_FALSE
00027 #else
00028 #define NOEXCEPT_FALSE noexcept(false)
00029 #endif
00030
00031
00032 TEST_CASE("DS-dev metadata enumerates correctly", "[live] [DS-device]")
00033 {
00034
00035 safe_context ctx;
00036 const int device_count = rs_get_device_count(ctx, require_no_error());
00037 REQUIRE(device_count > 0);
00038
00039
00040 for (int i = 0; i<device_count; ++i)
00041 {
00042 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00043 REQUIRE(dev != nullptr);
00044
00045 SECTION("device name identification ")
00046 {
00047 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
00048 {
00049 bool b = (s == rs_get_device_name(dev, require_no_error()));
00050 if (b) std::cout << "Camera type " << s << std::endl;
00051 return b; }));
00052 }
00053
00054 SECTION("device serial number has ten decimal digits")
00055 {
00056 const char * serial = rs_get_device_serial(dev, require_no_error());
00057 REQUIRE(strlen(serial) == 10);
00058 for (int i = 0; i<10; ++i) REQUIRE(isdigit(serial[i]));
00059 }
00060 }
00061 }
00062
00063 TEST_CASE("DS-device devices support all required options", "[live] [DS-device]")
00064 {
00065
00066 safe_context ctx;
00067 const int device_count = rs_get_device_count(ctx, require_no_error());
00068 REQUIRE(device_count > 0);
00069
00070
00071 for (int i = 0; i<device_count; ++i)
00072 {
00073 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00074 REQUIRE(dev != nullptr);
00075
00076 SECTION("device supports standard picture options and DS-device extension options")
00077 {
00078 rs_set_device_option(dev, RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED, 1.0, require_no_error());
00079
00080 const int supported_options[] = {
00081 RS_OPTION_COLOR_BACKLIGHT_COMPENSATION,
00082 RS_OPTION_COLOR_BRIGHTNESS,
00083 RS_OPTION_COLOR_CONTRAST,
00084 RS_OPTION_COLOR_EXPOSURE,
00085 RS_OPTION_COLOR_GAIN,
00086 RS_OPTION_COLOR_GAMMA,
00087 RS_OPTION_COLOR_HUE,
00088 RS_OPTION_COLOR_SATURATION,
00089 RS_OPTION_COLOR_SHARPNESS,
00090 RS_OPTION_COLOR_WHITE_BALANCE,
00091 RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE,
00092 RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE,
00093 RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED,
00094 RS_OPTION_R200_LR_GAIN,
00095 RS_OPTION_R200_LR_EXPOSURE,
00096 RS_OPTION_R200_EMITTER_ENABLED,
00097 RS_OPTION_R200_DEPTH_UNITS,
00098 RS_OPTION_R200_DEPTH_CLAMP_MIN,
00099 RS_OPTION_R200_DEPTH_CLAMP_MAX,
00100 RS_OPTION_R200_AUTO_EXPOSURE_MEAN_INTENSITY_SET_POINT,
00101 RS_OPTION_R200_AUTO_EXPOSURE_TOP_EDGE,
00102 RS_OPTION_R200_AUTO_EXPOSURE_BOTTOM_EDGE,
00103 RS_OPTION_R200_AUTO_EXPOSURE_LEFT_EDGE,
00104 RS_OPTION_R200_AUTO_EXPOSURE_RIGHT_EDGE,
00105 RS_OPTION_R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_DECREMENT,
00106 RS_OPTION_R200_DEPTH_CONTROL_ESTIMATE_MEDIAN_INCREMENT,
00107 RS_OPTION_R200_DEPTH_CONTROL_MEDIAN_THRESHOLD,
00108 RS_OPTION_R200_DEPTH_CONTROL_SCORE_MINIMUM_THRESHOLD,
00109 RS_OPTION_R200_DEPTH_CONTROL_SCORE_MAXIMUM_THRESHOLD,
00110 RS_OPTION_R200_DEPTH_CONTROL_TEXTURE_COUNT_THRESHOLD,
00111 RS_OPTION_R200_DEPTH_CONTROL_TEXTURE_DIFFERENCE_THRESHOLD,
00112 RS_OPTION_R200_DEPTH_CONTROL_SECOND_PEAK_THRESHOLD,
00113 RS_OPTION_R200_DEPTH_CONTROL_NEIGHBOR_THRESHOLD,
00114 RS_OPTION_R200_DEPTH_CONTROL_LR_THRESHOLD,
00115 RS_OPTION_FRAMES_QUEUE_SIZE
00116 };
00117
00118 std::stringstream ss;
00119 for (int i = 0; i<RS_OPTION_COUNT; ++i)
00120 {
00121 ss.str(""); ss << "Verifying support for " << rs_option_to_string((rs_option)i);
00122 INFO(ss.str().c_str());
00123 if (std::find(std::begin(supported_options), std::end(supported_options), i) != std::end(supported_options))
00124 {
00125 REQUIRE(rs_device_supports_option(dev, (rs_option)i, require_no_error()) == 1);
00126 }
00127
00128 }
00129 }
00130 }
00131 }
00132
00133 TEST_CASE("DS-device head content verification", "[live] [DS-device]")
00134 {
00135
00136 safe_context ctx;
00137 const int device_count = rs_get_device_count(ctx, require_no_error());
00138 REQUIRE(device_count > 0);
00139
00140 std::vector<std::string> invalid_keywords = { "", "N/A" };
00141
00142 for (int i = 0; i<device_count; ++i)
00143 {
00144 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00145 REQUIRE(dev != nullptr);
00146
00147 SECTION("device supports standard picture options and DS-device extension options")
00148 {
00149 for (auto param = (int)rs_camera_info::RS_CAMERA_INFO_DEVICE_NAME; param < rs_camera_info::RS_CAMERA_INFO_COUNT; param++)
00150 {
00151 INFO("Testing " << rs_camera_info_to_string(rs_camera_info(param)));
00152 if (rs_supports_camera_info(dev,rs_camera_info(param), require_no_error()))
00153 {
00154 auto val = rs_get_device_info(dev, rs_camera_info(param), require_no_error());
00155 REQUIRE(std::none_of(invalid_keywords.begin(), invalid_keywords.end(), [&](std::string const& s) {return s == val; }));
00156 }
00157 else
00158 {
00159 rs_error * e = nullptr;
00160 REQUIRE(nullptr == rs_get_device_info(dev, rs_camera_info(param), &e));
00161 REQUIRE(e != nullptr);
00162 }
00163 }
00164 }
00165 }
00166 }
00167
00169
00171
00172 TEST_CASE("DS-device device extrinsics are within expected parameters", "[live] [DS-device]")
00173 {
00174
00175 safe_context ctx;
00176 const int device_count = rs_get_device_count(ctx, require_no_error());
00177 REQUIRE(device_count > 0);
00178
00179
00180 for (int i = 0; i<device_count; ++i)
00181 {
00182 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00183 REQUIRE(dev != nullptr);
00184
00185 SECTION("no extrinsic transformation between DEPTH and INFRARED")
00186 {
00187 rs_extrinsics extrin;
00188 rs_get_device_extrinsics(dev, RS_STREAM_DEPTH, RS_STREAM_INFRARED, &extrin, require_no_error());
00189
00190 require_identity_matrix(extrin.rotation);
00191 require_zero_vector(extrin.translation);
00192 }
00193
00194 SECTION("only x-axis translation (~70 mm) between DEPTH and INFRARED2")
00195 {
00196 rs_extrinsics extrin;
00197 rs_get_device_extrinsics(dev, RS_STREAM_DEPTH, RS_STREAM_INFRARED2, &extrin, require_no_error());
00198
00199 require_identity_matrix(extrin.rotation);
00200 REQUIRE(extrin.translation[0] < -0.06f);
00201 REQUIRE(extrin.translation[0] > -0.08f);
00202 REQUIRE(extrin.translation[1] == 0.0f);
00203 REQUIRE(extrin.translation[2] == 0.0f);
00204 }
00205
00206 SECTION("only translation between DEPTH and RECTIFIED_COLOR")
00207 {
00208 rs_extrinsics extrin;
00209 rs_get_device_extrinsics(dev, RS_STREAM_DEPTH, RS_STREAM_RECTIFIED_COLOR, &extrin, require_no_error());
00210
00211 require_identity_matrix(extrin.rotation);
00212 }
00213
00214 SECTION("depth scale is 0.001 (by default)")
00215 {
00216 REQUIRE(rs_get_device_depth_scale(dev, require_no_error()) == 0.001f);
00217 }
00218 }
00219 }
00220
00221 TEST_CASE("DS-device infrared2 streaming modes exactly match infrared streaming modes", "[live] [DS-device]")
00222 {
00223
00224 safe_context ctx;
00225 const int device_count = rs_get_device_count(ctx, require_no_error());
00226 REQUIRE(device_count > 0);
00227
00228
00229 for (int i = 0; i<device_count; ++i)
00230 {
00231 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00232 REQUIRE(dev != nullptr);
00233
00234
00235 const int infrared_mode_count = rs_get_stream_mode_count(dev, RS_STREAM_INFRARED, require_no_error());
00236 REQUIRE(infrared_mode_count > 0);
00237 REQUIRE(rs_get_stream_mode_count(dev, RS_STREAM_INFRARED2, require_no_error()) == infrared_mode_count);
00238
00239
00240 for (int j = 0; j<infrared_mode_count; ++j)
00241 {
00242
00243 int infrared_width = 0, infrared_height = 0, infrared_framerate = 0; rs_format infrared_format = RS_FORMAT_ANY;
00244 rs_get_stream_mode(dev, RS_STREAM_INFRARED, j, &infrared_width, &infrared_height, &infrared_format, &infrared_framerate, require_no_error());
00245
00246 int infrared2_width = 0, infrared2_height = 0, infrared2_framerate = 0; rs_format infrared2_format = RS_FORMAT_ANY;
00247 rs_get_stream_mode(dev, RS_STREAM_INFRARED2, j, &infrared2_width, &infrared2_height, &infrared2_format, &infrared2_framerate, require_no_error());
00248
00249 REQUIRE(infrared_width == infrared2_width);
00250 REQUIRE(infrared_height == infrared2_height);
00251 REQUIRE(infrared_format == infrared2_format);
00252 REQUIRE(infrared_framerate == infrared2_framerate);
00253
00254
00255 rs_enable_stream(dev, RS_STREAM_INFRARED, infrared_width, infrared_height, infrared_format, infrared_framerate, require_no_error());
00256 rs_enable_stream(dev, RS_STREAM_INFRARED2, infrared2_width, infrared2_height, infrared2_format, infrared2_framerate, require_no_error());
00257
00258 REQUIRE(rs_get_stream_format(dev, RS_STREAM_INFRARED, require_no_error()) == rs_get_stream_format(dev, RS_STREAM_INFRARED2, require_no_error()));
00259 REQUIRE(rs_get_stream_framerate(dev, RS_STREAM_INFRARED, require_no_error()) == rs_get_stream_framerate(dev, RS_STREAM_INFRARED2, require_no_error()));
00260
00261 rs_intrinsics infrared_intrin = {}, infrared2_intrin = {};
00262 rs_get_stream_intrinsics(dev, RS_STREAM_INFRARED, &infrared_intrin, require_no_error());
00263 rs_get_stream_intrinsics(dev, RS_STREAM_INFRARED2, &infrared2_intrin, require_no_error());
00264 REQUIRE(infrared_intrin.width == infrared_intrin.width);
00265 REQUIRE(infrared_intrin.height == infrared_intrin.height);
00266 REQUIRE(infrared_intrin.ppx == infrared_intrin.ppx);
00267 REQUIRE(infrared_intrin.ppy == infrared_intrin.ppy);
00268 REQUIRE(infrared_intrin.fx == infrared_intrin.fx);
00269 REQUIRE(infrared_intrin.fy == infrared_intrin.fy);
00270 REQUIRE(infrared_intrin.model == infrared_intrin.model);
00271 for (int k = 0; k<5; ++k) REQUIRE(infrared_intrin.coeffs[k] == infrared_intrin.coeffs[k]);
00272 }
00273 }
00274 }
00275
00277
00279
00280
00282
00284
00285 TEST_CASE("DS-device streams 480x360 depth", "[live] [DS-device] [one-camera]")
00286 {
00287 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 } });
00288 }
00289
00290 TEST_CASE("DS-device streams 628x468 depth", "[live] [DS-device] [one-camera]")
00291 {
00292 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 60 } });
00293 }
00294
00295 TEST_CASE("DS-device streams 320x240 depth", "[live] [DS-device] [one-camera]")
00296 {
00297 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 60 } });
00298 }
00299
00300 TEST_CASE("DS-device streams 480x360 depth (30 fps)", "[live] [DS-device] [one-camera]")
00301 {
00302 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 30 } });
00303 }
00304
00305 TEST_CASE("DS-device streams 628x468 depth (30 fps)", "[live] [DS-device] [one-camera]")
00306 {
00307 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 30 } });
00308 }
00309
00310 TEST_CASE("DS-device streams 320x240 depth (30 fps)", "[live] [DS-device] [one-camera]")
00311 {
00312 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 30 } });
00313 }
00314
00315 TEST_CASE("DS-device streams 480x360 depth (90 fps)", "[live] [DS-device] [one-camera]")
00316 {
00317 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 90 } });
00318 }
00319
00320 TEST_CASE("DS-device streams 628x468 depth (90 fps)", "[live] [DS-device] [one-camera]")
00321 {
00322 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 90 } });
00323 }
00324
00325 TEST_CASE("DS-device streams 320x240 depth (90 fps)", "[live] [DS-device] [one-camera]")
00326 {
00327 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 90 } });
00328 }
00329
00331
00333
00334 TEST_CASE("DS-device streams HD color", "[live] [DS-device] [one-camera]")
00335 {
00336 test_ds_device_streaming({ { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
00337 }
00338
00339 TEST_CASE("DS-device streams VGA color", "[live] [DS-device] [one-camera]")
00340 {
00341 test_ds_device_streaming({ { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
00342 }
00343
00344 TEST_CASE("DS-device streams VGA color (60 fps)", "[live] [DS-device] [one-camera]")
00345 {
00346 test_ds_device_streaming({ { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 60 } });
00347 }
00348
00349 TEST_CASE("DS-device streams 480x360 depth and HD color", "[live] [DS-device] [one-camera]")
00350 {
00351 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00352 { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
00353 }
00354
00355 TEST_CASE("DS-device streams 628x468 depth and HD color", "[live] [DS-device] [one-camera]")
00356 {
00357 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 60 },
00358 { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
00359 }
00360
00361 TEST_CASE("DS-device streams 320x240 depth and HD color", "[live] [DS-device] [one-camera]")
00362 {
00363 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 60 },
00364 { RS_STREAM_COLOR, 1920, 1080, RS_FORMAT_YUYV, 30 } });
00365 }
00366
00367 TEST_CASE("DS-device streams 480x360 depth and VGA color", "[live] [DS-device] [one-camera]")
00368 {
00369 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00370 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
00371 }
00372
00373 TEST_CASE("DS-device streams 628x468 depth and VGA color", "[live] [DS-device] [one-camera]")
00374 {
00375 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 60 },
00376 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
00377 }
00378
00379 TEST_CASE("DS-device streams 320x240 depth and VGA color", "[live] [DS-device] [one-camera]")
00380 {
00381 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 60 },
00382 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 } });
00383 }
00384
00385 TEST_CASE("DS-device streams 480x360 depth and VGA color (60 fps)", "[live] [DS-device] [one-camera]")
00386 {
00387 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00388 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 60 } });
00389 }
00390
00391
00393
00395
00396 TEST_CASE("DS-device streams 640x480 infrared (left 8 bit)", "[live] [DS-device] [one-camera]")
00397 {
00398 test_ds_device_streaming({ { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60 } });
00399 }
00400
00401 TEST_CASE("DS-device streams 640x480 infrared (left 16 bit)", "[live] [DS-device] [one-camera]")
00402 {
00403 test_ds_device_streaming({ { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y16, 60 } });
00404 }
00405
00406 TEST_CASE("DS-device streams 640x480 infrared (right 8 bit)", "[live] [DS-device] [one-camera]")
00407 {
00408 test_ds_device_streaming({ { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60 } });
00409 }
00410
00411 TEST_CASE("DS-device streams 640x480 infrared (right 16 bit)", "[live] [DS-device] [one-camera]")
00412 {
00413 test_ds_device_streaming({ { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y16, 60 } });
00414 }
00415
00416 TEST_CASE("DS-device streams 640x480 infrared (left+right 8 bit)", "[live] [DS-device] [one-camera]")
00417 {
00418 test_ds_device_streaming({ { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60 },
00419 { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60 } });
00420 }
00421
00422 TEST_CASE("DS-device streams 640x480 infrared (left+right 16 bit)", "[live] [DS-device] [one-camera]")
00423 {
00424 test_ds_device_streaming({ { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y16, 60 },
00425 { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y16, 60 } });
00426 }
00427
00428 TEST_CASE("DS-device streams 480x360 depth and 492x372 infrared (left+right 16 bit)", "[live] [DS-device] [one-camera]")
00429 {
00430 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00431 { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
00432 { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 } });
00433 }
00434
00435 TEST_CASE("DS-device streams 480x360 depth, VGA color, and 492x372 infrared", "[live] [DS-device] [one-camera]")
00436 {
00437 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00438 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
00439 { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
00440 { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 } });
00441 }
00442
00443 TEST_CASE("DS-device streams 628x468 depth, VGA color, and 640x480 infrared", "[live] [DS-device] [one-camera]")
00444 {
00445 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 60 },
00446 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
00447 { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y16, 60 },
00448 { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y16, 60 } });
00449 }
00450
00451 TEST_CASE("DS-device streams 320x240 depth, VGA color, and 332x252 infrared", "[live] [DS-device] [one-camera]")
00452 {
00453 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 60 },
00454 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 30 },
00455 { RS_STREAM_INFRARED, 332, 252, RS_FORMAT_Y16, 60 },
00456 { RS_STREAM_INFRARED2, 332, 252, RS_FORMAT_Y16, 60 } });
00457 }
00458
00460
00462
00463 TEST_CASE("DS-device streams 640x480 depth and infrared", "[live] [DS-device] [one-camera]")
00464 {
00465 test_ds_device_streaming({ { RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60 },
00466 { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60 },
00467 { RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60 } });
00468 }
00469
00470 TEST_CASE("DS-device streams 628x468 depth and infrared", "[live] [DS-device] [one-camera]")
00471 {
00472 test_ds_device_streaming({ { RS_STREAM_DEPTH, 628, 468, RS_FORMAT_Z16, 60 },
00473 { RS_STREAM_INFRARED, 628, 468, RS_FORMAT_Y8, 60 },
00474 { RS_STREAM_INFRARED2, 628, 468, RS_FORMAT_Y8, 60 } });
00475 }
00476
00477 TEST_CASE("DS-device streams 492x372 depth and infrared", "[live] [DS-device] [one-camera]")
00478 {
00479 test_ds_device_streaming({ { RS_STREAM_DEPTH, 492, 372, RS_FORMAT_Z16, 60 },
00480 { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y8, 60 },
00481 { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y8, 60 } });
00482 }
00483
00484 TEST_CASE("DS-device streams 480x360 depth and infrared", "[live] [DS-device] [one-camera]")
00485 {
00486 test_ds_device_streaming({ { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00487 { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
00488 { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 } });
00489 }
00490
00491 TEST_CASE("DS-device streams 332x252 depth and infrared", "[live] [DS-device] [one-camera]")
00492 {
00493 test_ds_device_streaming({ { RS_STREAM_DEPTH, 332, 252, RS_FORMAT_Z16, 60 },
00494 { RS_STREAM_INFRARED, 332, 252, RS_FORMAT_Y8, 60 },
00495 { RS_STREAM_INFRARED2, 332, 252, RS_FORMAT_Y8, 60 } });
00496 }
00497
00498 TEST_CASE("DS-device streams 320x240 depth and infrared", "[live] [DS-device] [one-camera]")
00499 {
00500 test_ds_device_streaming({ { RS_STREAM_DEPTH, 320, 240, RS_FORMAT_Z16, 60 },
00501 { RS_STREAM_INFRARED, 320, 240, RS_FORMAT_Y8, 60 },
00502 { RS_STREAM_INFRARED2, 320, 240, RS_FORMAT_Y8, 60 } });
00503 }
00504
00506
00508
00509
00510 TEST_CASE("DS-device supports RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED", "[live] [DS-device]")
00511 {
00512 test_ds_device_option(RS_OPTION_R200_LR_AUTO_EXPOSURE_ENABLED, { 0, 1 }, {}, BEFORE_START_DEVICE | AFTER_START_DEVICE);
00513 }
00514
00515 TEST_CASE("DS-device RGB White Balance", "[live] [DS-device] [one-camera]")
00516 {
00517
00518 test_ds_device_option(RS_OPTION_COLOR_WHITE_BALANCE, { 2800, 3500, 4600, 5500, 6400 }, { }, BEFORE_START_DEVICE | AFTER_START_DEVICE);
00519 }
00520
00521 TEST_CASE("DS-device supports RS_OPTION_R200_LR_GAIN", "[live] [DS-device]")
00522 {
00523 test_ds_device_option(RS_OPTION_R200_LR_GAIN, { 100, 200, 400, 800, 1600 }, {}, BEFORE_START_DEVICE | AFTER_START_DEVICE);
00524 }
00525
00526 TEST_CASE("DS-device supports RS_OPTION_R200_LR_EXPOSURE", "[live] [DS-device]")
00527 {
00528 test_ds_device_option(RS_OPTION_R200_LR_EXPOSURE, { 40, 80, 160 }, {}, BEFORE_START_DEVICE | AFTER_START_DEVICE);
00529 }
00530
00531
00532
00533
00534
00535 TEST_CASE("DS-device emitter defaults to off if depth is not enabled/streamed", "[live] [DS-device]")
00536 {
00537 safe_context ctx;
00538 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00539
00540 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00541 REQUIRE(dev != nullptr);
00542
00543 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00544
00545
00546 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00547
00548
00549 rs_enable_stream_preset(dev, RS_STREAM_COLOR, RS_PRESET_BEST_QUALITY, require_no_error());
00550 rs_enable_stream_preset(dev, RS_STREAM_INFRARED, RS_PRESET_BEST_QUALITY, require_no_error());
00551 rs_enable_stream_preset(dev, RS_STREAM_INFRARED2, RS_PRESET_BEST_QUALITY, require_no_error());
00552 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00553
00554
00555 rs_start_device(dev, require_no_error());
00556 std::this_thread::sleep_for(std::chrono::seconds(1));
00557 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00558 }
00559
00560 TEST_CASE("DS-device emitter defaults to on if depth is enabled/streamed", "[live] [DS-device]")
00561 {
00562 safe_context ctx;
00563 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00564
00565 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00566 REQUIRE(dev != nullptr);
00567 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00568
00569
00570 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00571
00572
00573 rs_enable_stream_preset(dev, RS_STREAM_DEPTH, RS_PRESET_BEST_QUALITY, require_no_error());
00574 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00575
00576
00577 rs_start_device(dev, require_no_error());
00578 std::this_thread::sleep_for(std::chrono::seconds(1));
00579 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00580 }
00581
00582 TEST_CASE("DS-device emitter can be enabled even if depth is not enabled/streamed", "[live] [DS-device]")
00583 {
00584 safe_context ctx;
00585 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00586
00587 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00588 REQUIRE(dev != nullptr);
00589 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00590
00591
00592 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00593
00594
00595 rs_enable_stream_preset(dev, RS_STREAM_COLOR, RS_PRESET_BEST_QUALITY, require_no_error());
00596 rs_enable_stream_preset(dev, RS_STREAM_INFRARED, RS_PRESET_BEST_QUALITY, require_no_error());
00597 rs_enable_stream_preset(dev, RS_STREAM_INFRARED2, RS_PRESET_BEST_QUALITY, require_no_error());
00598 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00599
00600
00601 rs_set_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, 1, require_no_error());
00602 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00603
00604
00605 rs_start_device(dev, require_no_error());
00606 std::this_thread::sleep_for(std::chrono::seconds(1));
00607 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00608 }
00609
00610 TEST_CASE("DS-device emitter can be turned off even if depth is enabled/streamed", "[live] [DS-device]")
00611 {
00612 safe_context ctx;
00613 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00614
00615 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00616 REQUIRE(dev != nullptr);
00617 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00618
00619
00620 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00621
00622
00623 rs_enable_stream_preset(dev, RS_STREAM_DEPTH, RS_PRESET_BEST_QUALITY, require_no_error());
00624 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00625
00626
00627 rs_set_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, 0, require_no_error());
00628 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00629
00630
00631 rs_start_device(dev, require_no_error());
00632 std::this_thread::sleep_for(std::chrono::seconds(1));
00633 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00634 }
00635
00636 TEST_CASE("DS-device emitter can be turned on and off after streaming has begun", "[live] [DS-device]")
00637 {
00638 safe_context ctx;
00639 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00640
00641 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00642 REQUIRE(dev != nullptr);
00643 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00644
00645
00646 rs_enable_stream_preset(dev, RS_STREAM_DEPTH, RS_PRESET_BEST_QUALITY, require_no_error());
00647 rs_start_device(dev, require_no_error());
00648 std::this_thread::sleep_for(std::chrono::seconds(1));
00649 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00650
00651
00652 rs_set_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, 0, require_no_error());
00653 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 0);
00654
00655
00656 rs_set_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, 1, require_no_error());
00657 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00658 }
00659
00660 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_UNITS", "[live] [DS-device]")
00661 {
00662 safe_context ctx;
00663 REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00664
00665 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00666 REQUIRE(dev != nullptr);
00667 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00668
00669
00670 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_DEPTH_UNITS, require_no_error()) == 1000);
00671 REQUIRE(rs_get_device_depth_scale(dev, require_no_error()) == 0.001f);
00672
00673 for (int value : {100, 500, 1000, 2000, 10000})
00674 {
00675
00676 rs_set_device_option(dev, RS_OPTION_R200_DEPTH_UNITS, value, require_no_error());
00677 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_DEPTH_UNITS, require_no_error()) == value);
00678 REQUIRE(rs_get_device_depth_scale(dev, require_no_error()) == (float)value / 1000000);
00679 }
00680 }
00681
00682 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_CLAMP_MIN", "[live] [DS-device]")
00683 {
00684 test_ds_device_option(RS_OPTION_R200_DEPTH_CLAMP_MIN, { 0, 500, 1000, 2000 }, {}, BEFORE_START_DEVICE);
00685 }
00686
00687 TEST_CASE("DS-device supports RS_OPTION_R200_DEPTH_CLAMP_MAX", "[live] [DS-device]")
00688 {
00689 test_ds_device_option(RS_OPTION_R200_DEPTH_CLAMP_MAX, { 500, 1000, 2000, USHRT_MAX }, {}, BEFORE_START_DEVICE);
00690 }
00691
00692 TEST_CASE("DS-device verify standard UVC Controls set/get", "[live] [DS-device]")
00693 {
00694
00695 safe_context ctx;
00696 const int device_count = rs_get_device_count(ctx, require_no_error());
00697 REQUIRE(device_count == 1);
00698
00699
00700 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00701 REQUIRE(dev != nullptr);
00702
00703 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s) {return s == rs_get_device_name(dev, require_no_error()); }));
00704
00705
00706 rs_enable_stream_preset(dev, RS_STREAM_COLOR, RS_PRESET_BEST_QUALITY, require_no_error());
00707 rs_enable_stream_preset(dev, RS_STREAM_DEPTH, RS_PRESET_BEST_QUALITY, require_no_error());
00708
00709 rs_set_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, 1, require_no_error());
00710 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00711
00712 rs_start_device(dev, require_no_error());
00713
00714 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
00715 REQUIRE(rs_get_device_option(dev, RS_OPTION_R200_EMITTER_ENABLED, require_no_error()) == 1);
00716
00717 rs_option first = RS_OPTION_COLOR_BACKLIGHT_COMPENSATION;
00718 rs_option last = RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE;
00719
00720 std::vector<rs_option> test_options;
00721 std::vector<double> initial_values;
00722 std::vector<double> modified_values;
00723 std::vector<double> verification_values;
00724 for (int i=first; i<= last; i++)
00725 test_options.push_back((rs_option)i);
00726
00727 initial_values.resize(test_options.size());
00728 modified_values.resize(test_options.size());
00729 verification_values.resize(test_options.size());
00730
00731 rs_get_device_options(dev,test_options.data(),(unsigned int)test_options.size(),initial_values.data(), require_no_error());
00732
00733
00734
00735
00736 double min=0, max=0, step=0;
00737 for (int i=first; i<= last; i++)
00738 {
00739 rs_get_device_option_range(dev,(rs_option)i,&min,&max,&step,require_no_error());
00740 if (initial_values[i] == max)
00741 modified_values[i] = initial_values[i]- step;
00742 else
00743 modified_values[i] = initial_values[i]+ step;
00744 }
00745
00746
00747 rs_set_device_options(dev,test_options.data(),(unsigned int)test_options.size(),modified_values.data(), require_no_error());
00748 std::this_thread::sleep_for(std::chrono::milliseconds(500));
00749
00750 rs_get_device_options(dev,test_options.data(),(unsigned int)test_options.size(),verification_values.data(), require_no_error());
00751
00752
00753
00754
00755 for (int i=first; i<= last; i++)
00756 {
00757 #if defined(_WINDOWS) || defined(WIN32) || defined(WIN64)
00758 if (((rs_option)i == rs_option::RS_OPTION_COLOR_EXPOSURE || (rs_option)i == rs_option::RS_OPTION_COLOR_WHITE_BALANCE))
00759 continue;
00760 #endif
00761
00762 REQUIRE(modified_values[i]!=initial_values[i]);
00763 REQUIRE(modified_values[i]==verification_values[i]);
00764 }
00765
00766 rs_stop_device(dev, require_no_error());
00767 }
00768
00770
00772
00773 TEST_CASE("a single DS-device can stream a variety of reasonable streaming mode combinations", "[live] [DS-device] [one-camera]")
00774 {
00775 safe_context ctx;
00776
00777 SECTION("exactly one device is connected")
00778 {
00779 int device_count = rs_get_device_count(ctx, require_no_error());
00780 REQUIRE(device_count == 1);
00781 }
00782
00783 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00784 REQUIRE(dev != nullptr);
00785
00786 SECTION("device name identification ")
00787 {
00788 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
00789 {
00790 bool b = (s == rs_get_device_name(dev, require_no_error()));
00791 if (b) std::cout << "Camera type " << s << std::endl;
00792 return b; }));
00793 }
00794
00795 SECTION("streaming is possible in some reasonable configurations")
00796 {
00797 SECTION("streaming DEPTH 480, 360, RS_FORMAT_Z16, 60")
00798 {
00799 test_streaming(dev, {
00800 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 }
00801 });
00802 }
00803
00804 SECTION("streaming [DEPTH,480,360,Z16,60] [COLOR,480,360,RGB8,60]")
00805 {
00806 test_streaming(dev, {
00807 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00808 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 }
00809 });
00810 }
00811
00812 SECTION("streaming [DEPTH,480,360,Z16,60] [IR,480,360,Y8,60]")
00813 {
00814 test_streaming(dev, {
00815 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00816 { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 }
00817 });
00818 }
00819
00820 SECTION("streaming [IR,492,372,Y16,60] [IR2,492,372,Y16,60]")
00821 {
00822 test_streaming(dev, {
00823 { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
00824 { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 }
00825 });
00826 }
00827
00828 SECTION("streaming [DEPTH,480,360,Z16,60] [COLOR,640,480,RGB8,60] [IR,480,360,Y8,60] [IR2,480,360,Y8,60]")
00829 {
00830 test_streaming(dev, {
00831 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00832 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 },
00833 { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
00834 { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 }
00835 });
00836 }
00837 }
00838 }
00839
00840 TEST_CASE("streaming five configurations sequentionally", "[live] [DS-device] [one-camera]")
00841 {
00842 safe_context ctx;
00843
00844 SECTION("exactly one device is connected")
00845 {
00846 int device_count = rs_get_device_count(ctx, require_no_error());
00847 REQUIRE(device_count == 1);
00848 }
00849
00850 rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00851 REQUIRE(dev != nullptr);
00852
00853 REQUIRE(std::any_of(ds_names.begin(), ds_names.end(), [&](std::string const& s)
00854 {
00855 bool b = (s == rs_get_device_name(dev, require_no_error()));
00856 if (b) std::cout << "Camera type " << s << std::endl;
00857 return b; }));
00858
00859 test_streaming(dev, {
00860 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 }
00861 });
00862
00863 test_streaming(dev, {
00864 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_YUYV, 60 }
00865 });
00866
00867 test_streaming(dev, {
00868 { RS_STREAM_INFRARED, 492, 372, RS_FORMAT_Y16, 60 },
00869 { RS_STREAM_INFRARED2, 492, 372, RS_FORMAT_Y16, 60 }
00870 });
00871
00872 test_streaming(dev, {
00873 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00874 { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 }
00875 });
00876
00877 test_streaming(dev, {
00878 { RS_STREAM_DEPTH, 480, 360, RS_FORMAT_Z16, 60 },
00879 { RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60 },
00880 { RS_STREAM_INFRARED, 480, 360, RS_FORMAT_Y8, 60 },
00881 { RS_STREAM_INFRARED2, 480, 360, RS_FORMAT_Y8, 60 }
00882 });
00883 }
00884
00885 #endif