Skip to content

Commit 3bc4a83

Browse files
committed
matcher handles multiple color streams
1 parent f70c2b2 commit 3bc4a83

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

src/core/matcher-factory.cpp

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ std::shared_ptr< matcher > matcher_factory::create( rs2_matchers matcher,
3838

3939
std::shared_ptr< matcher > matcher_factory::create_DLR_C_matcher( std::vector< stream_interface * > const & profiles )
4040
{
41-
auto color = find_profile( RS2_STREAM_COLOR, 0, profiles );
42-
if( ! color )
41+
auto color = get_color_profiles( profiles );
42+
if( color.empty() )
4343
{
4444
LOG_DEBUG( "Created default matcher" );
4545
return create_timestamp_matcher( profiles );
4646
}
4747

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 ) } );
4949
}
5050

5151

5252
std::shared_ptr< matcher > matcher_factory::create_DI_C_matcher( std::vector< stream_interface * > const & profiles )
5353
{
54-
auto color = find_profile( RS2_STREAM_COLOR, 0, profiles );
55-
if( ! color )
54+
auto color = get_color_profiles( profiles );
55+
if( color.empty() )
5656
{
5757
LOG_DEBUG( "Created default matcher" );
5858
return create_timestamp_matcher( profiles );
5959
}
6060

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 ) } );
6262
}
6363

6464

@@ -115,11 +115,11 @@ std::shared_ptr< matcher > matcher_factory::create_DIC_matcher( std::vector< str
115115

116116
std::shared_ptr< matcher > matcher_factory::create_DIC_C_matcher( std::vector< stream_interface * > const & profiles )
117117
{
118-
auto color = find_profile( RS2_STREAM_COLOR, 0, profiles );
119-
if( ! color )
118+
auto color = get_color_profiles( profiles );
119+
if( color.empty() )
120120
throw std::runtime_error( "no color stream found for matcher" );
121121

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 ) } );
123123
}
124124

125125

@@ -164,4 +164,33 @@ matcher_factory::create_timestamp_composite_matcher( std::vector< std::shared_pt
164164
}
165165

166166

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

src/core/matcher-factory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class matcher_factory
3434
static std::shared_ptr< matcher > create_frame_number_matcher( std::vector< stream_interface * > const & profiles );
3535
static std::shared_ptr< matcher > create_timestamp_matcher( std::vector< stream_interface * > const & profiles );
3636

37+
static std::vector< stream_interface * > get_color_profiles( std::vector< stream_interface * > const & profiles );
38+
static std::shared_ptr< matcher >
39+
create_color_composite_matcher( std::vector< stream_interface * > const & profiles );
3740
static std::shared_ptr< matcher >
3841
create_timestamp_composite_matcher( std::vector< std::shared_ptr< matcher > > const & matchers );
3942
static std::shared_ptr< matcher >

0 commit comments

Comments
 (0)