diff --git a/applications/reconstruct/include/ftl/registration.hpp b/applications/reconstruct/include/ftl/registration.hpp index be5154f30f67e56c556410b3e3df3766e64595e1..20f8eac6ab9ad751bc4021d6f5469d6480affb2d 100644 --- a/applications/reconstruct/include/ftl/registration.hpp +++ b/applications/reconstruct/include/ftl/registration.hpp @@ -14,11 +14,11 @@ namespace ftl { namespace registration { -void to_json(nlohmann::json &json, std::map<std::string, Eigen::Matrix4f> &transformations); -void from_json(nlohmann::json &json, std::map<std::string, Eigen::Matrix4f> &transformations); +void to_json(nlohmann::json &json, std::map<std::string, Eigen::Matrix4d> &transformations); +void from_json(nlohmann::json &json, std::map<std::string, Eigen::Matrix4d> &transformations); -bool loadTransformations(const std::string &path, std::map<std::string, Eigen::Matrix4f> &data); -bool saveTransformations(const std::string &path, std::map<std::string, Eigen::Matrix4f> &data); +bool loadTransformations(const std::string &path, std::map<std::string, Eigen::Matrix4d> &data); +bool saveTransformations(const std::string &path, std::map<std::string, Eigen::Matrix4d> &data); /** @brief Find transformation matrix for transforming clouds_source to clouds_target. * Assumes that corresponding points in clouds_source[i] and clouds_target[i] have same indices. diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index d1c2c095a6c9ae928416b5216694fb07be8726f3..f3a29a9fd329275d822c8a547190c4762b7a855f 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -102,13 +102,13 @@ static void run(ftl::Configurable *root) { if (!merge) { LOG(WARNING) << "Input merging not configured, using only first input in configuration"; inputs = { inputs[0] }; - inputs[0].source->setPose(Eigen::Matrix4f::Identity()); + inputs[0].source->setPose(Eigen::Matrix4d::Identity()); } if (inputs.size() > 1) { - std::map<std::string, Eigen::Matrix4f> transformations; + std::map<std::string, Eigen::Matrix4d> transformations; - if ((*merge)["register"]) { + /*if ((*merge)["register"]) { LOG(INFO) << "Registration requested"; ftl::registration::Registration *reg = ftl::registration::ChessboardRegistration::create(*merge); @@ -129,14 +129,14 @@ static void run(ftl::Configurable *root) { free(reg); } - else { + else {*/ if (loadTransformations(string(FTL_LOCAL_CONFIG_ROOT) + "/registration.json", transformations)) { LOG(INFO) << "Loaded camera trasformations from file"; } else { LOG(ERROR) << "Error loading camera transformations from file"; } - } + //} for (auto &input : inputs) { string uri = input.source->getURI(); @@ -146,7 +146,7 @@ static void run(ftl::Configurable *root) { LOG(WARNING) << "Using only first configured source"; // TODO: use target source if configured and found inputs = { inputs[0] }; - inputs[0].source->setPose(Eigen::Matrix4f::Identity()); + inputs[0].source->setPose(Eigen::Matrix4d::Identity()); break; } input.source->setPose(T->second); @@ -244,7 +244,8 @@ static void run(ftl::Configurable *root) { // Send to GPU and merge view into scene inputs[i].gpu.updateParams(inputs[i].params); inputs[i].gpu.updateData(depth, rgba); - scene->integrate(inputs[i].source->getPose(), inputs[i].gpu, inputs[i].params, nullptr); + // TODO(Nick): Use double pose + scene->integrate(inputs[i].source->getPose().cast<float>(), inputs[i].gpu, inputs[i].params, nullptr); } } else { active = 1; diff --git a/applications/reconstruct/src/registration.cpp b/applications/reconstruct/src/registration.cpp index ec27f43ba89cb1bdf71f57c5ba74c29ac4e25999..ad8c1e8cd71c442f10c18f0611d6b9fcce5ecc2c 100644 --- a/applications/reconstruct/src/registration.cpp +++ b/applications/reconstruct/src/registration.cpp @@ -40,17 +40,18 @@ using pcl::PointXYZRGB; using cv::Mat; using Eigen::Matrix4f; +using Eigen::Matrix4d; -void from_json(nlohmann::json &json, map<string, Matrix4f> &transformations) { +void from_json(nlohmann::json &json, map<string, Matrix4d> &transformations) { for (auto it = json.begin(); it != json.end(); ++it) { - Eigen::Matrix4f m; + Eigen::Matrix4d m; auto data = m.data(); for(size_t i = 0; i < 16; i++) { data[i] = it.value()[i]; } transformations[it.key()] = m; } } -void to_json(nlohmann::json &json, map<string, Matrix4f> &transformations) { +void to_json(nlohmann::json &json, map<string, Matrix4d> &transformations) { for (auto &item : transformations) { auto val = nlohmann::json::array(); for(size_t i = 0; i < 16; i++) { val.push_back((float) item.second.data()[i]); } @@ -58,7 +59,7 @@ void to_json(nlohmann::json &json, map<string, Matrix4f> &transformations) { } } -bool loadTransformations(const string &path, map<string, Matrix4f> &data) { +bool loadTransformations(const string &path, map<string, Matrix4d> &data) { std::ifstream file(path); if (!file.is_open()) { LOG(ERROR) << "Error loading transformations from file " << path; @@ -71,7 +72,7 @@ bool loadTransformations(const string &path, map<string, Matrix4f> &data) { return true; } -bool saveTransformations(const string &path, map<string, Matrix4f> &data) { +bool saveTransformations(const string &path, map<string, Matrix4d> &data) { nlohmann::json data_json; to_json(data_json, data); std::ofstream file(path); diff --git a/applications/registration/src/correspondances.cpp b/applications/registration/src/correspondances.cpp index b385800a25bd40e1ef7225d146b44eff2d691b38..5292905e9e7e44dee329e1d9b7ee60d557b2d4c7 100644 --- a/applications/registration/src/correspondances.cpp +++ b/applications/registration/src/correspondances.cpp @@ -267,7 +267,7 @@ double Correspondances::icp() { pcl::transformPointCloud(*src_cloud, *tsrc_cloud, transform_); - pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp; + pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ, double> icp; icp.setInputSource(tsrc_cloud); icp.setInputTarget(targ_cloud); icp.align(*final_cloud); @@ -399,7 +399,7 @@ double Correspondances::findBestSubset(Eigen::Matrix4d &tr, int K, int N) { //return score; } -Eigen::Matrix4f Correspondances::transform() { +Eigen::Matrix4d Correspondances::transform() { if (!uptodate_) estimateTransform(transform_); return (parent_) ? parent_->transform() * transform_ : transform_; }