From f4e3a3656ab540934ba2078f2b76eccd10f839be Mon Sep 17 00:00:00 2001
From: Sebastian Hahta <joseha@utu.fi>
Date: Fri, 13 Sep 2019 15:20:36 +0300
Subject: [PATCH] fix build

---
 components/rgbd-sources/include/ftl/offilter.hpp   |  3 +--
 components/rgbd-sources/src/algorithms/offilter.cu | 13 +++++--------
 components/rgbd-sources/src/offilter.cpp           |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/components/rgbd-sources/include/ftl/offilter.hpp b/components/rgbd-sources/include/ftl/offilter.hpp
index 194ee20fb..c5e7a9cf7 100644
--- a/components/rgbd-sources/include/ftl/offilter.hpp
+++ b/components/rgbd-sources/include/ftl/offilter.hpp
@@ -13,12 +13,11 @@ namespace rgbd {
 
 class OFDisparityFilter {
 public:
-	OFDisparityFilter() : n_max_(0), threshold_(0.0), size_(0, 0) {} // TODO: invalid state
+	OFDisparityFilter() : n_max_(0), threshold_(0.0) {}
 	OFDisparityFilter(cv::Size size, int n_frames, float threshold);
 	void filter(ftl::rgbd::Frame &frame, cv::cuda::Stream &stream);
 
 private:
-	int n_;
 	int n_max_;
 	float threshold_;
 
diff --git a/components/rgbd-sources/src/algorithms/offilter.cu b/components/rgbd-sources/src/algorithms/offilter.cu
index 546f94c11..6feee5ae1 100644
--- a/components/rgbd-sources/src/algorithms/offilter.cu
+++ b/components/rgbd-sources/src/algorithms/offilter.cu
@@ -21,19 +21,16 @@ __global__ void temporal_median_filter_kernel(
 	cv::cuda::PtrStepSz<int16_t> optflow,
 	cv::cuda::PtrStepSz<float> history,
 	int n_max,
-	int16_t threshold // fixed point 10.5
-	uint granularity  // 4 for Turing
+	int16_t threshold, // fixed point 10.5
+	float granularity  // 4 for Turing
 )
 {
 	float sorted[max_history]; // TODO: dynamic shared memory
 	for (STRIDE_Y(y, disp.rows)) {
 	for (STRIDE_X(x, disp.cols)) {
 
-		int flowx = optflow(y, 2 * x);
-		int flowy = optflow(y, 2 * x + 1);
-
 		int flowx = optflow(round(y / granularity), 2 * round(x / granularity));
-		int flowy = optflow(round(y/ granularity), 2 * round(x / granularity) + 1);
+		int flowy = optflow(round(y / granularity), 2 * round(x / granularity) + 1);
 
 		if ((abs(flowx) + abs(flowy)) > threshold)
 		{
@@ -83,8 +80,8 @@ void optflow_filter(cv::cuda::GpuMat &disp, const cv::cuda::GpuMat &optflow,
 	// TODO: dynamic shared memory
 	temporal_median_filter_kernel<<<grid, threads, 0, cv::cuda::StreamAccessor::getStream(stream)>>>
 		(	disp, optflow, history, n,
-			round(threshold * (1 << 5)) // TODO: documentation; 10.5 format
-			4,							// TODO: (4 pixels granularity for Turing)
+			round(threshold * (1 << 5)),	// TODO: documentation; 10.5 format
+			4								// TODO: (4 pixels granularity for Turing)
 		);
 
 	cudaSafeCall(cudaGetLastError());
diff --git a/components/rgbd-sources/src/offilter.cpp b/components/rgbd-sources/src/offilter.cpp
index 2fb6d1623..bdf6f40a5 100644
--- a/components/rgbd-sources/src/offilter.cpp
+++ b/components/rgbd-sources/src/offilter.cpp
@@ -15,7 +15,7 @@ using std::vector;
 template<typename T> static bool inline isValidDisparity(T d) { return (0.0 < d) && (d < 256.0); } // TODO
 
 OFDisparityFilter::OFDisparityFilter(Size size, int n_frames, float threshold) :
-	n_(0), n_max_(n_frames + 1), threshold_(threshold)
+	n_max_(n_frames + 1), threshold_(threshold)
 {
 	CHECK((n_max_ > 1) && (n_max_ >= 32)) << "History length must be between 0 and 31!";
 	disp_old_ = cv::cuda::GpuMat(cv::Size(size.width * n_max_, size.height), CV_32FC1);
-- 
GitLab