Skip to content
Snippets Groups Projects
Commit 7dae3c7d authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Support channel blending

parent 208d97d0
No related branches found
No related tags found
No related merge requests found
...@@ -48,11 +48,13 @@ namespace { ...@@ -48,11 +48,13 @@ namespace {
constexpr char const *const defaultImageViewFragmentShader = constexpr char const *const defaultImageViewFragmentShader =
R"(#version 330 R"(#version 330
uniform sampler2D image; uniform sampler2D image1;
uniform sampler2D image2;
uniform float blendAmount;
out vec4 color; out vec4 color;
in vec2 uv; in vec2 uv;
void main() { 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) { ...@@ -457,8 +459,12 @@ void ftl::gui::Screen::draw(NVGcontext *ctx) {
size().x() * r, size().y() * r);*/ size().x() * r, size().y() * r);*/
mShader.bind(); mShader.bind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mImageID); glBindTexture(GL_TEXTURE_2D, leftEye_);
mShader.setUniform("image", 0); 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("scaleFactor", scaleFactor);
mShader.setUniform("position", imagePosition); mShader.setUniform("position", imagePosition);
mShader.drawIndexed(GL_TRIANGLES, 0, 2); mShader.drawIndexed(GL_TRIANGLES, 0, 2);
......
...@@ -8,9 +8,6 @@ set(OPERSRC ...@@ -8,9 +8,6 @@ set(OPERSRC
src/normals.cpp src/normals.cpp
src/filling.cpp src/filling.cpp
src/filling.cu src/filling.cu
src/nvopticalflow.cpp
src/disparity/optflow_smoothing.cu
src/disparity/optflow_smoothing.cpp
src/disparity/disp2depth.cu src/disparity/disp2depth.cu
src/disparity/disparity_to_depth.cpp src/disparity/disparity_to_depth.cpp
src/disparity/fixstars_sgm.cpp src/disparity/fixstars_sgm.cpp
...@@ -20,7 +17,9 @@ set(OPERSRC ...@@ -20,7 +17,9 @@ set(OPERSRC
) )
if (HAVE_OPTFLOW) 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() endif()
add_library(ftloperators ${OPERSRC}) add_library(ftloperators ${OPERSRC})
......
#pragma once #pragma once
#include <ftl/config.h>
#include <ftl/operators/operator.hpp> #include <ftl/operators/operator.hpp>
#ifdef HAVE_OPTFLOW
#include <opencv2/cudaoptflow.hpp> #include <opencv2/cudaoptflow.hpp>
#endif
#include <libsgm.h> #include <libsgm.h>
...@@ -73,6 +77,7 @@ class DisparityToDepth : public ftl::operators::Operator { ...@@ -73,6 +77,7 @@ class DisparityToDepth : public ftl::operators::Operator {
/* /*
* Optical flow smoothing for depth * Optical flow smoothing for depth
*/ */
#ifdef HAVE_OPTFLOW
class OpticalFlowTemporalSmoothing : public ftl::operators::Operator { class OpticalFlowTemporalSmoothing : public ftl::operators::Operator {
public: public:
explicit OpticalFlowTemporalSmoothing(ftl::Configurable*); explicit OpticalFlowTemporalSmoothing(ftl::Configurable*);
...@@ -91,6 +96,7 @@ class OpticalFlowTemporalSmoothing : public ftl::operators::Operator { ...@@ -91,6 +96,7 @@ class OpticalFlowTemporalSmoothing : public ftl::operators::Operator {
int n_max_; int n_max_;
float threshold_; float threshold_;
}; };
#endif
} }
} }
...@@ -126,7 +126,10 @@ void StereoVideoSource::init(const string &file) { ...@@ -126,7 +126,10 @@ void StereoVideoSource::init(const string &file) {
pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity"); pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity");
pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm"); pipeline_depth_->append<ftl::operators::FixstarsSGM>("algorithm");
#ifdef HAVE_OPTFLOW
pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter"); pipeline_depth_->append<ftl::operators::OpticalFlowTemporalSmoothing>("optflow_filter");
#endif
pipeline_depth_->append<ftl::operators::DisparityBilateralFilter>("bilateral_filter"); pipeline_depth_->append<ftl::operators::DisparityBilateralFilter>("bilateral_filter");
pipeline_depth_->append<ftl::operators::DisparityToDepth>("calculate_depth"); pipeline_depth_->append<ftl::operators::DisparityToDepth>("calculate_depth");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment