Skip to content

KinFu fix (iss2925) #2926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion modules/rgbd/include/opencv2/rgbd/colored_kinfu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ class CV_EXPORTS_W ColoredKinFu
/** @brief Get current parameters */
virtual const Params& getParams() const = 0;

/** @brief Renders a volume into an image

Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
Light pose is fixed in KinFu params.

@param image resulting image
*/

CV_WRAP virtual void render(OutputArray image) const = 0;

/** @brief Renders a volume into an image

Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
Expand All @@ -211,7 +221,7 @@ class CV_EXPORTS_W ColoredKinFu
which is a last frame camera pose.
*/

CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0;
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;

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

Expand Down
12 changes: 11 additions & 1 deletion modules/rgbd/include/opencv2/rgbd/kinfu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ class CV_EXPORTS_W KinFu
/** @brief Get current parameters */
virtual const Params& getParams() const = 0;

/** @brief Renders a volume into an image

Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
Light pose is fixed in KinFu params.

@param image resulting image
*/

CV_WRAP virtual void render(OutputArray image) const = 0;

/** @brief Renders a volume into an image

Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
Expand All @@ -208,7 +218,7 @@ class CV_EXPORTS_W KinFu
which is a last frame camera pose.
*/

CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0;
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;

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

Expand Down
4 changes: 2 additions & 2 deletions modules/rgbd/include/opencv2/rgbd/large_kinfu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class CV_EXPORTS_W LargeKinfu

virtual const Params& getParams() const = 0;

CV_WRAP virtual void render(OutputArray image,
const Matx44f& cameraPose = Matx44f::eye()) const = 0;
CV_WRAP virtual void render(OutputArray image) const = 0;
CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose) const = 0;

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

Expand Down
26 changes: 12 additions & 14 deletions modules/rgbd/src/colored_kinfu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ColoredKinFuImpl : public ColoredKinFu

const Params& getParams() const CV_OVERRIDE;

void render(OutputArray image) const CV_OVERRIDE;
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;

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


template< typename MatType >
void ColoredKinFuImpl<MatType>::render(OutputArray image) const
{
CV_TRACE_FUNCTION();

renderPointsNormalsColors(pyrPoints[0], pyrNormals[0], pyrColors[0],image, params.lightPose);
}

template< typename MatType >
void ColoredKinFuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
{
CV_TRACE_FUNCTION();

Affine3f cameraPose(_cameraPose);
Affine3f _pose(pose);

const Affine3f id = Affine3f::Identity();
if((cameraPose.rotation() == _pose.rotation() && cameraPose.translation() == _pose.translation()) ||
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
{
renderPointsNormalsColors(pyrPoints[0], pyrNormals[0], pyrColors[0],image, params.lightPose);
}
else
{
MatType points, normals, colors;
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals, colors);
renderPointsNormalsColors(points, normals, colors, image, params.lightPose);
}
MatType points, normals, colors;
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals, colors);
renderPointsNormalsColors(points, normals, colors, image, params.lightPose);
}


Expand Down
27 changes: 13 additions & 14 deletions modules/rgbd/src/kinfu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class KinFuImpl : public KinFu

const Params& getParams() const CV_OVERRIDE;

void render(OutputArray image) const CV_OVERRIDE;
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;

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


template< typename MatType >
void KinFuImpl<MatType>::render(OutputArray image) const
{
CV_TRACE_FUNCTION();

renderPointsNormals(pyrPoints[0], pyrNormals[0], image, params.lightPose);
}


template< typename MatType >
void KinFuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
{
CV_TRACE_FUNCTION();

Affine3f cameraPose(_cameraPose);
Affine3f _pose(pose);

const Affine3f id = Affine3f::Identity();
if((cameraPose.rotation() == _pose.rotation() && cameraPose.translation() == _pose.translation()) ||
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
{
renderPointsNormals(pyrPoints[0], pyrNormals[0], image, params.lightPose);
}
else
{
MatType points, normals;
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals);
renderPointsNormals(points, normals, image, params.lightPose);
}
MatType points, normals;
volume->raycast(_cameraPose, params.intr, params.frameSize, points, normals);
renderPointsNormals(points, normals, image, params.lightPose);
}


Expand Down
30 changes: 16 additions & 14 deletions modules/rgbd/src/large_kinfu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class LargeKinfuImpl : public LargeKinfu

const Params& getParams() const CV_OVERRIDE;

void render(OutputArray image) const CV_OVERRIDE;
void render(OutputArray image, const Matx44f& cameraPose) const CV_OVERRIDE;

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


template<typename MatType>
void LargeKinfuImpl<MatType>::render(OutputArray image) const
{
CV_TRACE_FUNCTION();
auto currSubmap = submapMgr->getCurrentSubmap();
//! TODO: Can render be dependent on current submap
renderPointsNormals(currSubmap->pyrPoints[0], currSubmap->pyrNormals[0], image, params.lightPose);
}


template<typename MatType>
void LargeKinfuImpl<MatType>::render(OutputArray image, const Matx44f& _cameraPose) const
{
CV_TRACE_FUNCTION();

Affine3f cameraPose(_cameraPose);

auto currSubmap = submapMgr->getCurrentSubmap();
const Affine3f id = Affine3f::Identity();
if ((cameraPose.rotation() == pose.rotation() && cameraPose.translation() == pose.translation()) ||
(cameraPose.rotation() == id.rotation() && cameraPose.translation() == id.translation()))
{
//! TODO: Can render be dependent on current submap
renderPointsNormals(currSubmap->pyrPoints[0], currSubmap->pyrNormals[0], image, params.lightPose);
}
else
{
MatType points, normals;
currSubmap->raycast(cameraPose, params.intr, params.frameSize, points, normals);
renderPointsNormals(points, normals, image, params.lightPose);
}
MatType points, normals;
currSubmap->raycast(cameraPose, params.intr, params.frameSize, points, normals);
renderPointsNormals(points, normals, image, params.lightPose);
}


template<typename MatType>
void LargeKinfuImpl<MatType>::getCloud(OutputArray p, OutputArray n) const
{
Expand Down