unit-tests-live-f200.cpp
Go to the documentation of this file.
00001 // License: Apache 2.0. See LICENSE file in root directory.
00002 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
00003 
00005 // This set of tests is valid only for the F200 camera //
00007 
00008 #if !defined(MAKEFILE) || ( defined(F200_TEST) && defined(LIVE_TEST) )
00009 
00010 #define CATCH_CONFIG_MAIN
00011 #include "catch/catch.hpp"
00012 
00013 #include "unit-tests-common.h"
00014 
00015 #include <sstream>
00016 
00017 // due to F200 timestamp spikes it will be not tested in video callbacks mode
00018 inline void test_f200_streaming(rs_device * device, std::initializer_list<stream_mode> modes)
00019 {
00020     std::map<rs_stream, test_duration> duration_per_stream;
00021     for(auto & mode : modes)
00022     {
00023         duration_per_stream.insert(std::pair<rs_stream, test_duration>(mode.stream, test_duration()));
00024         rs_enable_stream(device, mode.stream, mode.width, mode.height, mode.format, mode.framerate, require_no_error());
00025         REQUIRE( rs_is_stream_enabled(device, mode.stream, require_no_error()) == 1 );
00026     }
00027 
00028     test_wait_for_frames(device, modes, duration_per_stream);
00029 
00030     for(auto & mode : modes)
00031     {
00032         rs_disable_stream(device, mode.stream, require_no_error());
00033         REQUIRE( rs_is_stream_enabled(device, mode.stream, require_no_error()) == 0 );
00034     }
00035 }
00036 
00037 TEST_CASE( "F200 metadata enumerates correctly", "[live] [f200]" )
00038 {
00039     // Require at least one device to be plugged in
00040     safe_context ctx;
00041     const int device_count = rs_get_device_count(ctx, require_no_error());
00042     REQUIRE(device_count > 0);
00043 
00044     // For each device
00045     for(int i=0; i<device_count; ++i)
00046     {
00047         rs_device * dev = rs_get_device(ctx, 0, require_no_error());    
00048         REQUIRE(dev != nullptr);
00049 
00050         SECTION( "device name is Intel RealSense F200" )
00051         {
00052             const char * name = rs_get_device_name(dev, require_no_error());
00053             REQUIRE(name == std::string("Intel RealSense F200"));
00054         }
00055     }
00056 }
00057 
00058 TEST_CASE( "F200 devices support all required options", "[live] [f200]" )
00059 {
00060     // Require at least one device to be plugged in
00061     safe_context ctx;
00062     const int device_count = rs_get_device_count(ctx, require_no_error());
00063     REQUIRE(device_count > 0);
00064 
00065     // For each device
00066     for(int i=0; i<device_count; ++i)
00067     {
00068         rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00069         REQUIRE(dev != nullptr);
00070 
00071         SECTION( "device supports standard picture options and F200 extension options, and nothing else" )
00072         {
00073             const int supported_options[] = {
00074                 RS_OPTION_COLOR_BACKLIGHT_COMPENSATION,
00075                 RS_OPTION_COLOR_BRIGHTNESS,
00076                 RS_OPTION_COLOR_CONTRAST,
00077                 RS_OPTION_COLOR_EXPOSURE,
00078                 RS_OPTION_COLOR_GAIN,
00079                 RS_OPTION_COLOR_GAMMA,
00080                 RS_OPTION_COLOR_HUE,
00081                 RS_OPTION_COLOR_SATURATION,
00082                 RS_OPTION_COLOR_SHARPNESS,
00083                 RS_OPTION_COLOR_WHITE_BALANCE,
00084                 RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE,
00085                 RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE,
00086                 RS_OPTION_F200_LASER_POWER,
00087                 RS_OPTION_F200_ACCURACY,
00088                 RS_OPTION_F200_MOTION_RANGE,
00089                 RS_OPTION_F200_FILTER_OPTION,
00090                 RS_OPTION_F200_CONFIDENCE_THRESHOLD,
00091                 RS_OPTION_F200_DYNAMIC_FPS,
00092                 RS_OPTION_FRAMES_QUEUE_SIZE
00093             };
00094 
00095             for(int i=0; i<RS_OPTION_COUNT; ++i)
00096             {
00097                 if(std::find(std::begin(supported_options), std::end(supported_options), i) != std::end(supported_options))
00098                 {
00099                     REQUIRE(rs_device_supports_option(dev, (rs_option)i, require_no_error()) == 1);
00100                 }
00101                 else
00102                 {
00103                     REQUIRE(rs_device_supports_option(dev, (rs_option)i, require_no_error()) == 0);
00104                 }
00105             }
00106         }
00107     }
00108 }
00110 // Calibration information tests //
00112 
00113 TEST_CASE( "F200 device extrinsics are within expected parameters", "[live] [f200]" )
00114 {
00115     // Require at least one device to be plugged in
00116     safe_context ctx;
00117     const int device_count = rs_get_device_count(ctx, require_no_error());
00118     REQUIRE(device_count > 0);
00119 
00120     // For each device
00121     for(int i=0; i<device_count; ++i)
00122     {
00123         rs_device * dev = rs_get_device(ctx, 0, require_no_error());    
00124         REQUIRE(dev != nullptr);
00125 
00126         SECTION( "no extrinsic transformation between DEPTH and INFRARED" )
00127         {
00128             rs_extrinsics extrin;
00129             rs_get_device_extrinsics(dev, RS_STREAM_DEPTH, RS_STREAM_INFRARED, &extrin, require_no_error());
00130 
00131             require_identity_matrix(extrin.rotation);
00132             require_zero_vector(extrin.translation);
00133         }
00134 
00135         SECTION( "depth scale is 1/32 mm" )
00136         {
00137             REQUIRE( rs_get_device_depth_scale(dev, require_no_error()) == Approx(1.0f/32000) );
00138         }
00139     }
00140 }
00141 
00143 // Depth streaming tests //
00145 
00146 TEST_CASE("F200 streams depth (Z16)", "[live] [f200] [one-camera]")
00147 {
00148     safe_context ctx;
00149     REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00150 
00151     rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00152     REQUIRE(dev != nullptr);
00153     REQUIRE(rs_get_device_name(dev, require_no_error()) == std::string("Intel RealSense F200"));
00154 
00155     SECTION("F200 streams depth 640x480 (VGA), [15,30,60] fps")
00156     {
00157         for (auto & fps : { /*2, 5,*/ 15, 30, 60 })
00158         {
00159             INFO("Testing " << fps << " fps");
00160             test_f200_streaming(dev, { { RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, fps } });
00161         }
00162     }
00163 
00164     SECTION("F200 streams depth 640x240 (HVGA), [15,30,60] fps")
00165     {
00166         for (auto & fps : {/* 2, 5,*/ 15, 30, 60})
00167         {
00168             INFO("Testing " << fps << " fps");
00169             test_f200_streaming(dev, { { RS_STREAM_DEPTH, 640, 240, RS_FORMAT_Z16, fps } });
00170         }
00171     }
00172 }
00173 
00175 // Infrared streaming tests //
00177 
00178 TEST_CASE("F200 streams infrared (Y16)", "[live] [f200] [one-camera]")
00179 {
00180     safe_context ctx;
00181     REQUIRE(rs_get_device_count(ctx, require_no_error()) == 1);
00182 
00183     rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00184     REQUIRE(dev != nullptr);
00185     REQUIRE(rs_get_device_name(dev, require_no_error()) == std::string("Intel RealSense F200"));
00186 
00187     SECTION("F200 streams infrared 640x480 depth (VGA), [30,60,120] fps")
00188     {
00189         for (auto & fps : { 30, 60, 120/*, 240, 300*/ })
00190         {
00191             INFO("Testing " << fps << " fps")
00192             test_f200_streaming(dev, { { RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y16, fps } });
00193         }
00194     }
00195 
00196     SECTION("F200 streams infrared 640x240 depth (HVGA), [30,60,120] fps")
00197     {
00198         for (auto & fps : { 30, 60, 120/*, 240, 300*/ })
00199         {
00200             INFO("Testing " << fps << " fps")
00201             test_f200_streaming(dev, { { RS_STREAM_INFRARED, 640, 240, RS_FORMAT_Y16, fps } });
00202         }
00203     }
00204 }
00205 
00206 TEST_CASE( "F200 has no INFRARED2 streaming modes", "[live] [f200]" )
00207 {
00208     // Require at least one device to be plugged in
00209     safe_context ctx;
00210     const int device_count = rs_get_device_count(ctx, require_no_error());
00211     REQUIRE(device_count > 0);
00212 
00213     // For each device
00214     for(int i=0; i<device_count; ++i)
00215     {
00216         rs_device * dev = rs_get_device(ctx, 0, require_no_error());    
00217         REQUIRE(dev != nullptr);
00218         REQUIRE( rs_get_stream_mode_count(dev, RS_STREAM_INFRARED2, require_no_error()) == 0 );
00219     }
00220 }
00221 
00223 // Streaming tests //
00225 
00226 TEST_CASE( "a single F200 can stream a variety of reasonable streaming mode combinations", "[live] [f200] [one-camera]" )
00227 {
00228     safe_context ctx;
00229 
00230     SECTION( "exactly one device is connected" )
00231     {
00232         int device_count = rs_get_device_count(ctx, require_no_error());
00233         REQUIRE(device_count == 1);
00234     }
00235 
00236     rs_device * dev = rs_get_device(ctx, 0, require_no_error());
00237     REQUIRE(dev != nullptr);
00238 
00239     SECTION( "device name is Intel RealSense F200" )
00240     {
00241         const char * name = rs_get_device_name(dev, require_no_error());
00242         REQUIRE(name == std::string("Intel RealSense F200"));
00243     }
00244 
00245     SECTION( "streaming is possible in some reasonable configurations" )
00246     {
00247         test_f200_streaming(dev, {
00248             {RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60}
00249         });
00250 
00251         test_f200_streaming(dev, {
00252             {RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60},
00253             {RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60}
00254         });
00255 
00256         test_f200_streaming(dev, {
00257             {RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60},
00258             {RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60}
00259         });
00260 
00261         test_f200_streaming(dev, {
00262             {RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60},
00263         });
00264 
00265         test_f200_streaming(dev, {
00266             {RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60},
00267             {RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60},
00268             {RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60}
00269         });
00270     }
00271 }
00272 
00273 #endif /* !defined(MAKEFILE) || ( defined(F200_TEST) && defined(LIVE_TEST) ) */


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39