CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[GSoC] Add new Hashtable based TSDF volume to RGBD module #2566
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
Conversation
Merge opencv master
- Implement Integrate function (untested)
- Clean up comments and few fixes
- Format code - Delete kinfu_back.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will review algorithmic part again if there are some glitches.
Will repeat a review for class interface details and so on.
modules/rgbd/samples/kinfu_demo.cpp
Outdated
@@ -26,39 +27,39 @@ static vector<string> readDepth(std::string fileList) | |||
vector<string> v; | |||
|
|||
fstream file(fileList); | |||
if(!file.is_open()) | |||
if (!file.is_open()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore formatting of kinfu_demo
: it's hard to see what changes are significant and which are not. Of course, this can be left where formatting is really awful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not done (please point on commit with non-style changes in this file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted all the style changes in the file. Only added useHashTSDF parameter to the demo
modules/rgbd/src/kinfu.cpp
Outdated
@@ -60,7 +61,8 @@ Ptr<Params> Params::defaultParams() | |||
|
|||
// default pose of volume cube | |||
p.volumePose = Affine3f().translate(Vec3f(-volSize/2.f, -volSize/2.f, 0.5f)); | |||
p.tsdf_trunc_dist = 0.04f; //meters; | |||
/* p.volumePose = Affine3f(); */ | |||
p.tsdf_trunc_dist = 5 * p.voxelSize; //meters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An experimental thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pose change is an experimental thing. However, in general, it is better to have the truncation distance as a multiple to voxel size, as opposed to a constant, because with different resolutions (coarse or fine) the integration might become problematic when truncation distance goes below voxel size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So please adjust tsdf_trunc_dist
so that it's close to previous value of 0.04f to maintain compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Changed to 7 * voxel_size for 512 resolution and 2* voxel_size for 128 resolution
stepSize = tstep; | ||
} | ||
//! Surface crossing | ||
if (prevTsdf > 0.f && currTsdf <= 0.f && currWeight > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop should stop at surface crossing, even if NaN and Inf conditions are false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not resolved yet and there is a problem:
If surface crossing happened and tInterp
is not a good number (which is possible if prevTsdf
is close to currTsdf
: this leads to Inf or even NaN if stepSize
is also small so that tcurr
is close to tprev
)
OR
If the voxels are OK but their neighbours are not good so that it's impossible to get normal
THEN
We skip this step and search for the next point on a ray.
BUT we shouldn't.
A loop should be finished if we faced a surface, even if we cannot get feasible points/normals from it (in that case we should indicate it with NaNs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be done is to run loop until surface crossing, mark it with a bool, after the loop check that bool and if it's true then perform the interpolation, normal calculation and so on, if it's false then write NaNs to output pixels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had fixed this by moving the break outside the (is tInterp invalid check), but it seems it was not pushed correctly for some reason. I think just breaking the loop regardless of the tInterp value at a surface crossing solves the issue.
- Address Review comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at my comments (including old, not answered ones)
@@ -210,13 +222,13 @@ class CV_EXPORTS_W KinFu | |||
|
|||
@param points vector of points which are 4-float vectors | |||
*/ | |||
CV_WRAP virtual void getPoints(OutputArray points) const = 0; | |||
/* CV_WRAP virtual void getPoints(OutputArray points) const = 0; */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: getPoints and getNormals for HashTSDF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but not tested. Will write as part of tests.
modules/rgbd/src/kinfu.cpp
Outdated
@@ -60,7 +61,8 @@ Ptr<Params> Params::defaultParams() | |||
|
|||
// default pose of volume cube | |||
p.volumePose = Affine3f().translate(Vec3f(-volSize/2.f, -volSize/2.f, 0.5f)); | |||
p.tsdf_trunc_dist = 0.04f; //meters; | |||
/* p.volumePose = Affine3f(); */ | |||
p.tsdf_trunc_dist = 5 * p.voxelSize; //meters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So please adjust tsdf_trunc_dist
so that it's close to previous value of 0.04f to maintain compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now this pull request looks almost ready. According to my comments there is a list of things TODO:
- fix raycast loop, surface crossing
- minors in
hash_tsdf.cpp
: extra print, float16 - Expose volumes to public interface:
- move
volume.hpp
toinclude/opencv2/rgbd
directory - add a factory to this header: a function with a name for example
makeVolume
which takes an enum and a set of parameters like pose, voxelSize, truncDist, raymarchStep and returns TSDFVolume or HashTSDFVolume ascv::Ptr<Volume>
. This should look like what's going on inKinFuImpl
constructor you wrote.
- move
- Make sure that the demo still works
- Fix tests
stepSize = tstep; | ||
} | ||
//! Surface crossing | ||
if (prevTsdf > 0.f && currTsdf <= 0.f && currWeight > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not resolved yet and there is a problem:
If surface crossing happened and tInterp
is not a good number (which is possible if prevTsdf
is close to currTsdf
: this leads to Inf or even NaN if stepSize
is also small so that tcurr
is close to tprev
)
OR
If the voxels are OK but their neighbours are not good so that it's impossible to get normal
THEN
We skip this step and search for the next point on a ray.
BUT we shouldn't.
A loop should be finished if we faced a surface, even if we cannot get feasible points/normals from it (in that case we should indicate it with NaNs).
stepSize = tstep; | ||
} | ||
//! Surface crossing | ||
if (prevTsdf > 0.f && currTsdf <= 0.f && currWeight > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be done is to run loop until surface crossing, mark it with a bool, after the loop check that bool and if it's true then perform the interpolation, normal calculation and so on, if it's false then write NaNs to output pixels.
- Fix formatting according to comments - Move volume abstract class to include/opencv2/rgbd/ - Write factory method for creating TSDFVolumes - Small bug fixes - Minor fixes according to comments
2b0c153
to
d15ae3b
Compare
π |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution!
Several coding style notes are below.
namespace cv | ||
{ | ||
namespace kinfu | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid indentation in namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// module's directory | ||
|
||
#ifndef __OPENCV_VOLUME_H__ | ||
#define __OPENCV_VOLUME_H__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPENCV_VOLUME_H
Missing module name: __OPENCV_RGBD_VOLUME_H__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
class Volume | ||
{ | ||
public: | ||
explicit Volume(float _voxelSize, cv::Affine3f _pose, float _raycastStepFactor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit
Makes sense for cases with single parameter only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
modules/rgbd/samples/kinfu_demo.cpp
Outdated
@@ -26,39 +27,39 @@ static vector<string> readDepth(std::string fileList) | |||
vector<string> v; | |||
|
|||
fstream file(fileList); | |||
if(!file.is_open()) | |||
if (!file.is_open()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not done (please point on commit with non-style changes in this file)
modules/rgbd/src/hash_tsdf.cpp
Outdated
// This code is also subject to the license terms in the LICENSE_KinectFusion.md file found in this | ||
// module's directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps not related to this functionality
modules/rgbd/src/hash_tsdf.cpp
Outdated
mutable Mutex mutex; | ||
}; | ||
|
||
struct VolumeUnitInFrustumInvoker : ParallelLoopBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using of lambda functions instead for all ParallelLoopBody
stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we prefer lambdas over functor objects just because of coding style or ParallelLoopBody
misses some important features?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed a few small parallel_for_
to lambdas.
- Fix raycasting bug causing to loop forever - Suppress warnings by explicit conversion - Disable hashTsdf test until we figure out memory leak - style changes - Add missing license in a few files, correct precomp.hpp usage
Hi @alalek, I have fixed all the review comments, can the PR be merged? Or is there something missing from my side? |
This work is part of GSoC and is potentially for the first evaluation phase of the program.
My mentor for the GSoC time period is: @savuor
My proposal is available here: https://summerofcode.withgoogle.com/dashboard/project/6190777371197440/details/
Please note that this is still Work in Progress, as the system is not yet reliable and does not work well.
Making an initial PR as requested for early code review.
Pull Request Readiness Checklist