|
| 1 | +// This file is part of OpenCV project. |
| 2 | +// It is subject to the license terms in the LICENSE file found in the top-level directory |
| 3 | +// of this distribution and at http://opencv.org/license.html |
| 4 | + |
| 5 | +// This code is also subject to the license terms in the LICENSE_KinectFusion.md file found in this |
| 6 | +// module's directory |
| 7 | + |
| 8 | +#ifndef __OPENCV_RGBD_LARGEKINFU_HPP__ |
| 9 | +#define __OPENCV_RGBD_LARGEKINFU_HPP__ |
| 10 | + |
| 11 | +#include <opencv2/rgbd/volume.hpp> |
| 12 | + |
| 13 | +#include "opencv2/core.hpp" |
| 14 | +#include "opencv2/core/affine.hpp" |
| 15 | + |
| 16 | +namespace cv |
| 17 | +{ |
| 18 | +namespace large_kinfu |
| 19 | +{ |
| 20 | +struct CV_EXPORTS_W Params |
| 21 | +{ |
| 22 | + /** @brief Default parameters |
| 23 | + A set of parameters which provides better model quality, can be very slow. |
| 24 | + */ |
| 25 | + CV_WRAP static Ptr<Params> defaultParams(); |
| 26 | + |
| 27 | + /** @brief Coarse parameters |
| 28 | + A set of parameters which provides better speed, can fail to match frames |
| 29 | + in case of rapid sensor motion. |
| 30 | + */ |
| 31 | + CV_WRAP static Ptr<Params> coarseParams(); |
| 32 | + |
| 33 | + /** @brief HashTSDF parameters |
| 34 | + A set of parameters suitable for use with HashTSDFVolume |
| 35 | + */ |
| 36 | + CV_WRAP static Ptr<Params> hashTSDFParams(bool isCoarse); |
| 37 | + |
| 38 | + /** @brief frame size in pixels */ |
| 39 | + CV_PROP_RW Size frameSize; |
| 40 | + |
| 41 | + /** @brief camera intrinsics */ |
| 42 | + CV_PROP_RW Matx33f intr; |
| 43 | + |
| 44 | + /** @brief pre-scale per 1 meter for input values |
| 45 | + Typical values are: |
| 46 | + * 5000 per 1 meter for the 16-bit PNG files of TUM database |
| 47 | + * 1000 per 1 meter for Kinect 2 device |
| 48 | + * 1 per 1 meter for the 32-bit float images in the ROS bag files |
| 49 | + */ |
| 50 | + CV_PROP_RW float depthFactor; |
| 51 | + |
| 52 | + /** @brief Depth sigma in meters for bilateral smooth */ |
| 53 | + CV_PROP_RW float bilateral_sigma_depth; |
| 54 | + /** @brief Spatial sigma in pixels for bilateral smooth */ |
| 55 | + CV_PROP_RW float bilateral_sigma_spatial; |
| 56 | + /** @brief Kernel size in pixels for bilateral smooth */ |
| 57 | + CV_PROP_RW int bilateral_kernel_size; |
| 58 | + |
| 59 | + /** @brief Number of pyramid levels for ICP */ |
| 60 | + CV_PROP_RW int pyramidLevels; |
| 61 | + |
| 62 | + /** @brief Minimal camera movement in meters |
| 63 | + Integrate new depth frame only if camera movement exceeds this value. |
| 64 | + */ |
| 65 | + CV_PROP_RW float tsdf_min_camera_movement; |
| 66 | + |
| 67 | + /** @brief light pose for rendering in meters */ |
| 68 | + CV_PROP_RW Vec3f lightPose; |
| 69 | + |
| 70 | + /** @brief distance theshold for ICP in meters */ |
| 71 | + CV_PROP_RW float icpDistThresh; |
| 72 | + /** @brief angle threshold for ICP in radians */ |
| 73 | + CV_PROP_RW float icpAngleThresh; |
| 74 | + /** @brief number of ICP iterations for each pyramid level */ |
| 75 | + CV_PROP_RW std::vector<int> icpIterations; |
| 76 | + |
| 77 | + /** @brief Threshold for depth truncation in meters |
| 78 | + All depth values beyond this threshold will be set to zero |
| 79 | + */ |
| 80 | + CV_PROP_RW float truncateThreshold; |
| 81 | + |
| 82 | + /** @brief Volume parameters |
| 83 | + */ |
| 84 | + kinfu::VolumeParams volumeParams; |
| 85 | +}; |
| 86 | + |
| 87 | +/** @brief Large Scale Dense Depth Fusion implementation |
| 88 | +
|
| 89 | + This class implements a 3d reconstruction algorithm for larger environments using |
| 90 | + Spatially hashed TSDF volume "Submaps". |
| 91 | + It also runs a periodic posegraph optimization to minimize drift in tracking over long sequences. |
| 92 | + Currently the algorithm does not implement a relocalization or loop closure module. |
| 93 | + Potentially a Bag of words implementation or RGBD relocalization as described in |
| 94 | + Glocker et al. ISMAR 2013 will be implemented |
| 95 | +
|
| 96 | + It takes a sequence of depth images taken from depth sensor |
| 97 | + (or any depth images source such as stereo camera matching algorithm or even raymarching |
| 98 | + renderer). The output can be obtained as a vector of points and their normals or can be |
| 99 | + Phong-rendered from given camera pose. |
| 100 | +
|
| 101 | + An internal representation of a model is a spatially hashed voxel cube that stores TSDF values |
| 102 | + which represent the distance to the closest surface (for details read the @cite kinectfusion article |
| 103 | + about TSDF). There is no interface to that representation yet. |
| 104 | +
|
| 105 | + For posegraph optimization, a Submap abstraction over the Volume class is created. |
| 106 | + New submaps are added to the model when there is low visibility overlap between current viewing frustrum |
| 107 | + and the existing volume/model. Multiple submaps are simultaneously tracked and a posegraph is created and |
| 108 | + optimized periodically. |
| 109 | +
|
| 110 | + LargeKinfu does not use any OpenCL acceleration yet. |
| 111 | + To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL(). |
| 112 | +
|
| 113 | + This implementation is inspired from Kintinuous, InfiniTAM and other SOTA algorithms |
| 114 | +
|
| 115 | + You need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion. |
| 116 | +*/ |
| 117 | +class CV_EXPORTS_W LargeKinfu |
| 118 | +{ |
| 119 | + public: |
| 120 | + CV_WRAP static Ptr<LargeKinfu> create(const Ptr<Params>& _params); |
| 121 | + virtual ~LargeKinfu() = default; |
| 122 | + |
| 123 | + virtual const Params& getParams() const = 0; |
| 124 | + |
| 125 | + CV_WRAP virtual void render(OutputArray image, |
| 126 | + const Matx44f& cameraPose = Matx44f::eye()) const = 0; |
| 127 | + |
| 128 | + CV_WRAP virtual void getCloud(OutputArray points, OutputArray normals) const = 0; |
| 129 | + |
| 130 | + CV_WRAP virtual void getPoints(OutputArray points) const = 0; |
| 131 | + |
| 132 | + CV_WRAP virtual void getNormals(InputArray points, OutputArray normals) const = 0; |
| 133 | + |
| 134 | + CV_WRAP virtual void reset() = 0; |
| 135 | + |
| 136 | + virtual const Affine3f getPose() const = 0; |
| 137 | + |
| 138 | + CV_WRAP virtual bool update(InputArray depth) = 0; |
| 139 | +}; |
| 140 | + |
| 141 | +} // namespace large_kinfu |
| 142 | +} // namespace cv |
| 143 | +#endif |
0 commit comments