Skip to content

Commit 342f892

Browse files
authored
Merge pull request #2926 from DumDereDum:iss2925
KinFu fix (iss2925) * add TODO * rewrite render * docs fix * remove extra comment
1 parent e673aa4 commit 342f892

File tree

6 files changed

+65
-46
lines changed

6 files changed

+65
-46
lines changed

modules/rgbd/include/opencv2/rgbd/colored_kinfu.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ class CV_EXPORTS_W ColoredKinFu
201201
/** @brief Get current parameters */
202202
virtual const Params& getParams() const = 0;
203203

204+
/** @brief Renders a volume into an image
205+
206+
Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
207+
Light pose is fixed in KinFu params.
208+
209+
@param image resulting image
210+
*/
211+
212+
CV_WRAP virtual void render(OutputArray image) const = 0;
213+
204214
/** @brief Renders a volume into an image
205215
206216
Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
@@ -211,7 +221,7 @@ class CV_EXPORTS_W ColoredKinFu
211221
which is a last frame camera pose.
212222
*/
213223

214-
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0;
224+
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;
215225

216226
/** @brief Gets points and normals of current 3d mesh
217227

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ class CV_EXPORTS_W KinFu
198198
/** @brief Get current parameters */
199199
virtual const Params& getParams() const = 0;
200200

201+
/** @brief Renders a volume into an image
202+
203+
Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
204+
Light pose is fixed in KinFu params.
205+
206+
@param image resulting image
207+
*/
208+
209+
CV_WRAP virtual void render(OutputArray image) const = 0;
210+
201211
/** @brief Renders a volume into an image
202212
203213
Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
@@ -208,7 +218,7 @@ class CV_EXPORTS_W KinFu
208218
which is a last frame camera pose.
209219
*/
210220

211-
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0;
221+
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;
212222

213223
/** @brief Gets points and normals of current 3d mesh
214224

modules/rgbd/include/opencv2/rgbd/large_kinfu.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class CV_EXPORTS_W LargeKinfu
125125

126126
virtual const Params& getParams() const = 0;
127127

128-
CV_WRAP virtual void render(OutputArray image,
129-
const Matx44f& cameraPose = Matx44f::eye()) const = 0;
128+
CV_WRAP virtual void render(OutputArray image) const = 0;
129+
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;
130130

131131
CV_WRAP virtual void getCloud(OutputArray points, OutputArray normals) const = 0;
132132

modules/rgbd/src/colored_kinfu.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class ColoredKinFuImpl : public ColoredKinFu
141141

142142
const Params& getParams() const CV_OVERRIDE;
143143

144+
void render(OutputArray image) const CV_OVERRIDE;
144145
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;
145146

146147
virtual void getCloud(OutputArray points, OutputArray normals) const CV_OVERRIDE;
@@ -322,26 +323,23 @@ bool ColoredKinFuImpl<MatType>::updateT(const MatType& _depth, const MatType& _r
322323
}
323324

324325

326+
template< typename MatType >
327+
void ColoredKinFuImpl<MatType>::render(OutputArray image) const
328+
{
329+
CV_TRACE_FUNCTION();
330+
331+
renderPointsNormalsColors(pyrPoints[0], pyrNormals[0], pyrColors[0],image, params.lightPose);
332+
}
333+
325334
template< typename MatType >
326335
void ColoredKinFuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
327336
{
328337
CV_TRACE_FUNCTION();
329338

330339
Affine3f cameraPose(_cameraPose);
331-
Affine3f _pose(pose);
332-
333-
const Affine3f id = Affine3f::Identity();
334-
if((cameraPose.rotation() == _pose.rotation() && cameraPose.translation() == _pose.translation()) ||
335-
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
336-
{
337-
renderPointsNormalsColors(pyrPoints[0], pyrNormals[0], pyrColors[0],image, params.lightPose);
338-
}
339-
else
340-
{
341-
MatType points, normals, colors;
342-
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals, colors);
343-
renderPointsNormalsColors(points, normals, colors, image, params.lightPose);
344-
}
340+
MatType points, normals, colors;
341+
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals, colors);
342+
renderPointsNormalsColors(points, normals, colors, image, params.lightPose);
345343
}
346344

347345

modules/rgbd/src/kinfu.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class KinFuImpl : public KinFu
129129

130130
const Params& getParams() const CV_OVERRIDE;
131131

132+
void render(OutputArray image) const CV_OVERRIDE;
132133
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;
133134

134135
virtual void getCloud(OutputArray points, OutputArray normals) const CV_OVERRIDE;
@@ -284,26 +285,24 @@ bool KinFuImpl<MatType>::updateT(const MatType& _depth)
284285
}
285286

286287

288+
template< typename MatType >
289+
void KinFuImpl<MatType>::render(OutputArray image) const
290+
{
291+
CV_TRACE_FUNCTION();
292+
293+
renderPointsNormals(pyrPoints[0], pyrNormals[0], image, params.lightPose);
294+
}
295+
296+
287297
template< typename MatType >
288298
void KinFuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
289299
{
290300
CV_TRACE_FUNCTION();
291301

292302
Affine3f cameraPose(_cameraPose);
293-
Affine3f _pose(pose);
294-
295-
const Affine3f id = Affine3f::Identity();
296-
if((cameraPose.rotation() == _pose.rotation() && cameraPose.translation() == _pose.translation()) ||
297-
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
298-
{
299-
renderPointsNormals(pyrPoints[0], pyrNormals[0], image, params.lightPose);
300-
}
301-
else
302-
{
303-
MatType points, normals;
304-
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals);
305-
renderPointsNormals(points, normals, image, params.lightPose);
306-
}
303+
MatType points, normals;
304+
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals);
305+
renderPointsNormals(points, normals, image, params.lightPose);
307306
}
308307

309308

modules/rgbd/src/large_kinfu.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class LargeKinfuImpl : public LargeKinfu
112112

113113
const Params& getParams() const CV_OVERRIDE;
114114

115+
void render(OutputArray image) const CV_OVERRIDE;
115116
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;
116117

117118
virtual void getCloud(OutputArray points, OutputArray normals) const CV_OVERRIDE;
@@ -296,29 +297,30 @@ bool LargeKinfuImpl<MatType>::updateT(const MatType& _depth)
296297
return true;
297298
}
298299

300+
301+
template<typename MatType>
302+
void LargeKinfuImpl<MatType>::render(OutputArray image) const
303+
{
304+
CV_TRACE_FUNCTION();
305+
auto currSubmap = submapMgr->getCurrentSubmap();
306+
//! TODO: Can render be dependent on current submap
307+
renderPointsNormals(currSubmap->pyrPoints[0], currSubmap->pyrNormals[0], image, params.lightPose);
308+
}
309+
310+
299311
template<typename MatType>
300312
void LargeKinfuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
301313
{
302314
CV_TRACE_FUNCTION();
303315

304316
Affine3f cameraPose(_cameraPose);
305-
306317
auto currSubmap = submapMgr->getCurrentSubmap();
307-
const Affine3f id = Affine3f::Identity();
308-
if ((cameraPose.rotation() == pose.rotation() && cameraPose.translation() == pose.translation()) ||
309-
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
310-
{
311-
//! TODO: Can render be dependent on current submap
312-
renderPointsNormals(currSubmap->pyrPoints[0], currSubmap->pyrNormals[0], image, params.lightPose);
313-
}
314-
else
315-
{
316-
MatType points, normals;
317-
currSubmap->raycast(cameraPose, params.intr, params.frameSize, points, normals);
318-
renderPointsNormals(points, normals, image, params.lightPose);
319-
}
318+
MatType points, normals;
319+
currSubmap->raycast(cameraPose, params.intr, params.frameSize, points, normals);
320+
renderPointsNormals(points, normals, image, params.lightPose);
320321
}
321322

323+
322324
template<typename MatType>
323325
void LargeKinfuImpl<MatType>::getCloud(OutputArray p, OutputArray n) const
324326
{

0 commit comments

Comments
 (0)