-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New HashTSDF implementation #2698
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
New HashTSDF implementation #2698
Conversation
modules/rgbd/src/hash_tsdf.cpp
Outdated
|
||
vu.pose = subvolumePose; | ||
volumes.push_back(Mat(1, volumeDims.x * volumeDims.y * volumeDims.z, rawType<TsdfVoxel>())); | ||
vu.index = HashS; HashS++; |
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.
push_back
works here but one of the purposes of this PR is to make a code that'd be easy to port to OpenCL, while OpenCL has no such push_back
ability: its buffers have fixed size.
What should be done instead:
volumes
should be preallocated to some size- when this buffer is exhausted, a reallocation should be done to a new buffer of
size*sizeFactor
wheresizeFactor=2.0
for example
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 the same
modules/rgbd/src/hash_tsdf.hpp
Outdated
cv::Vec3i coord; | ||
volumeIndex index; | ||
cv::Matx44f pose; | ||
Vec4i volDims; |
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.
Since all volume units have the same size, we shouldn't keep volDims
for each of them.
Another question is should we keep pose
for each of them since it can be calculated from coord
and volume pose - I think, we shouldn't.
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.
volDims - done
modules/rgbd/src/hash_tsdf.hpp
Outdated
@@ -33,8 +33,10 @@ class HashTSDFVolume : public Volume | |||
int volumeUnitResolution; | |||
float volumeUnitSize; | |||
bool zFirstMemOrder; | |||
Point3i volumeDims; | |||
Vec4i volDims; |
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 rename one of them (or both?) to be more self-descriptive
For example, volDims
to volStrides
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/src/tsdf.cpp
Outdated
} | ||
return pixNorm; | ||
} | ||
|
||
// use depth instead of distance (optimization) | ||
void TSDFVolumeCPU::integrate(InputArray _depth, float depthFactor, const cv::Matx44f& cameraPose, | ||
const Intr& intrinsics) |
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.
Since integrateVolumeUnit
is in tsdf_functions, the TSDF integration should be rewritten using it. SIMD version is to be taken too.
If this amount of work is too big for that PR, then it's better to postpone it till next PR.
cv::Matx44f _pose, Point3i volResolution, Vec4i volStrides, | ||
InputArray _depth, float depthFactor, const cv::Matx44f& cameraPose, | ||
const cv::kinfu::Intr& intrinsics, InputArray _pixNorms, InputArray _volume) | ||
{ |
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 not forget SIMD version of the code
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/src/hash_tsdf.cpp
Outdated
//! Out of bounds | ||
CV_DbgAssert((volumeIdx[0] >= volResolution.x || volumeIdx[0] < 0) || | ||
(volumeIdx[1] >= volResolution.y || volumeIdx[1] < 0) || | ||
(volumeIdx[2] >= volResolution.z || volumeIdx[2] < 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.
Here compilation fails: no such thing as volResolution
Also semicolon ;
missed
modules/rgbd/src/hash_tsdf.cpp
Outdated
cv::Vec3i volumeUnitIdx = volumeToVolumeUnitIdx(point); | ||
VolumeUnitIndexes::const_iterator it = volumeUnits.find(volumeUnitIdx); | ||
|
||
CV_DbgAssert (it == volumeUnits.end()) |
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 same
modules/rgbd/src/hash_tsdf.cpp
Outdated
Ptr<TSDFVolumeCPU> volumeUnit = std::dynamic_pointer_cast<TSDFVolumeCPU>(it->second.pVolume); | ||
VolumeUnitIndexes::const_iterator it = volumeUnits.find(volumeUnitIdx); | ||
|
||
CV_DbgAssert (it == volumeUnits.end()) |
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 same
👍 |
This PR changes
pixNorm
for each volume unitPull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.