Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
func
reflectivity
l500
reflectivity/l500/test-bad-conditions.cpp
Go to the documentation of this file.
1
// License: Apache 2.0. See LICENSE file in root directory.
2
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
3
4
//#test:tag reflectivity
5
//#test:device L500*
6
7
#include "../../func-common.h"
8
9
// Test group description:
10
// * This tests group verifies IR reflectivity option restrictions,
11
// according to [RS-8358].
12
//
13
// Current test description:
14
// * Enabling IR Reflectivity option while streaming require Visual Preset = 'Max Range' and Sensor Mode = 'VGA'.
15
// If not an exception should be thrown.
16
// * If Alternate IR option is on, turning on IR Reflectivity
17
// should throw an exception.
18
//
19
// Note: * L515 specific test.
20
// * Test will pass if no L515 device is connected.
21
// * Test will be performed on the first L515 device detected.
22
23
TEST_CASE
(
"Reflectivity while streaming require Max Range Preset"
,
"[reflectivity]"
)
24
{
25
auto
ds
26
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
27
28
// Make sure alt IR is off
29
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
) )
30
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0 );
31
32
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_LOW_AMBIENT
);
33
auto
depth_vga_profile
34
=
get_profile_by_stream_parameters
(
ds
,
RS2_STREAM_DEPTH
,
RS2_FORMAT_Z16
, 640, 480, 30 );
35
REQUIRE
( depth_vga_profile );
36
37
ds
.open( depth_vga_profile );
38
ds
.start( [](
rs2::frame
f
) {} );
39
40
// Verify failure
41
CHECK_THROWS
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f ) );
42
// Verify stay off
43
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
) );
44
45
ds
.stop();
46
ds
.close();
47
}
48
49
50
TEST_CASE
(
"Reflectivity while streaming require VGA Sensor Mode"
,
"[reflectivity]"
)
51
{
52
auto
ds
53
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
54
55
// Make sure alt IR is off
56
if
(
ds
.supports(
RS2_OPTION_ALTERNATE_IR
))
57
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 0);
58
59
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
60
61
// Find a profile that sensor mode != VGA
62
auto
profiles
=
ds
.get_stream_profiles();
63
auto
non_vga_depth_profile
64
= std::find_if(
profiles
.begin(),
profiles
.end(), [](
rs2::stream_profile
sp) {
65
auto
vp = sp.as<
rs2::video_stream_profile
>();
66
67
return
((sp.stream_type() ==
RS2_STREAM_DEPTH
) && (sp.format() ==
RS2_FORMAT_Z16
)
68
&& (vp.width() != 640) && (vp.height() != 480));
69
});
70
71
REQUIRE
(non_vga_depth_profile !=
profiles
.end());
72
73
ds
.open(*non_vga_depth_profile);
74
ds
.start([](
rs2::frame
f
) {});
75
76
// Verify failure
77
CHECK_THROWS
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
78
// Verify stay off
79
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
80
81
ds
.stop();
82
ds
.close();
83
}
84
85
TEST_CASE
(
"Enable IR Reflectivity when Alternate IR is on fails"
,
"[reflectivity]"
)
86
{
87
auto
ds
88
=
find_first_supported_depth_sensor_or_exit
(
"L515"
,
RS2_OPTION_ENABLE_IR_REFLECTIVITY
);
89
90
if
(!
ds
.supports(
RS2_OPTION_ALTERNATE_IR
))
91
{
92
std::cout
<<
"Sensor not supporting alternate IR, test skipped"
<< std::endl;
93
exit
(0);
94
}
95
96
ds
.set_option(
RS2_OPTION_ALTERNATE_IR
, 1.
f
);
97
98
ds
.set_option(
RS2_OPTION_SENSOR_MODE
,
RS2_SENSOR_MODE_VGA
);
99
ds
.set_option(
RS2_OPTION_VISUAL_PRESET
,
RS2_L500_VISUAL_PRESET_MAX_RANGE
);
100
101
CHECK_THROWS
(
ds
.set_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
, 1.f));
102
CHECK_FALSE
(
ds
.get_option(
RS2_OPTION_ENABLE_IR_REFLECTIVITY
));
103
}
rs2::stream_profile
Definition:
rs_frame.hpp:22
RS2_L500_VISUAL_PRESET_LOW_AMBIENT
Definition:
rs_option.h:156
rs2::frame
Definition:
rs_frame.hpp:343
RS2_L500_VISUAL_PRESET_MAX_RANGE
Definition:
rs_option.h:157
RS2_FORMAT_Z16
Definition:
rs_sensor.h:62
RS2_SENSOR_MODE_VGA
Definition:
rs_option.h:167
f
GLdouble f
Definition:
glad/glad/glad.h:1518
TEST_CASE
TEST_CASE("Reflectivity while streaming require Max Range Preset","[reflectivity]")
Definition:
reflectivity/l500/test-bad-conditions.cpp:23
Catch::cout
std::ostream & cout()
REQUIRE
REQUIRE(n_callbacks==1)
find_first_supported_depth_sensor_or_exit
rs2::depth_sensor find_first_supported_depth_sensor_or_exit(const std::string &dev_name, rs2_option opt)
Definition:
func-common.h:77
RS2_OPTION_ENABLE_IR_REFLECTIVITY
Definition:
rs_option.h:109
t265_stereo.profiles
profiles
Definition:
t265_stereo.py:139
CHECK_THROWS
#define CHECK_THROWS(...)
Definition:
catch.hpp:17415
RS2_STREAM_DEPTH
Definition:
rs_sensor.h:45
rs2::textual_icons::exit
static const textual_icon exit
Definition:
model-views.h:254
test_sensor_first_frame_delay.ds
ds
Definition:
test_sensor_first_frame_delay.py:75
RS2_OPTION_ALTERNATE_IR
Definition:
rs_option.h:107
rs2::video_stream_profile
Definition:
rs_frame.hpp:201
RS2_OPTION_VISUAL_PRESET
Definition:
rs_option.h:36
RS2_OPTION_SENSOR_MODE
Definition:
rs_option.h:95
get_profile_by_stream_parameters
rs2::stream_profile get_profile_by_stream_parameters(rs2::sensor s, rs2_stream stream=RS2_STREAM_ANY, rs2_format format=RS2_FORMAT_ANY, int width=-1, int height=-1, int fps=-1, int stream_index=-1)
Definition:
func-common.h:227
CHECK_FALSE
CHECK_FALSE(inverse(inverse(p))==p)
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:50:11