From 5ab94a66c943b000caec67a7ae7460842bfebaf8 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 24 Jul 2020 13:51:25 +0300 Subject: [PATCH] Add 360 render capability --- applications/gui2/src/modules/camera.cpp | 5 +++- .../include/ftl/rgbd/capabilities.hpp | 4 ++- .../rgbd-sources/include/ftl/rgbd/frame.hpp | 2 ++ .../streams/src/renderers/screen_render.cpp | 27 ++++++++++--------- .../streams/src/renderers/screen_render.hpp | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/applications/gui2/src/modules/camera.cpp b/applications/gui2/src/modules/camera.cpp index 218b1d29c..670695023 100644 --- a/applications/gui2/src/modules/camera.cpp +++ b/applications/gui2/src/modules/camera.cpp @@ -76,11 +76,14 @@ void Camera::update(double delta) { if (caps.count(Capability::TOUCH)) jmeta["Touch"] = nlohmann::json{{"icon", ENTYPO_ICON_MOUSE_POINTER},{"value", true}}; else jmeta.erase("Touch"); - if (caps.count(Capability::MOVABLE)) jmeta["Movable"] = nlohmann::json{{"icon", ENTYPO_ICON_COMPASS},{"value", true}}; + if (caps.count(Capability::MOVABLE)) jmeta["Movable"] = nlohmann::json{{"icon", ENTYPO_ICON_DIRECTION},{"value", true}}; else jmeta.erase("Movable"); if (caps.count(Capability::VR)) jmeta["VR"] = nlohmann::json{{"value", true}}; else jmeta.erase("VR"); + + if (caps.count(Capability::EQUI_RECT)) jmeta["360"] = nlohmann::json{{"icon", ENTYPO_ICON_COMPASS},{"value", true}}; + else jmeta.erase("360"); } std::map<ftl::data::Message,std::string> messages; diff --git a/components/rgbd-sources/include/ftl/rgbd/capabilities.hpp b/components/rgbd-sources/include/ftl/rgbd/capabilities.hpp index dd938fc1b..dacab1e52 100644 --- a/components/rgbd-sources/include/ftl/rgbd/capabilities.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/capabilities.hpp @@ -22,7 +22,9 @@ enum class Capability : int { VR, // Is a VR device, so provides own active pose etc LIVE, // Live, not recorded (removed from ftl file sources) FUSED, // Reconstruction has been performed - STREAMED // Means it came from a stream and not device + STREAMED, // Means it came from a stream and not device + EQUI_RECT, // 360 rendered (Equirectangular Render) + STEREO // Side-by-side stereo render }; std::string capabilityName(Capability); diff --git a/components/rgbd-sources/include/ftl/rgbd/frame.hpp b/components/rgbd-sources/include/ftl/rgbd/frame.hpp index 74e06aaac..509c4bec8 100644 --- a/components/rgbd-sources/include/ftl/rgbd/frame.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/frame.hpp @@ -105,6 +105,8 @@ class Frame : public ftl::data::Frame { inline bool isMovable() const { return hasCapability(ftl::rgbd::Capability::MOVABLE); } inline bool isTouchable() const { return hasCapability(ftl::rgbd::Capability::TOUCH); } inline bool isVR() const { return hasCapability(ftl::rgbd::Capability::VR); } + inline bool is360() const { return hasCapability(ftl::rgbd::Capability::EQUI_RECT); } + inline bool isSideBySideStereo() const { return hasCapability(ftl::rgbd::Capability::STEREO); } void upload(ftl::codecs::Channel c); diff --git a/components/streams/src/renderers/screen_render.cpp b/components/streams/src/renderers/screen_render.cpp index 056477c6c..c60bd7047 100644 --- a/components/streams/src/renderers/screen_render.cpp +++ b/components/streams/src/renderers/screen_render.cpp @@ -33,10 +33,14 @@ ScreenRender::ScreenRender(ftl::render::Source *host, ftl::stream::Feed *feed) ); intrinsics_ = ftl::create<ftl::Configurable>(host_, "intrinsics"); - refresh_calibration_ = false; intrinsics_->onAny({"focal","width","height"}, [this]() { - refresh_calibration_ = true; + calibration_uptodate_.clear(); + }); + + renderer_->value("projection", 0); + renderer_->onAny({"projection"}, [this]() { + calibration_uptodate_.clear(); }); filter_ = nullptr; @@ -85,18 +89,17 @@ bool ScreenRender::retrieve(ftl::data::Frame &frame_out) { if (sets.size() > 0) { ftl::rgbd::Frame &rgbdframe = frame_out.cast<ftl::rgbd::Frame>(); - if (!frame_out.has(Channel::Calibration) || refresh_calibration_) { - refresh_calibration_ = false; + if (!frame_out.has(Channel::Calibration) || calibration_uptodate_.test_and_set()) { rgbdframe.setLeft() = ftl::rgbd::Camera::from(intrinsics_); - if (!frame_out.has(Channel::Capabilities)) { - auto &cap = frame_out.create<std::unordered_set<Capability>>(Channel::Capabilities); - cap.emplace(Capability::VIDEO); - cap.emplace(Capability::MOVABLE); - cap.emplace(Capability::ADJUSTABLE); - cap.emplace(Capability::VIRTUAL); - cap.emplace(Capability::LIVE); - } + auto &cap = frame_out.create<std::unordered_set<Capability>>(Channel::Capabilities); + cap.clear(); + cap.emplace(Capability::VIDEO); + cap.emplace(Capability::MOVABLE); + cap.emplace(Capability::ADJUSTABLE); + cap.emplace(Capability::VIRTUAL); + cap.emplace(Capability::LIVE); + if (renderer_->value("projection", 0) == int(ftl::rgbd::Projection::EQUIRECTANGULAR)) cap.emplace(Capability::EQUI_RECT); auto &meta = frame_out.create<std::map<std::string,std::string>>(Channel::MetaData); meta["name"] = host_->value("name", host_->getID()); diff --git a/components/streams/src/renderers/screen_render.hpp b/components/streams/src/renderers/screen_render.hpp index 4de8e9609..e8a5635a5 100644 --- a/components/streams/src/renderers/screen_render.hpp +++ b/components/streams/src/renderers/screen_render.hpp @@ -34,7 +34,7 @@ class ScreenRender : public ftl::render::BaseSourceImpl { ftl::Configurable *intrinsics_; uint32_t my_id_; ftl::operators::Graph *post_pipe_; - bool refresh_calibration_; + std::atomic_flag calibration_uptodate_; }; } -- GitLab