From 27eb2bd1f161107b2080c9ec8f840cb8588e268b Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Tue, 21 Jul 2020 13:17:08 +0300
Subject: [PATCH] Allow for missing depth height to maintain aspect

---
 components/rgbd-sources/src/sources/stereovideo/opencv.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
index df3a9999d..aefae673e 100644
--- a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
@@ -138,7 +138,8 @@ OpenCVDevice::OpenCVDevice(nlohmann::json &config, bool stereo)
 	height_ = frame.rows;
 
 	dwidth_ = value("depth_width", width_);
-	dheight_ = value("depth_height", height_);
+	float aspect = float(height_) / float(width_);
+	dheight_ = value("depth_height", std::min(uint32_t(aspect*float(dwidth_)), height_)) & 0xFFFe;
 
 	// Allocate page locked host memory for fast GPU transfer
 	left_hm_ = cv::cuda::HostMem(dheight_, dwidth_, CV_8UC4);
-- 
GitLab