|
|
|
@ -15,134 +15,134 @@ namespace kinfu { |
|
|
|
|
//! @addtogroup kinect_fusion
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
/** @brief KinectFusion implementation
|
|
|
|
|
struct CV_EXPORTS_W Params |
|
|
|
|
{ |
|
|
|
|
/** @brief Default parameters
|
|
|
|
|
A set of parameters which provides better model quality, can be very slow. |
|
|
|
|
*/ |
|
|
|
|
CV_WRAP static Ptr<Params> defaultParams(); |
|
|
|
|
|
|
|
|
|
This class implements a 3d reconstruction algorithm described in |
|
|
|
|
@cite kinectfusion paper. |
|
|
|
|
/** @brief Coarse parameters
|
|
|
|
|
A set of parameters which provides better speed, can fail to match frames |
|
|
|
|
in case of rapid sensor motion. |
|
|
|
|
*/ |
|
|
|
|
CV_WRAP static Ptr<Params> coarseParams(); |
|
|
|
|
|
|
|
|
|
It takes a sequence of depth images taken from depth sensor |
|
|
|
|
(or any depth images source such as stereo camera matching algorithm or even raymarching renderer). |
|
|
|
|
The output can be obtained as a vector of points and their normals |
|
|
|
|
or can be Phong-rendered from given camera pose. |
|
|
|
|
enum PlatformType |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
An internal representation of a model is a voxel cube that keeps TSDF values |
|
|
|
|
which are a sort of distances to the surface (for details read the @cite kinectfusion article about TSDF). |
|
|
|
|
There is no interface to that representation yet. |
|
|
|
|
PLATFORM_CPU, PLATFORM_GPU |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
This implementation is based on (kinfu-remake)[https://github.com/Nerei/kinfu_remake].
|
|
|
|
|
*/ |
|
|
|
|
class CV_EXPORTS KinFu |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
struct CV_EXPORTS Params |
|
|
|
|
{ |
|
|
|
|
/** @brief Default parameters
|
|
|
|
|
A set of parameters which provides better model quality, can be very slow. |
|
|
|
|
*/ |
|
|
|
|
static Params defaultParams(); |
|
|
|
|
/** @brief A platform on which to run the algorithm.
|
|
|
|
|
* |
|
|
|
|
Currently KinFu supports only one platform which is a CPU. |
|
|
|
|
GPU platform is to be implemented in the future. |
|
|
|
|
*/ |
|
|
|
|
PlatformType platform; |
|
|
|
|
|
|
|
|
|
/** @brief Coarse parameters
|
|
|
|
|
A set of parameters which provides better speed, can fail to match frames |
|
|
|
|
in case of rapid sensor motion. |
|
|
|
|
*/ |
|
|
|
|
static Params coarseParams(); |
|
|
|
|
/** @brief frame size in pixels */ |
|
|
|
|
CV_PROP_RW Size frameSize; |
|
|
|
|
|
|
|
|
|
enum PlatformType |
|
|
|
|
{ |
|
|
|
|
/** @brief camera intrinsics */ |
|
|
|
|
CV_PROP Matx33f intr; |
|
|
|
|
|
|
|
|
|
PLATFORM_CPU, PLATFORM_GPU |
|
|
|
|
}; |
|
|
|
|
/** @brief pre-scale per 1 meter for input values
|
|
|
|
|
|
|
|
|
|
/** @brief A platform on which to run the algorithm.
|
|
|
|
|
* |
|
|
|
|
Currently KinFu supports only one platform which is a CPU. |
|
|
|
|
GPU platform is to be implemented in the future. |
|
|
|
|
*/ |
|
|
|
|
PlatformType platform; |
|
|
|
|
Typical values are: |
|
|
|
|
* 5000 per 1 meter for the 16-bit PNG files of TUM database |
|
|
|
|
* 1 per 1 meter for the 32-bit float images in the ROS bag files |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW float depthFactor; |
|
|
|
|
|
|
|
|
|
/** @brief frame size in pixels */ |
|
|
|
|
Size frameSize; |
|
|
|
|
/** @brief Depth sigma in meters for bilateral smooth */ |
|
|
|
|
CV_PROP_RW float bilateral_sigma_depth; |
|
|
|
|
/** @brief Spatial sigma in pixels for bilateral smooth */ |
|
|
|
|
CV_PROP_RW float bilateral_sigma_spatial; |
|
|
|
|
/** @brief Kernel size in pixels for bilateral smooth */ |
|
|
|
|
CV_PROP_RW int bilateral_kernel_size; |
|
|
|
|
|
|
|
|
|
/** @brief camera intrinsics */ |
|
|
|
|
Matx33f intr; |
|
|
|
|
/** @brief Number of pyramid levels for ICP */ |
|
|
|
|
CV_PROP_RW int pyramidLevels; |
|
|
|
|
|
|
|
|
|
/** @brief pre-scale per 1 meter for input values
|
|
|
|
|
/** @brief Resolution of voxel cube
|
|
|
|
|
|
|
|
|
|
Typical values are: |
|
|
|
|
* 5000 per 1 meter for the 16-bit PNG files of TUM database |
|
|
|
|
* 1 per 1 meter for the 32-bit float images in the ROS bag files |
|
|
|
|
*/ |
|
|
|
|
float depthFactor; |
|
|
|
|
Number of voxels in each cube edge. |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW int volumeDims; |
|
|
|
|
/** @brief Size of voxel cube side in meters */ |
|
|
|
|
CV_PROP_RW float volumeSize; |
|
|
|
|
|
|
|
|
|
/** @brief Depth sigma in meters for bilateral smooth */ |
|
|
|
|
float bilateral_sigma_depth; |
|
|
|
|
/** @brief Spatial sigma in pixels for bilateral smooth */ |
|
|
|
|
float bilateral_sigma_spatial; |
|
|
|
|
/** @brief Kernel size in pixels for bilateral smooth */ |
|
|
|
|
int bilateral_kernel_size; |
|
|
|
|
/** @brief Minimal camera movement in meters
|
|
|
|
|
|
|
|
|
|
/** @brief Number of pyramid levels for ICP */ |
|
|
|
|
int pyramidLevels; |
|
|
|
|
Integrate new depth frame only if camera movement exceeds this value. |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW float tsdf_min_camera_movement; |
|
|
|
|
|
|
|
|
|
/** @brief Resolution of voxel cube
|
|
|
|
|
/** @brief initial volume pose in meters */ |
|
|
|
|
Affine3f volumePose; |
|
|
|
|
|
|
|
|
|
Number of voxels in each cube edge. |
|
|
|
|
*/ |
|
|
|
|
int volumeDims; |
|
|
|
|
/** @brief Size of voxel cube side in meters */ |
|
|
|
|
float volumeSize; |
|
|
|
|
/** @brief distance to truncate in meters
|
|
|
|
|
|
|
|
|
|
/** @brief Minimal camera movement in meters
|
|
|
|
|
Distances that exceed this value will be truncated in voxel cube values. |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW float tsdf_trunc_dist; |
|
|
|
|
|
|
|
|
|
Integrate new depth frame only if camera movement exceeds this value. |
|
|
|
|
*/ |
|
|
|
|
float tsdf_min_camera_movement; |
|
|
|
|
/** @brief max number of frames per voxel
|
|
|
|
|
|
|
|
|
|
/** @brief initial volume pose in meters */ |
|
|
|
|
Affine3f volumePose; |
|
|
|
|
Each voxel keeps running average of distances no longer than this value. |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW int tsdf_max_weight; |
|
|
|
|
|
|
|
|
|
/** @brief distance to truncate in meters
|
|
|
|
|
/** @brief A length of one raycast step
|
|
|
|
|
|
|
|
|
|
Distances that exceed this value will be truncated in voxel cube values. |
|
|
|
|
*/ |
|
|
|
|
float tsdf_trunc_dist; |
|
|
|
|
How much voxel sizes we skip each raycast step |
|
|
|
|
*/ |
|
|
|
|
CV_PROP_RW float raycast_step_factor; |
|
|
|
|
|
|
|
|
|
/** @brief max number of frames per voxel
|
|
|
|
|
// gradient delta in voxel sizes
|
|
|
|
|
// fixed at 1.0f
|
|
|
|
|
// float gradient_delta_factor;
|
|
|
|
|
|
|
|
|
|
Each voxel keeps running average of distances no longer than this value. |
|
|
|
|
*/ |
|
|
|
|
int tsdf_max_weight; |
|
|
|
|
/** @brief light pose for rendering in meters */ |
|
|
|
|
CV_PROP Vec3f lightPose; |
|
|
|
|
|
|
|
|
|
/** @brief A length of one raycast step
|
|
|
|
|
/** @brief distance theshold for ICP in meters */ |
|
|
|
|
CV_PROP_RW float icpDistThresh; |
|
|
|
|
/** angle threshold for ICP in radians */ |
|
|
|
|
CV_PROP_RW float icpAngleThresh; |
|
|
|
|
/** number of ICP iterations for each pyramid level */ |
|
|
|
|
CV_PROP std::vector<int> icpIterations; |
|
|
|
|
|
|
|
|
|
How much voxel sizes we skip each raycast step |
|
|
|
|
*/ |
|
|
|
|
float raycast_step_factor; |
|
|
|
|
// depth truncation is not used by default
|
|
|
|
|
// float icp_truncate_depth_dist; //meters
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// gradient delta in voxel sizes
|
|
|
|
|
// fixed at 1.0f
|
|
|
|
|
// float gradient_delta_factor;
|
|
|
|
|
/** @brief KinectFusion implementation
|
|
|
|
|
|
|
|
|
|
/** @brief light pose for rendering in meters */ |
|
|
|
|
Vec3f lightPose; |
|
|
|
|
This class implements a 3d reconstruction algorithm described in |
|
|
|
|
@cite kinectfusion paper. |
|
|
|
|
|
|
|
|
|
/** @brief distance theshold for ICP in meters */ |
|
|
|
|
float icpDistThresh; |
|
|
|
|
/** angle threshold for ICP in radians */ |
|
|
|
|
float icpAngleThresh; |
|
|
|
|
/** number of ICP iterations for each pyramid level */ |
|
|
|
|
std::vector<int> icpIterations; |
|
|
|
|
It takes a sequence of depth images taken from depth sensor |
|
|
|
|
(or any depth images source such as stereo camera matching algorithm or even raymarching renderer). |
|
|
|
|
The output can be obtained as a vector of points and their normals |
|
|
|
|
or can be Phong-rendered from given camera pose. |
|
|
|
|
|
|
|
|
|
// depth truncation is not used by default
|
|
|
|
|
// float icp_truncate_depth_dist; //meters
|
|
|
|
|
}; |
|
|
|
|
An internal representation of a model is a voxel cube that keeps TSDF values |
|
|
|
|
which are a sort of distances to the surface (for details read the @cite kinectfusion article about TSDF). |
|
|
|
|
There is no interface to that representation yet. |
|
|
|
|
|
|
|
|
|
KinFu(const Params& _params); |
|
|
|
|
This implementation is based on (kinfu-remake)[https://github.com/Nerei/kinfu_remake].
|
|
|
|
|
*/ |
|
|
|
|
class CV_EXPORTS_W KinFu |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
CV_WRAP static Ptr<KinFu> create(const Ptr<Params>& _params); |
|
|
|
|
virtual ~KinFu(); |
|
|
|
|
|
|
|
|
|
/** @brief Get current parameters */ |
|
|
|
|
const Params& getParams() const; |
|
|
|
|
void setParams(const Params&); |
|
|
|
|
virtual const Params& getParams() const = 0; |
|
|
|
|
virtual void setParams(const Params&) = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Renders a volume into an image
|
|
|
|
|
|
|
|
|
@ -154,7 +154,7 @@ public: |
|
|
|
|
which is a last frame camera pose. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
void render(OutputArray image, const Affine3f cameraPose = Affine3f::Identity()) const; |
|
|
|
|
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Gets points and normals of current 3d mesh
|
|
|
|
|
|
|
|
|
@ -164,7 +164,7 @@ public: |
|
|
|
|
@param points vector of points which are 4-float vectors |
|
|
|
|
@param normals vector of normals which are 4-float vectors |
|
|
|
|
*/ |
|
|
|
|
void getCloud(OutputArray points, OutputArray normals) const; |
|
|
|
|
CV_WRAP virtual void getCloud(OutputArray points, OutputArray normals) const = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Gets points of current 3d mesh
|
|
|
|
|
|
|
|
|
@ -172,22 +172,22 @@ public: |
|
|
|
|
|
|
|
|
|
@param points vector of points which are 4-float vectors |
|
|
|
|
*/ |
|
|
|
|
void getPoints(OutputArray points) const; |
|
|
|
|
CV_WRAP virtual void getPoints(OutputArray points) const = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Calculates normals for given points
|
|
|
|
|
@param points input vector of points which are 4-float vectors |
|
|
|
|
@param normals output vector of corresponding normals which are 4-float vectors |
|
|
|
|
*/ |
|
|
|
|
void getNormals(InputArray points, OutputArray normals) const; |
|
|
|
|
CV_WRAP virtual void getNormals(InputArray points, OutputArray normals) const = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Resets the algorithm
|
|
|
|
|
|
|
|
|
|
Clears current model and resets a pose. |
|
|
|
|
*/ |
|
|
|
|
void reset(); |
|
|
|
|
CV_WRAP virtual void reset() = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Get current pose in voxel cube space */ |
|
|
|
|
const Affine3f getPose() const; |
|
|
|
|
virtual const Affine3f getPose() const = 0; |
|
|
|
|
|
|
|
|
|
/** @brief Process next depth frame
|
|
|
|
|
|
|
|
|
@ -197,12 +197,10 @@ public: |
|
|
|
|
@param depth one-channel image which size and depth scale is described in algorithm's parameters |
|
|
|
|
@return true if succeded to align new frame with current scene, false if opposite |
|
|
|
|
*/ |
|
|
|
|
bool update(InputArray depth); |
|
|
|
|
CV_WRAP virtual bool update(InputArray depth) = 0; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
class KinFuImpl; |
|
|
|
|
cv::Ptr<KinFuImpl> impl; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//! @}
|
|
|
|
|