@@ -38,27 +38,27 @@ std::shared_ptr< matcher > matcher_factory::create( rs2_matchers matcher,
38
38
39
39
std::shared_ptr< matcher > matcher_factory::create_DLR_C_matcher ( std::vector< stream_interface * > const & profiles )
40
40
{
41
- auto color = find_profile ( RS2_STREAM_COLOR, 0 , profiles );
42
- if ( ! color )
41
+ auto color = get_color_profiles ( profiles );
42
+ if ( color. empty () )
43
43
{
44
44
LOG_DEBUG ( " Created default matcher" );
45
45
return create_timestamp_matcher ( profiles );
46
46
}
47
47
48
- return create_timestamp_composite_matcher ( { create_DLR_matcher ( profiles ), create_identity_matcher ( color ) } );
48
+ return create_timestamp_composite_matcher ( { create_DLR_matcher ( profiles ), create_color_composite_matcher ( color ) } );
49
49
}
50
50
51
51
52
52
std::shared_ptr< matcher > matcher_factory::create_DI_C_matcher ( std::vector< stream_interface * > const & profiles )
53
53
{
54
- auto color = find_profile ( RS2_STREAM_COLOR, 0 , profiles );
55
- if ( ! color )
54
+ auto color = get_color_profiles ( profiles );
55
+ if ( color. empty () )
56
56
{
57
57
LOG_DEBUG ( " Created default matcher" );
58
58
return create_timestamp_matcher ( profiles );
59
59
}
60
60
61
- return create_timestamp_composite_matcher ( { create_DI_matcher ( profiles ), create_identity_matcher ( color ) } );
61
+ return create_timestamp_composite_matcher ( { create_DI_matcher ( profiles ), create_color_composite_matcher ( color ) } );
62
62
}
63
63
64
64
@@ -115,11 +115,11 @@ std::shared_ptr< matcher > matcher_factory::create_DIC_matcher( std::vector< str
115
115
116
116
std::shared_ptr< matcher > matcher_factory::create_DIC_C_matcher ( std::vector< stream_interface * > const & profiles )
117
117
{
118
- auto color = find_profile ( RS2_STREAM_COLOR, 0 , profiles );
119
- if ( ! color )
118
+ auto color = get_color_profiles ( profiles );
119
+ if ( color. empty () )
120
120
throw std::runtime_error ( " no color stream found for matcher" );
121
121
122
- return create_timestamp_composite_matcher ( { create_DIC_matcher ( profiles ), create_identity_matcher ( color ) } );
122
+ return create_timestamp_composite_matcher ( { create_DIC_matcher ( profiles ), create_color_composite_matcher ( color ) } );
123
123
}
124
124
125
125
@@ -164,4 +164,33 @@ matcher_factory::create_timestamp_composite_matcher( std::vector< std::shared_pt
164
164
}
165
165
166
166
167
- } // namespace librealsense
167
+ std::vector< stream_interface * >
168
+ matcher_factory::get_color_profiles ( std::vector< stream_interface * > const & profiles )
169
+ {
170
+ // We need one profile per stream - matcher use only UID and type
171
+ std::map< int , stream_interface * > color_profiles;
172
+ for ( auto & profile : profiles )
173
+ if ( profile->get_stream_type () == RS2_STREAM_COLOR )
174
+ color_profiles[profile->get_stream_index ()] = profile;
175
+
176
+ std::vector< stream_interface * > ret;
177
+ for ( auto & profile : color_profiles )
178
+ ret.push_back ( profile.second );
179
+
180
+ return ret;
181
+ }
182
+
183
+
184
+ std::shared_ptr< matcher >
185
+ matcher_factory::create_color_composite_matcher ( std::vector< stream_interface * > const & profiles )
186
+ {
187
+ std::vector< std::shared_ptr< matcher > > color_matchers;
188
+ for ( auto & profile : profiles )
189
+ color_matchers.push_back ( std::make_shared< identity_matcher >( profile->get_unique_id (),
190
+ profile->get_stream_type () ) );
191
+
192
+ return create_frame_number_composite_matcher ( color_matchers );
193
+ }
194
+
195
+
196
+ } // namespace librealsense
0 commit comments