Skip to content

Commit

Permalink
Merge pull request IntelRealSense#2128 from matkatz1/tag_profiles_red…
Browse files Browse the repository at this point in the history
…esign

change tag_profile to tag_profiles and move the tagging to sensor_base
  • Loading branch information
dorodnic authored Jul 24, 2018
2 parents 6da23a8 + 09d00d1 commit c4d84ae
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/core/streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace librealsense

virtual std::vector<tagged_profile> get_profiles_tags() const = 0;

virtual void tag_profile(stream_profile_interface* profile) const = 0;
virtual void tag_profiles(stream_profiles profiles) const = 0;
};

class depth_stereo_sensor;
Expand Down
25 changes: 14 additions & 11 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,23 @@ void librealsense::device::register_stream_to_extrinsic_group(const stream_inter
}
}

void librealsense::device::tag_profile(stream_profile_interface* profile) const
void librealsense::device::tag_profiles(stream_profiles profiles) const
{
for (auto tag : *_profiles_tags)
for (auto profile : profiles)
{
auto vp = dynamic_cast<video_stream_profile_interface*>(profile);
if (vp)
for (auto tag : *_profiles_tags)
{
if ((tag.stream == RS2_STREAM_ANY || vp->get_stream_type() == tag.stream) &&
(tag.format == RS2_FORMAT_ANY || vp->get_format() == tag.format) &&
(tag.width == -1 || vp->get_width() == tag.width) &&
(tag.height == -1 || vp->get_height() == tag.height) &&
(tag.fps == -1 || vp->get_framerate() == tag.fps) &&
(tag.stream_index == -1 || vp->get_stream_index() == tag.stream_index))
profile->tag_profile(tag.tag);
auto vp = dynamic_cast<video_stream_profile_interface*>(profile.get());
if (vp)
{
if ((tag.stream == RS2_STREAM_ANY || vp->get_stream_type() == tag.stream) &&
(tag.format == RS2_FORMAT_ANY || vp->get_format() == tag.format) &&
(tag.width == -1 || vp->get_width() == tag.width) &&
(tag.height == -1 || vp->get_height() == tag.height) &&
(tag.fps == -1 || vp->get_framerate() == tag.fps) &&
(tag.stream_index == -1 || vp->get_stream_index() == tag.stream_index))
profile->tag_profile(tag.tag);
}
}
}
}
2 changes: 1 addition & 1 deletion src/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace librealsense
return _is_valid;
}

void tag_profile(stream_profile_interface* profile) const override;
void tag_profiles(stream_profiles profiles) const override;

protected:
int add_sensor(std::shared_ptr<sensor_interface> sensor_base);
Expand Down
2 changes: 0 additions & 2 deletions src/ds5/ds5-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ namespace librealsense
else
return rs2_intrinsics{};
});

get_device().tag_profile(video);
}

return results;
Expand Down
4 changes: 0 additions & 4 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ namespace librealsense
}
auto vid_profile = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(vid_profile);

// Register intrinsics
if (p->get_format() != RS2_FORMAT_Y16) // Y16 format indicate unrectified images, no intrinsics are available for these
{
Expand Down Expand Up @@ -233,8 +231,6 @@ namespace librealsense
}
auto video = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(video);

// Register intrinsics
if (p->get_format() != RS2_FORMAT_Y16) // Y16 format indicate unrectified images, no intrinsics are available for these
{
Expand Down
5 changes: 0 additions & 5 deletions src/ds5/ds5-motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ namespace librealsense
assign_stream(_owner->_gyro_stream, p);
if (p->get_stream_type() == RS2_STREAM_GPIO)
assign_stream(_owner->_gpio_streams[p->get_stream_index()-1], p);
if (p->get_framerate() == 1000 &&
p->get_format() == RS2_FORMAT_MOTION_XYZ32F)
get_device().tag_profile(p.get());

//set motion intrinsics
if (p->get_stream_type() == RS2_STREAM_ACCEL || p->get_stream_type() == RS2_STREAM_GYRO)
Expand Down Expand Up @@ -127,8 +124,6 @@ namespace librealsense

auto video = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(video);

auto profile = to_profile(p.get());
std::weak_ptr<ds5_fisheye_sensor> wp =
std::dynamic_pointer_cast<ds5_fisheye_sensor>(this->shared_from_this());
Expand Down
4 changes: 0 additions & 4 deletions src/ivcam/sr300.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ namespace librealsense
// Register intrinsics
auto video = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(video);

auto profile = to_profile(p.get());
std::weak_ptr<sr300_color_sensor> wp =
std::dynamic_pointer_cast<sr300_color_sensor>(this->shared_from_this());
Expand Down Expand Up @@ -293,8 +291,6 @@ namespace librealsense
// Register intrinsics
auto video = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(video);

auto profile = to_profile(p.get());
std::weak_ptr<sr300_depth_sensor> wp =
std::dynamic_pointer_cast<sr300_depth_sensor>(this->shared_from_this());
Expand Down
2 changes: 0 additions & 2 deletions src/l500/l500.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ namespace librealsense
// Register intrinsics
auto video = dynamic_cast<video_stream_profile_interface*>(p.get());

get_device().tag_profile(video);

auto profile = to_profile(p.get());
std::weak_ptr<l500_depth_sensor> wp =
std::dynamic_pointer_cast<l500_depth_sensor>(this->shared_from_this());
Expand Down
5 changes: 1 addition & 4 deletions src/media/playback/playback_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ playback_device::playback_device(std::shared_ptr<context> ctx, std::shared_ptr<d
for (auto sensor_pair : m_sensors)
{
auto profiles = sensor_pair.second->get_stream_profiles();
for(auto profile : profiles)
{
tag_profile(profile.get());
}
tag_profiles(profiles);
}
register_extrinsics(m_device_description);
}
Expand Down
5 changes: 3 additions & 2 deletions src/media/playback/playback_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ namespace librealsense
bool is_valid() const override;

std::vector<tagged_profile> get_profiles_tags() const override { return std::vector<tagged_profile>(); };//no hard-coded default streams for playback
void tag_profile(stream_profile_interface* profile) const override
void tag_profiles(stream_profiles profiles) const override
{
profile->tag_profile(profile_tag::PROFILE_TAG_DEFAULT | profile_tag::PROFILE_TAG_SUPERSET);
for(auto profile : profiles)
profile->tag_profile(profile_tag::PROFILE_TAG_DEFAULT | profile_tag::PROFILE_TAG_SUPERSET);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/media/record/record_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace librealsense
bool is_valid() const override;

std::vector<tagged_profile> get_profiles_tags() const override { return m_device->get_profiles_tags(); };
void tag_profile(stream_profile_interface* profile) const override { m_device->tag_profile(profile); }
void tag_profiles(stream_profiles profiles) const override { m_device->tag_profiles(profiles); }

private:
template <typename T> void write_device_extension_changes(const T& ext);
Expand Down
6 changes: 5 additions & 1 deletion src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ namespace librealsense
_metadata_parsers(std::make_shared<metadata_parser_map>()),
_on_open(nullptr),
_owner(dev),
_profiles([this]() { return this->init_stream_profiles(); })
_profiles([this]() {
auto profiles = this->init_stream_profiles();
_owner->tag_profiles(profiles);
return profiles;
})
{
register_option(RS2_OPTION_FRAMES_QUEUE_SIZE, _source.get_published_size_option());

Expand Down

0 comments on commit c4d84ae

Please sign in to comment.