diff --git a/applications/vision/src/main.cpp b/applications/vision/src/main.cpp index 14be06f2c5f21f065a0e63a7d3b553b2a46dd289..e6d14d05707067233c2e98a93aa6c506c9e959e2 100644 --- a/applications/vision/src/main.cpp +++ b/applications/vision/src/main.cpp @@ -143,7 +143,14 @@ static void run(const string &file) { // Send RGB+Depth images for local rendering if (prgb.rows > 0) display.render(prgb, pdepth, source->getParameters()); - if (config["display"]["right"]) cv::imshow("Right: ", source->getRight()); + if (config["display"]["right"]) { + Mat rgbr = source->getRight().clone(); + cv::namedWindow("Right: ", cv::WINDOW_KEEPRATIO); + cv::line(rgbr, cv::Point(0, rgbr.rows/2), cv::Point(rgbr.cols-1, rgbr.rows/2), cv::Scalar(0,0,255), 1); + cv::line(rgbr, cv::Point(rgbr.cols/2, 0), cv::Point(rgbr.cols/2, rgbr.rows-1), cv::Scalar(0,0,255), 1); + cv::imshow("Right: ", rgbr); + } + display.wait(1); // Wait for both pipelines to complete diff --git a/cmake/git_version.cmake b/cmake/git_version.cmake index f44754522e8d88c22d05a59050f888b7e954a160..471ae6adcf9a38ff81793ebc26576dc24172b646 100644 --- a/cmake/git_version.cmake +++ b/cmake/git_version.cmake @@ -11,19 +11,19 @@ if (Git_FOUND) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" ftl_VERSION_MAJOR "${VERSION}") - string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" ftl_VERSION_MINOR "${VERSION}") - string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" ftl_VERSION_PATCH "${VERSION}") - string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-([0-9]+).*" "\\1" ftl_VERSION_COMMITS "${VERSION}") - string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+-(.*)" "\\1" ftl_VERSION_SHA1 "${VERSION}") - set(FTL_VERSION "\"${ftl_VERSION_MAJOR}.${ftl_VERSION_MINOR}.${ftl_VERSION_PATCH}\"") + #string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" ftl_VERSION_MAJOR "${VERSION}") + #string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" ftl_VERSION_MINOR "${VERSION}") + #string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" ftl_VERSION_PATCH "${VERSION}") + #string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-([0-9]+).*" "\\1" ftl_VERSION_COMMITS "${VERSION}") + #string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+-(.*)" "\\1" ftl_VERSION_SHA1 "${VERSION}") + #set(FTL_VERSION "\"${ftl_VERSION_MAJOR}.${ftl_VERSION_MINOR}.${ftl_VERSION_PATCH}\"") else() - - set(ftl_VERSION_MAJOR "0") - set(ftl_VERSION_MINOR "0") - set(ftl_VERSION_PATCH "0") - set(FTL_VERSION "\"${ftl_VERSION_MAJOR}.${ftl_VERSION_MINOR}.${ftl_VERSION_PATCH}\"") + set(VERSION "unknown") + #set(ftl_VERSION_MAJOR "0") + #set(ftl_VERSION_MINOR "0") + #set(ftl_VERSION_PATCH "0") + #set(FTL_VERSION "\"${ftl_VERSION_MAJOR}.${ftl_VERSION_MINOR}.${ftl_VERSION_PATCH}\"") message(WARNING "Version could not be obtained from git") diff --git a/components/common/cpp/src/config.cpp.in b/components/common/cpp/src/config.cpp.in index c0a62b67b1d3fcdcaf62e6c3802d3fa897b54229..15d1bbc11f7254a0eef6852d449a6110b6841607 100644 --- a/components/common/cpp/src/config.cpp.in +++ b/components/common/cpp/src/config.cpp.in @@ -1,10 +1,10 @@ #include <ftl/config.h> const char *FTL_VERSION_LONG = "@VERSION@"; -const char *FTL_VERSION = @FTL_VERSION@; -const int FTL_VERSION_MAJOR = @ftl_VERSION_MAJOR@; -const int FTL_VERSION_MINOR = @ftl_VERSION_MINOR@; -const int FTL_VERSION_PATCH = @ftl_VERSION_PATCH@; -const int FTL_VERSION_COMMITS = @ftl_VERSION_COMMITS@; -const char *FTL_VERSION_SHA1 = "@ftl_VERSION_SHA1@"; +const char *FTL_VERSION = ""; +const int FTL_VERSION_MAJOR = 0; +const int FTL_VERSION_MINOR = 0; +const int FTL_VERSION_PATCH = 0; +const int FTL_VERSION_COMMITS = 0; +const char *FTL_VERSION_SHA1 = ""; diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index a2674dcb08d101b73a4835dde91d31b97f6865e8..45b40da01e6d2fd6d720ca1f19fea6ceda6ac564 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -115,10 +115,15 @@ static bool mergeConfig(const string &path) { ifstream i; i.open(path); if (i.is_open()) { - json t; - i >> t; - config.merge_patch(t); - return true; + try { + json t; + i >> t; + config.merge_patch(t); + return true; + } catch (json::parse_error& e) { + LOG(ERROR) << "Parse error in loading config: " << e.what(); + return false; + } } else { return false; } diff --git a/components/renderers/cpp/src/display.cpp b/components/renderers/cpp/src/display.cpp index 8841c1ad0992dea0eff22b8f608f1953242eda6d..9760b4a7241da5e48924522058df855b04adff07 100644 --- a/components/renderers/cpp/src/display.cpp +++ b/components/renderers/cpp/src/display.cpp @@ -19,61 +19,63 @@ Display::Display(nlohmann::json &config, std::string name) : config_(config) { #endif // HAVE_VIZ #if defined HAVE_PCL - pclviz_ = pcl::visualization::PCLVisualizer::Ptr(new pcl::visualization::PCLVisualizer ("FTL Cloud: " + name)); - pclviz_->setBackgroundColor (255, 255, 255); - pclviz_->addCoordinateSystem (1.0); - pclviz_->setShowFPS(true); - pclviz_->initCameraParameters (); - - pclviz_->registerPointPickingCallback( - [](const pcl::visualization::PointPickingEvent& event, void* viewer_void) { - if (event.getPointIndex () == -1) return; - float x, y, z; - event.getPoint(x, y, z); - LOG(INFO) << "( " << x << ", " << y << ", " << z << ")"; - }, (void*) &pclviz_); - - pclviz_->registerKeyboardCallback ( - [](const pcl::visualization::KeyboardEvent &event, void* viewer_void) { - auto viewer = *static_cast<pcl::visualization::PCLVisualizer::Ptr*>(viewer_void); - pcl::visualization::Camera cam; - viewer->getCameraParameters(cam); - - Eigen::Vector3f pos(cam.pos[0], cam.pos[1], cam.pos[2]); - Eigen::Vector3f focal(cam.focal[0], cam.focal[1], cam.focal[2]); - Eigen::Vector3f dir = focal - pos; //.normalize(); - dir.normalize(); - - const float speed = 40.0f; - - if (event.getKeySym() == "Up") { - pos += speed*dir; - focal += speed*dir; - } else if (event.getKeySym() == "Down") { - pos -= speed*dir; - focal -= speed*dir; - } else if (event.getKeySym() == "Left") { - Eigen::Matrix3f m = Eigen::AngleAxisf(-0.5f*M_PI, Eigen::Vector3f::UnitY()).toRotationMatrix(); - dir = m*dir; - pos += speed*dir; - focal += speed*dir; - } else if (event.getKeySym() == "Right") { - Eigen::Matrix3f m = Eigen::AngleAxisf(0.5f*M_PI, Eigen::Vector3f::UnitY()).toRotationMatrix(); - dir = m*dir; - pos += speed*dir; - focal += speed*dir; - } - - - cam.pos[0] = pos[0]; - cam.pos[1] = pos[1]; - cam.pos[2] = pos[2]; - cam.focal[0] = focal[0]; - cam.focal[1] = focal[1]; - cam.focal[2] = focal[2]; - viewer->setCameraParameters(cam); - - }, (void*)&pclviz_); + if (config.value("points", false)) { + pclviz_ = pcl::visualization::PCLVisualizer::Ptr(new pcl::visualization::PCLVisualizer ("FTL Cloud: " + name)); + pclviz_->setBackgroundColor (255, 255, 255); + pclviz_->addCoordinateSystem (1.0); + pclviz_->setShowFPS(true); + pclviz_->initCameraParameters (); + + pclviz_->registerPointPickingCallback( + [](const pcl::visualization::PointPickingEvent& event, void* viewer_void) { + if (event.getPointIndex () == -1) return; + float x, y, z; + event.getPoint(x, y, z); + LOG(INFO) << "( " << x << ", " << y << ", " << z << ")"; + }, (void*) &pclviz_); + + pclviz_->registerKeyboardCallback ( + [](const pcl::visualization::KeyboardEvent &event, void* viewer_void) { + auto viewer = *static_cast<pcl::visualization::PCLVisualizer::Ptr*>(viewer_void); + pcl::visualization::Camera cam; + viewer->getCameraParameters(cam); + + Eigen::Vector3f pos(cam.pos[0], cam.pos[1], cam.pos[2]); + Eigen::Vector3f focal(cam.focal[0], cam.focal[1], cam.focal[2]); + Eigen::Vector3f dir = focal - pos; //.normalize(); + dir.normalize(); + + const float speed = 40.0f; + + if (event.getKeySym() == "Up") { + pos += speed*dir; + focal += speed*dir; + } else if (event.getKeySym() == "Down") { + pos -= speed*dir; + focal -= speed*dir; + } else if (event.getKeySym() == "Left") { + Eigen::Matrix3f m = Eigen::AngleAxisf(-0.5f*M_PI, Eigen::Vector3f::UnitY()).toRotationMatrix(); + dir = m*dir; + pos += speed*dir; + focal += speed*dir; + } else if (event.getKeySym() == "Right") { + Eigen::Matrix3f m = Eigen::AngleAxisf(0.5f*M_PI, Eigen::Vector3f::UnitY()).toRotationMatrix(); + dir = m*dir; + pos += speed*dir; + focal += speed*dir; + } + + + cam.pos[0] = pos[0]; + cam.pos[1] = pos[1]; + cam.pos[2] = pos[2]; + cam.focal[0] = focal[0]; + cam.focal[1] = focal[1]; + cam.focal[2] = focal[2]; + viewer->setCameraParameters(cam); + + }, (void*)&pclviz_); + } #endif // HAVE_PCL active_ = true; @@ -210,7 +212,7 @@ bool Display::render(const cv::Mat &rgb, const cv::Mat &depth, const ftl::rgbd:: #if defined HAVE_PCL bool Display::render(pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr pc) { pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(pc); - if (!pclviz_->updatePointCloud<pcl::PointXYZRGB> (pc, rgb, "reconstruction")) { + if (pclviz_ && !pclviz_->updatePointCloud<pcl::PointXYZRGB> (pc, rgb, "reconstruction")) { pclviz_->addPointCloud<pcl::PointXYZRGB> (pc, rgb, "reconstruction"); pclviz_->setCameraPosition(-878.0, -71.0, -2315.0, -0.1, -0.99, 0.068, 0.0, -1.0, 0.0); pclviz_->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "reconstruction"); @@ -242,7 +244,7 @@ bool Display::render(const cv::Mat &img, style_t s) { void Display::wait(int ms) { if (config_["points"]) { #if defined HAVE_PCL - pclviz_->spinOnce(20); + if (pclviz_) pclviz_->spinOnce(20); #elif defined HAVE_VIZ window_->spinOnce(1, true); #endif // HAVE_VIZ @@ -258,7 +260,7 @@ void Display::wait(int ms) { bool Display::active() const { #if defined HAVE_PCL - return active_ && !pclviz_->wasStopped(); + return active_ && (!pclviz_ || !pclviz_->wasStopped()); #elif defined HAVE_VIZ return active_ && !window_->wasStopped(); #else diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp index 24d1435cd67d14208992d74649f3334136488466..012dffa12947b067f0f09b83d605fa756b75b329 100644 --- a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp +++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp @@ -12,7 +12,9 @@ using cv::Mat; FixstarsSGM::FixstarsSGM(nlohmann::json &config) : Disparity(config) { ssgm_ = nullptr; use_filter_ = config.value("use_filter", false); - filter_ = cv::cuda::createDisparityBilateralFilter(max_disp_, config.value("filter_radius", 25), config.value("filter_iter", 1)); + // note: (max_disp_ << 4) libsgm subpixel accuracy. + // What is the impact in the filter? (possible artifacts) + filter_ = cv::cuda::createDisparityBilateralFilter(max_disp_ << 4, config.value("filter_radius", 25), config.value("filter_iter", 1)); } void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) { @@ -20,7 +22,7 @@ void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) { Mat right_disp; Mat lbw, rbw; - cv::cvtColor(l, lbw, cv::COLOR_BGR2GRAY); + cv::cvtColor(l, lbw, cv::COLOR_BGR2GRAY); cv::cvtColor(r, rbw, cv::COLOR_BGR2GRAY); if (!ssgm_) { @@ -54,4 +56,4 @@ void FixstarsSGM::compute(const cv::Mat &l, const cv::Mat &r, cv::Mat &disp) { } disp.convertTo(disp, CV_32F, 1.0f/16.0f); -} \ No newline at end of file +}