Skip to content

Commit d442856

Browse files
Merge pull request #2447 from ayushgargdroid:kinfuParams
* Adding constructor for kinfu_Params(). Allows users to configure parameters for KinFu Algorithm * Trailing whitespace correct * Add constructor for TSDF Initial Pose. Allowed parameters are Matx33f,Vec3f and Matx44f. Also added function setInitialVolumePose to handle Matx44f param data type.
1 parent 80deee6 commit d442856

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

modules/rgbd/include/opencv2/rgbd/kinfu.hpp

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,49 @@ namespace kinfu {
1717

1818
struct CV_EXPORTS_W Params
1919
{
20-
/** @brief Default parameters
21-
A set of parameters which provides better model quality, can be very slow.
22-
*/
20+
21+
CV_WRAP Params(){}
22+
23+
/**
24+
* @brief Constructor for Params
25+
* Sets the initial pose of the TSDF volume.
26+
* @param volumeIntialPoseRot rotation matrix
27+
* @param volumeIntialPoseTransl translation vector
28+
*/
29+
CV_WRAP Params(Matx33f volumeIntialPoseRot, Vec3f volumeIntialPoseTransl)
30+
{
31+
setInitialVolumePose(volumeIntialPoseRot,volumeIntialPoseTransl);
32+
}
33+
34+
/**
35+
* @brief Constructor for Params
36+
* Sets the initial pose of the TSDF volume.
37+
* @param volumeIntialPose 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume
38+
*/
39+
CV_WRAP Params(Matx44f volumeIntialPose)
40+
{
41+
setInitialVolumePose(volumeIntialPose);
42+
}
43+
44+
/**
45+
* @brief Set Initial Volume Pose
46+
* Sets the initial pose of the TSDF volume.
47+
* @param R rotation matrix
48+
* @param t translation vector
49+
*/
50+
CV_WRAP void setInitialVolumePose(Matx33f R, Vec3f t);
51+
52+
/**
53+
* @brief Set Initial Volume Pose
54+
* Sets the initial pose of the TSDF volume.
55+
* @param homogen_tf 4 by 4 Homogeneous Transform matrix to set the intial pose of TSDF volume
56+
*/
57+
CV_WRAP void setInitialVolumePose(Matx44f homogen_tf);
58+
59+
/**
60+
* @brief Default parameters
61+
* A set of parameters which provides better model quality, can be very slow.
62+
*/
2363
CV_WRAP static Ptr<Params> defaultParams();
2464

2565
/** @brief Coarse parameters
@@ -32,7 +72,7 @@ struct CV_EXPORTS_W Params
3272
CV_PROP_RW Size frameSize;
3373

3474
/** @brief camera intrinsics */
35-
CV_PROP Matx33f intr;
75+
CV_PROP_RW Matx33f intr;
3676

3777
/** @brief pre-scale per 1 meter for input values
3878
@@ -93,14 +133,14 @@ struct CV_EXPORTS_W Params
93133
// float gradient_delta_factor;
94134

95135
/** @brief light pose for rendering in meters */
96-
CV_PROP Vec3f lightPose;
136+
CV_PROP_RW Vec3f lightPose;
97137

98138
/** @brief distance theshold for ICP in meters */
99139
CV_PROP_RW float icpDistThresh;
100140
/** angle threshold for ICP in radians */
101141
CV_PROP_RW float icpAngleThresh;
102142
/** number of ICP iterations for each pyramid level */
103-
CV_PROP std::vector<int> icpIterations;
143+
CV_PROP_RW std::vector<int> icpIterations;
104144

105145
/** @brief Threshold for depth truncation in meters
106146

modules/rgbd/src/kinfu.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
namespace cv {
1313
namespace kinfu {
1414

15+
void Params::setInitialVolumePose(Matx33f R, Vec3f t)
16+
{
17+
setInitialVolumePose(Affine3f(R,t).matrix);
18+
}
19+
20+
void Params::setInitialVolumePose(Matx44f homogen_tf)
21+
{
22+
Params::volumePose.matrix = homogen_tf;
23+
}
24+
1525
Ptr<Params> Params::defaultParams()
1626
{
1727
Params p;
@@ -299,6 +309,8 @@ void KinFuImpl<T>::getNormals(InputArray points, OutputArray normals) const
299309

300310
Ptr<KinFu> KinFu::create(const Ptr<Params>& params)
301311
{
312+
CV_Assert((int)params->icpIterations.size() == params->pyramidLevels);
313+
CV_Assert(params->intr(0,1) == 0 && params->intr(1,0) == 0 && params->intr(2,0) == 0 && params->intr(2,1) == 0 && params->intr(2,2) == 1);
302314
#ifdef HAVE_OPENCL
303315
if(cv::ocl::useOpenCL())
304316
return makePtr< KinFuImpl<UMat> >(*params);

0 commit comments

Comments
 (0)