From 4559b1fa34b736657ca311678735215b9982826a Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Wed, 15 May 2019 10:52:07 +0300 Subject: [PATCH] Remove Q from Display --- reconstruct/src/main.cpp | 7 ++----- renderer/cpp/include/ftl/display.hpp | 5 +---- renderer/cpp/src/display.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/reconstruct/src/main.cpp b/reconstruct/src/main.cpp index 61049ec33..1b77929d0 100644 --- a/reconstruct/src/main.cpp +++ b/reconstruct/src/main.cpp @@ -149,10 +149,6 @@ static void run() { net.subscribe(src, [&in](const vector<unsigned char> &jpg, const vector<unsigned char> &d) { in.recv(jpg, d); }); - - // todo: Display should only need processed input, depth calculation etc. - // should happen somewhere else. - display.setCalibration(in.getQ()); } int active = displays.size(); @@ -172,9 +168,10 @@ static void run() { auto lk = source.lock(); Mat rgb = source.getRGB(); Mat disparity = source.getDisparity(); + Mat q = source.getQ(); lk.unlock(); - display.render(rgb, disparity); + display.render(rgb, disparity, q); display.wait(50); } diff --git a/renderer/cpp/include/ftl/display.hpp b/renderer/cpp/include/ftl/display.hpp index bb7d5444c..c60d5fc05 100644 --- a/renderer/cpp/include/ftl/display.hpp +++ b/renderer/cpp/include/ftl/display.hpp @@ -33,9 +33,7 @@ class Display { explicit Display(nlohmann::json &config, std::string name); ~Display(); - void setCalibration(const cv::Mat &q) { q_ = q; } - - bool render(const cv::Mat &rgb, const cv::Mat &depth); + bool render(const cv::Mat &rgb, const cv::Mat &depth, const cv::Mat &q); #if defined HAVE_PCL bool render(pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr); @@ -47,7 +45,6 @@ class Display { void wait(int ms); private: - cv::Mat q_; nlohmann::json config_; #if defined HAVE_VIZ diff --git a/renderer/cpp/src/display.cpp b/renderer/cpp/src/display.cpp index 6f70787ed..acedcbe37 100644 --- a/renderer/cpp/src/display.cpp +++ b/renderer/cpp/src/display.cpp @@ -77,13 +77,13 @@ Display::~Display() { #endif // HAVE_VIZ } -bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { +bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const cv::Mat &q) { Mat idepth; - if (config_["points"] && q_.rows != 0) { + if (config_["points"] && q.rows != 0) { #if defined HAVE_PCL cv::Mat_<cv::Vec3f> XYZ(depth.rows, depth.cols); // Output point cloud - reprojectImageTo3D(depth, XYZ, q_, false); + reprojectImageTo3D(depth, XYZ, q, false); auto pc = ftl::utility::matToPointXYZ(XYZ, rgb); pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(pc); @@ -96,7 +96,7 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { //cv::Mat Q_32F; //calibrate_.getQ().convertTo(Q_32F, CV_32F); cv::Mat_<cv::Vec3f> XYZ(depth.rows, depth.cols); // Output point cloud - reprojectImageTo3D(depth+20.0f, XYZ, q_, true); + reprojectImageTo3D(depth+20.0f, XYZ, q, true); // Remove all invalid pixels from point cloud XYZ.setTo(Vec3f(NAN, NAN, NAN), depth == 0.0f); @@ -181,7 +181,7 @@ bool Display::render(const cv::Mat &img, style_t s) { } void Display::wait(int ms) { - if (config_["points"] && q_.rows != 0) { + if (config_["points"]) { #if defined HAVE_PCL pclviz_->spinOnce(20); #elif defined HAVE_VIZ -- GitLab