1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #27801 from savuor:rv/fix_hashtsdf_expand

Fixed HashTSDF expand bug #27801

HashTSDF should expand volume units during integration. It didn't happen in fact because of wrong Mat passing.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Rostislav Vasilikhin
2025-09-22 07:36:13 +02:00
committed by GitHub
parent 83b7a0caf7
commit 9d232fe7f2
3 changed files with 147 additions and 14 deletions
+9 -8
View File
@@ -90,13 +90,13 @@ Point3f ocl_getNormalVoxel(
void integrateHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int& lastVolIndex, const int frameId, const int volumeUnitDegree, bool enableGrowth,
InputArray _depth, InputArray _pixNorms, InputArray _volUnitsData, VolumeUnitIndexes& volumeUnits)
InputArray _depth, InputArray _pixNorms, InputOutputArray _volUnitsData, VolumeUnitIndexes& volumeUnits)
{
CV_TRACE_FUNCTION();
CV_Assert(_depth.type() == DEPTH_TYPE);
Depth depth = _depth.getMat();
Mat volUnitsData = _volUnitsData.getMat();
Mat& volUnitsData = _volUnitsData.getMatRef();
Mat pixNorms = _pixNorms.getMat();
Matx44f _pose;
@@ -184,11 +184,12 @@ void integrateHashTsdfVolumeUnit(
vu.pose = subvolumePose;
vu.index = lastVolIndex;
lastVolIndex++;
if (lastVolIndex > int(volUnitsData.size().height))
if (lastVolIndex >= int(volUnitsData.size().height))
{
volUnitsData.resize((lastVolIndex - 1) * 2);
volUnitsData.resize(lastVolIndex * 2);
CV_LOG_DEBUG(NULL, "HashTSDF storage extended from " << lastVolIndex << " to " << lastVolIndex * 2 << " volume units");
}
lastVolIndex++;
volUnitsData.row(vu.index).forEach<VecTsdfVoxel>([](VecTsdfVoxel &vv, const int * /* position */)
{
TsdfVoxel& v = reinterpret_cast<TsdfVoxel&>(vv);
@@ -480,15 +481,15 @@ void markActive(
void ocl_integrateHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int& lastVolIndex, const int frameId, int& bufferSizeDegree, const int volumeUnitDegree, bool enableGrowth,
InputArray _depth, InputArray _pixNorms, InputArray _lastVisibleIndices, InputArray _volUnitsDataCopy, InputArray _volUnitsData, CustomHashSet& hashTable, InputArray _isActiveFlags)
InputArray _depth, InputArray _pixNorms, InputArray _lastVisibleIndices, InputOutputArray _volUnitsDataCopy, InputOutputArray _volUnitsData, CustomHashSet& hashTable, InputArray _isActiveFlags)
{
CV_TRACE_FUNCTION();
UMat depth = _depth.getUMat();
CV_Assert(!depth.empty());
CV_Assert(lastVolIndex >= 0);
UMat pixNorms = _pixNorms.getUMat();
UMat volUnitsData = _volUnitsData.getUMat();
Mat volUnitsDataCopy = _volUnitsDataCopy.getMat();
UMat& volUnitsData = _volUnitsData.getUMatRef();
Mat& volUnitsDataCopy = _volUnitsDataCopy.getMatRef();
UMat isActiveFlags = _isActiveFlags.getUMat();
UMat lastVisibleIndices = _lastVisibleIndices.getUMat();
+2 -2
View File
@@ -287,7 +287,7 @@ typedef std::unordered_map<cv::Vec3i, VolumeUnit, tsdf_hash> VolumeUnitIndexes;
void integrateHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int& lastVolIndex, const int frameId, const int volumeUnitDegree, bool enableGrowth,
InputArray _depth, InputArray _pixNorms, InputArray _volUnitsData, VolumeUnitIndexes& volumeUnits);
InputArray _depth, InputArray _pixNorms, InputOutputArray _volUnitsData, VolumeUnitIndexes& volumeUnits);
void raycastHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int height, int width, InputArray intr, const int volumeUnitDegree,
@@ -304,7 +304,7 @@ void fetchPointsNormalsFromHashTsdfVolumeUnit(
#ifdef HAVE_OPENCL
void ocl_integrateHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int& lastVolIndex, const int frameId, int& bufferSizeDegree, const int volumeUnitDegree, bool enableGrowth,
InputArray _depth, InputArray _pixNorms, InputArray _lastVisibleIndices, InputArray _volUnitsDataCopy, InputArray _volUnitsData, CustomHashSet& hashTable, InputArray _isActiveFlags);
InputArray _depth, InputArray _pixNorms, InputArray _lastVisibleIndices, InputOutputArray _volUnitsDataCopy, InputOutputArray _volUnitsData, CustomHashSet& hashTable, InputArray _isActiveFlags);
void ocl_raycastHashTsdfVolumeUnit(
const VolumeSettings& settings, const Matx44f& cameraPose, int height, int width, InputArray intr, const int volumeUnitDegree,