diff --git a/renderer/cpp/include/ftl/display.hpp b/renderer/cpp/include/ftl/display.hpp index c6d63ca4f8685c1c0cfa751c2fb87b5b10fb412e..e7642b8ac17869379946da4c2595314ab14d85f3 100644 --- a/renderer/cpp/include/ftl/display.hpp +++ b/renderer/cpp/include/ftl/display.hpp @@ -17,6 +17,11 @@ namespace ftl { * Multiple local display options for disparity or point clouds. */ class Display { + public: + enum style_t { + STYLE_NORMAL, STYLE_DISPARITY, STYLE_DEPTH + }; + public: explicit Display(nlohmann::json &config); ~Display(); @@ -25,6 +30,8 @@ class Display { bool render(const cv::Mat &rgb, const cv::Mat &depth); + bool render(const cv::Mat &img, style_t s=STYLE_NORMAL); + bool active() const; void wait(int ms); diff --git a/renderer/cpp/src/display.cpp b/renderer/cpp/src/display.cpp index 7ee8efe3c7a5099656bd89bc680049a0e8949f82..aa5449dfd7d73de8feed41f14721edb08c860d3d 100644 --- a/renderer/cpp/src/display.cpp +++ b/renderer/cpp/src/display.cpp @@ -84,6 +84,27 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth) { return true; } +bool Display::render(const cv::Mat &img, style_t s) { + if (s == STYLE_NORMAL) { + cv::imshow("Image", img); + } else if (s = STYLE_DISPARITY) { + Mat idepth; + + if ((bool)config_["flip_vert"]) { + cv::flip(img, idepth, 0); + } else { + idepth = img; + } + + idepth.convertTo(idepth, CV_8U, 255.0f / 256.0f); + + applyColorMap(idepth, idepth, cv::COLORMAP_JET); + cv::imshow("Disparity", idepth); + } + + return true; +} + void Display::wait(int ms) { if (config_["points"] && q_.rows != 0) { #if defined HAVE_VIZ