Skip to content

Commit

Permalink
Fixing crashes in the viewer when switching between cameras in the 3D…
Browse files Browse the repository at this point in the history
… viewer
  • Loading branch information
dorodnic committed Oct 10, 2017
1 parent 58518b3 commit 3317adc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
11 changes: 9 additions & 2 deletions src/ds5/ds5-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,16 @@ namespace librealsense

auto video = dynamic_cast<video_stream_profile_interface*>(p.get());
auto profile = to_profile(p.get());
video->set_intrinsics([profile, this]()

std::weak_ptr<ds5_color_sensor> wp =
std::dynamic_pointer_cast<ds5_color_sensor>(this->shared_from_this());
video->set_intrinsics([profile, wp]()
{
return get_intrinsics(profile);
auto sp = wp.lock();
if (sp)
return sp->get_intrinsics(profile);
else
return rs2_intrinsics{};
});

if (video->get_width() == 640 && video->get_height() == 480 && video->get_format() == RS2_FORMAT_RGB8 && video->get_framerate() == 30)
Expand Down
10 changes: 8 additions & 2 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ namespace librealsense
if (p->get_format() != RS2_FORMAT_Y16) // Y16 format indicate unrectified images, no intrinsics are available for these
{
auto profile = to_profile(p.get());
video->set_intrinsics([profile, this]()
std::weak_ptr<ds5_depth_sensor> wp =
std::dynamic_pointer_cast<ds5_depth_sensor>(this->shared_from_this());
video->set_intrinsics([profile, wp]()
{
return get_intrinsics(profile);
auto sp = wp.lock();
if (sp)
return sp->get_intrinsics(profile);
else
return rs2_intrinsics{};
});
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/ds5/ds5-motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,16 @@ namespace librealsense
if (video->get_width() == 640 && video->get_height() == 480 && video->get_format() == RS2_FORMAT_RAW8 && video->get_framerate() == 30)
video->make_default();

// Register intrinsics
auto profile = to_profile(p.get());
video->set_intrinsics([profile, this]()
std::weak_ptr<ds5_fisheye_sensor> wp =
std::dynamic_pointer_cast<ds5_fisheye_sensor>(this->shared_from_this());
video->set_intrinsics([profile, wp]()
{
return get_intrinsics(profile);
auto sp = wp.lock();
if (sp)
return sp->get_intrinsics(profile);
else
return rs2_intrinsics{};
});
}

Expand Down
21 changes: 17 additions & 4 deletions src/ivcam/sr300.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,15 @@ namespace librealsense
video->make_default();

auto profile = to_profile(p.get());
video->set_intrinsics([profile, this]()
std::weak_ptr<sr300_color_sensor> wp =
std::dynamic_pointer_cast<sr300_color_sensor>(this->shared_from_this());
video->set_intrinsics([profile, wp]()
{
return get_intrinsics(profile);
auto sp = wp.lock();
if (sp)
return sp->get_intrinsics(profile);
else
return rs2_intrinsics{};
});
}

Expand Down Expand Up @@ -285,9 +291,16 @@ namespace librealsense
video->make_default();

auto profile = to_profile(p.get());
video->set_intrinsics([profile, this]()
std::weak_ptr<sr300_depth_sensor> wp =
std::dynamic_pointer_cast<sr300_depth_sensor>(this->shared_from_this());

video->set_intrinsics([profile, wp]()
{
return get_intrinsics(profile);
auto sp = wp.lock();
if (sp)
return sp->get_intrinsics(profile);
else
return rs2_intrinsics{};
});
}

Expand Down

0 comments on commit 3317adc

Please sign in to comment.