diff --git a/src/ds5/ds5-color.cpp b/src/ds5/ds5-color.cpp index fc12e5cf8f..ddce42942f 100644 --- a/src/ds5/ds5-color.cpp +++ b/src/ds5/ds5-color.cpp @@ -145,9 +145,16 @@ namespace librealsense auto video = dynamic_cast(p.get()); auto profile = to_profile(p.get()); - video->set_intrinsics([profile, this]() + + std::weak_ptr wp = + std::dynamic_pointer_cast(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) diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index 0d29fe1d61..3fb756d229 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -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 wp = + std::dynamic_pointer_cast(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{}; }); } } diff --git a/src/ds5/ds5-motion.cpp b/src/ds5/ds5-motion.cpp index 7c6bd1953c..06b1364b3c 100644 --- a/src/ds5/ds5-motion.cpp +++ b/src/ds5/ds5-motion.cpp @@ -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 wp = + std::dynamic_pointer_cast(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{}; }); } diff --git a/src/ivcam/sr300.h b/src/ivcam/sr300.h index 130528baf8..e957b4e0d2 100644 --- a/src/ivcam/sr300.h +++ b/src/ivcam/sr300.h @@ -233,9 +233,15 @@ namespace librealsense video->make_default(); auto profile = to_profile(p.get()); - video->set_intrinsics([profile, this]() + std::weak_ptr wp = + std::dynamic_pointer_cast(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{}; }); } @@ -285,9 +291,16 @@ namespace librealsense video->make_default(); auto profile = to_profile(p.get()); - video->set_intrinsics([profile, this]() + std::weak_ptr wp = + std::dynamic_pointer_cast(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{}; }); }