From e2f8c986dc8bbcef092b4ed30570f9e3bbf98b9f Mon Sep 17 00:00:00 2001
From: Sebastian Hahta <joseha@utu.fi>
Date: Fri, 29 Nov 2019 14:07:48 +0200
Subject: [PATCH] camera params to depth resolution

---
 components/rgbd-sources/src/source.cpp        | 16 -------
 .../src/sources/stereovideo/stereovideo.cpp   | 45 +++++++++----------
 2 files changed, 22 insertions(+), 39 deletions(-)

diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp
index 13cdd5487..c757ddc84 100644
--- a/components/rgbd-sources/src/source.cpp
+++ b/components/rgbd-sources/src/source.cpp
@@ -308,22 +308,6 @@ void Source::notify(int64_t ts, cv::cuda::GpuMat &c1, cv::cuda::GpuMat &c2) {
 		impl_->params_ = impl_->params_.scaled(max_width, max_height);
 	}
 
-	// Should channel 1 be scaled?
-	if (c1.cols < max_width || c1.rows < max_height) {
-		LOG(WARNING) << "Resizing on GPU";
-		cv::cuda::resize(c1, c1, cv::Size(max_width, max_height));
-	}
-
-	// Should channel 2 be scaled?
-	if (!c2.empty() && (c2.cols < max_width || c2.rows < max_height)) {
-		LOG(WARNING) << "Resizing on GPU";
-		if (c2.type() == CV_32F) {
-			cv::cuda::resize(c2, c2, cv::Size(max_width, max_height), 0.0, 0.0, cv::INTER_NEAREST);
-		} else {
-			cv::cuda::resize(c2, c2, cv::Size(max_width, max_height));
-		}
-	}
-
 	if (callback_) callback_(ts, c1, c2);
 }
 
diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
index b4f365101..c2ecf8ff1 100644
--- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
@@ -71,7 +71,28 @@ void StereoVideoSource::init(const string &file) {
 	color_size_ = cv::Size(lsrc_->width(), lsrc_->height());
 	frames_ = std::vector<Frame>(2);
 
-	calib_ = ftl::create<Calibrate>(host_, "calibration", color_size_, stream_);
+	pipeline_input_ = ftl::config::create<ftl::operators::Graph>(host_, "input");
+	#ifdef HAVE_OPTFLOW
+	pipeline_input_->append<ftl::operators::NVOpticalFlow>("optflow");
+	#endif
+
+	pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity");
+	depth_size_ = cv::Size(	pipeline_depth_->value("width", color_size_.width),
+							pipeline_depth_->value("height", color_size_.height));
+
+	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");
+	pipeline_depth_->append<ftl::operators::ColourChannels>("colour");  // Convert BGR to BGRA
+	pipeline_depth_->append<ftl::operators::Normals>("normals");  // Estimate surface normals
+	pipeline_depth_->append<ftl::operators::CrossSupport>("cross");
+	pipeline_depth_->append<ftl::operators::DiscontinuityMask>("discontinuity_mask");
+	pipeline_depth_->append<ftl::operators::AggreMLS>("mls");  // Perform MLS (using smoothing channel)
+
+	calib_ = ftl::create<Calibrate>(host_, "calibration", depth_size_, stream_);
 	if (!calib_->isCalibrated()) LOG(WARNING) << "Cameras are not calibrated!";
 
 	// Generate camera parameters from camera matrix
@@ -125,28 +146,6 @@ void StereoVideoSource::init(const string &file) {
 	mask_l_gpu.download(mask_l);
 	mask_l_ = (mask_l == 0);
 	
-	pipeline_input_ = ftl::config::create<ftl::operators::Graph>(host_, "input");
-	#ifdef HAVE_OPTFLOW
-	pipeline_input_->append<ftl::operators::NVOpticalFlow>("optflow");
-	#endif
-
-	pipeline_depth_ = ftl::config::create<ftl::operators::Graph>(host_, "disparity");
-
-	depth_size_ = cv::Size(	pipeline_depth_->value("width", color_size_.width),
-							pipeline_depth_->value("height", color_size_.height));
-
-	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");
-	pipeline_depth_->append<ftl::operators::ColourChannels>("colour");  // Convert BGR to BGRA
-	pipeline_depth_->append<ftl::operators::Normals>("normals");  // Estimate surface normals
-	pipeline_depth_->append<ftl::operators::CrossSupport>("cross");
-	pipeline_depth_->append<ftl::operators::DiscontinuityMask>("discontinuity_mask");
-	pipeline_depth_->append<ftl::operators::AggreMLS>("mls");  // Perform MLS (using smoothing channel)
-
 	LOG(INFO) << "StereoVideo source ready...";
 	ready_ = true;
 }
-- 
GitLab