diff --git a/reconstruct/src/main.cpp b/reconstruct/src/main.cpp index 61049ec33f73c081961fe8d5f7de74f6929b789b..1b77929d0c4e9b9e8049d3ddff48f2189aa2c0e2 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 bb7d5444cbd7d2fffcc23cea6b994a314f20de50..c60d5fc052bf2f4784698a2d123f48b6c77ef1a4 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 6f70787ed1a2494903837aacf96ea7ec42de15c2..acedcbe37df86adf66099b14477898a9fd7c9f6a 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