-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2892 from savuor:posegraph_no_ceres
Pose Graph rewritten without Ceres * Works well on g2o dataset, cumulative: 1. Pose3d done w/o Eigen types; 2. PoseGraph nodes vector<Node> -> map<int, Node> 3. Eigen is not used in cost function or parametrization 4. Cost function debugged & fixed (original one was wrong), rewritten from Automatic to Analytic * g2o dataset reading added to PoseGraph * sparse solver fixes from DynaFu draft * Eigen cost function and parametrization removed + g2o reading fixed * refactored: pose error, pose graph edge, pose graph node * sparse solve: templated * MyOptimize(): 1st version * several fixes and TODOs for future * sparse block matrix: val functions, template type * works at Ceres quality (cleanup needed) * MyOptimize() is set to default optimizer * Ceres thrown away, PoseGraph class and header/source code reorganized * pose, node, edge -> nested for PoseGraph * warnings fixed * jacobiScaling disabled for better performance + minors * trailing whitespace fixed * more warnings fixed * message added: Eigen is required for build + minors * trying to fix warning * try to fix "unreachable code" warning * trying to fix unreachable code, pt.3 * trying to fix unreachable code, pt. 5 * trying to fix unreachable code, pt. the worst + minors * try to fix unreachable code, pt. the ugliest * trying to fix unreachable code, pt. the grumpiest * cout -> CV_LOG_INFO * quat matrix functions moved outside cv and kinfu namespaces * unused function fix * pose graph made public (but in detail namespace) + test for pose graph * minor: prints * Pose Graph interface settled * Pose graph interface and its use updated * cos -> std::cos * cout -> CV_LOG_INFO * pose graph interface updated: implementation * Pose Graph Node and Edge: extra fields dropped * more minor refactor-like fixes * return and finish condition fixed * more updates to test * test disabled for Debug builds because 400 sec is too much * whitespace * Disable pose graph test if there's no Eigen * more unused vars * fixing unused function warning * less includes * "verbose" removed * write obj to file only when debug level is raised * License + include guard * skip test using tags and SkipTestException * suppress "unused function" warning * minor
- Loading branch information
Showing
12 changed files
with
1,177 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
set(the_description "RGBD algorithms") | ||
|
||
find_package(Ceres QUIET) | ||
ocv_define_module(rgbd opencv_core opencv_calib3d opencv_imgproc OPTIONAL opencv_viz WRAP python) | ||
|
||
if(Ceres_FOUND) | ||
ocv_target_compile_definitions(${the_module} PUBLIC CERES_FOUND) | ||
ocv_target_link_libraries(${the_module} ${CERES_LIBRARIES}) | ||
if(Ceres_VERSION VERSION_LESS 2.0.0) | ||
ocv_include_directories("${CERES_INCLUDE_DIRS}") | ||
endif() | ||
add_definitions(/DGLOG_NO_ABBREVIATED_SEVERITIES) # avoid ERROR macro conflict in glog (ceres dependency) | ||
else() | ||
message(STATUS "rgbd: CERES support is disabled. Ceres Solver is Required for Posegraph optimization") | ||
if(NOT HAVE_EIGEN) | ||
message(STATUS "rgbd: Eigen support is disabled. Eigen is Required for Posegraph optimization") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// This file is part of OpenCV project. | ||
// It is subject to the license terms in the LICENSE file found in the top-level directory | ||
// of this distribution and at http://opencv.org/license.html | ||
|
||
#ifndef OPENCV_RGBD_POSE_GRAPH_HPP | ||
#define OPENCV_RGBD_POSE_GRAPH_HPP | ||
|
||
#include "opencv2/core/affine.hpp" | ||
#include "opencv2/core/quaternion.hpp" | ||
|
||
namespace cv | ||
{ | ||
namespace kinfu | ||
{ | ||
namespace detail | ||
{ | ||
|
||
// ATTENTION! This class is used internally in Large KinFu. | ||
// It has been pushed to publicly available headers for tests only. | ||
// Source compatibility of this API is not guaranteed in the future. | ||
|
||
// This class provides tools to solve so-called pose graph problem often arisen in SLAM problems | ||
// The pose graph format, cost function and optimization techniques | ||
// repeat the ones used in Ceres 3D Pose Graph Optimization: | ||
// http://ceres-solver.org/nnls_tutorial.html#other-examples, pose_graph_3d.cc bullet | ||
class CV_EXPORTS_W PoseGraph | ||
{ | ||
public: | ||
static Ptr<PoseGraph> create(); | ||
virtual ~PoseGraph(); | ||
|
||
// Node may have any id >= 0 | ||
virtual void addNode(size_t _nodeId, const Affine3d& _pose, bool fixed) = 0; | ||
virtual bool isNodeExist(size_t nodeId) const = 0; | ||
virtual bool setNodeFixed(size_t nodeId, bool fixed) = 0; | ||
virtual bool isNodeFixed(size_t nodeId) const = 0; | ||
virtual Affine3d getNodePose(size_t nodeId) const = 0; | ||
virtual std::vector<size_t> getNodesIds() const = 0; | ||
virtual size_t getNumNodes() const = 0; | ||
|
||
// Edges have consequent indices starting from 0 | ||
virtual void addEdge(size_t _sourceNodeId, size_t _targetNodeId, const Affine3f& _transformation, | ||
const Matx66f& _information = Matx66f::eye()) = 0; | ||
virtual size_t getEdgeStart(size_t i) const = 0; | ||
virtual size_t getEdgeEnd(size_t i) const = 0; | ||
virtual size_t getNumEdges() const = 0; | ||
|
||
// checks if graph is connected and each edge connects exactly 2 nodes | ||
virtual bool isValid() const = 0; | ||
|
||
// Termination criteria are max number of iterations and min relative energy change to current energy | ||
// Returns number of iterations elapsed or -1 if max number of iterations was reached or failed to optimize | ||
virtual int optimize(const cv::TermCriteria& tc = cv::TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 100, 1e-6)) = 0; | ||
|
||
// calculate cost function based on current nodes parameters | ||
virtual double calcEnergy() const = 0; | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace kinfu | ||
} // namespace cv | ||
#endif /* ifndef OPENCV_RGBD_POSE_GRAPH_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.