diff --git a/applications/gui/src/screen.cpp b/applications/gui/src/screen.cpp index a9f4cc023265ba427a0be451ee3337fe834528bc..3b2aae1aaff8d00daa6c80c3d03d8ffb47423783 100644 --- a/applications/gui/src/screen.cpp +++ b/applications/gui/src/screen.cpp @@ -48,11 +48,13 @@ namespace { constexpr char const *const defaultImageViewFragmentShader = R"(#version 330 - uniform sampler2D image; + uniform sampler2D image1; + uniform sampler2D image2; + uniform float blendAmount; out vec4 color; in vec2 uv; void main() { - color = texture(image, uv); + color = blendAmount * texture(image1, uv) + (1.0 - blendAmount) * texture(image2, uv); })"; } @@ -457,8 +459,12 @@ void ftl::gui::Screen::draw(NVGcontext *ctx) { size().x() * r, size().y() * r);*/ mShader.bind(); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, mImageID); - mShader.setUniform("image", 0); + glBindTexture(GL_TEXTURE_2D, leftEye_); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, (camera_->getRight().isValid()) ? rightEye_ : leftEye_); + mShader.setUniform("image1", 0); + mShader.setUniform("image2", 1); + mShader.setUniform("blendAmount", (camera_->getChannel() != ftl::codecs::Channel::Left) ? root_->value("blending", 0.5f) : 1.0f); mShader.setUniform("scaleFactor", scaleFactor); mShader.setUniform("position", imagePosition); mShader.drawIndexed(GL_TRIANGLES, 0, 2); diff --git a/components/operators/CMakeLists.txt b/components/operators/CMakeLists.txt index a0a38590eb494a3c6268dd725c9ab3c0f9b64edf..76e67de0209533bead6c6b065eb197e4eba3a858 100644 --- a/components/operators/CMakeLists.txt +++ b/components/operators/CMakeLists.txt @@ -8,9 +8,6 @@ set(OPERSRC src/normals.cpp src/filling.cpp src/filling.cu - src/nvopticalflow.cpp - src/disparity/optflow_smoothing.cu - src/disparity/optflow_smoothing.cpp src/disparity/disp2depth.cu src/disparity/disparity_to_depth.cpp src/disparity/fixstars_sgm.cpp @@ -20,7 +17,9 @@ set(OPERSRC ) if (HAVE_OPTFLOW) - list(APPEND OPERSRC src/nvopticalflow.cpp) + list(APPEND OPERSRC src/nvopticalflow.cpp + src/disparity/optflow_smoothing.cu + src/disparity/optflow_smoothing.cpp) endif() add_library(ftloperators ${OPERSRC}) diff --git a/components/operators/include/ftl/operators/disparity.hpp b/components/operators/include/ftl/operators/disparity.hpp index 07b620280ef10b05a544727a1d73d5b311720684..fa280871d15912a2eee8c384f0535ebbdfdcbc47 100644 --- a/components/operators/include/ftl/operators/disparity.hpp +++ b/components/operators/include/ftl/operators/disparity.hpp @@ -1,7 +1,11 @@ #pragma once +#include <ftl/config.h> #include <ftl/operators/operator.hpp> + +#ifdef HAVE_OPTFLOW #include <opencv2/cudaoptflow.hpp> +#endif #include <libsgm.h> @@ -73,6 +77,7 @@ class DisparityToDepth : public ftl::operators::Operator { /* * Optical flow smoothing for depth */ +#ifdef HAVE_OPTFLOW class OpticalFlowTemporalSmoothing : public ftl::operators::Operator { public: explicit OpticalFlowTemporalSmoothing(ftl::Configurable*); @@ -91,6 +96,7 @@ class OpticalFlowTemporalSmoothing : public ftl::operators::Operator { int n_max_; float threshold_; }; +#endif } } diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp index 0b0cd15a1a584e6811b6483fe36de7bde5293ce3..003984d8a5fdc9c4e799f77882d9bd13456c91be 100644 --- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp @@ -126,7 +126,10 @@ void StereoVideoSource::init(const string &file) { pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity"); pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm"); + + #ifdef HAVE_OPTFLOW pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter"); + #endif pipeline_depth_->append<ftl::operators::DisparityBilateralFilter>("bilateral_filter"); pipeline_depth_->append<ftl::operators::DisparityToDepth>("calculate_depth");