Commit c8b405eb authored by Rostislav Vasilikhin's avatar Rostislav Vasilikhin Committed by Alexander Alekhin

Merge pull request #2410 from savuor:fix/kinfu_fetch_checkzero

Fixed KinFu getCloud() at empty volume

* KinFu getCloud(): an empty volume check added to OCL code

* minor
parent 9c3e86b7
Pipeline #342 failed with stages
...@@ -1393,7 +1393,7 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals) ...@@ -1393,7 +1393,7 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals)
(int)divUp(globalSize[2], (unsigned int)localSize[2])); (int)divUp(globalSize[2], (unsigned int)localSize[2]));
const size_t counterSize = sizeof(int); const size_t counterSize = sizeof(int);
size_t lsz = localSize[0]*localSize[1]*localSize[2]*counterSize; size_t lszscan = localSize[0]*localSize[1]*localSize[2]*counterSize;
const int gsz[3] = {ngroups[2], ngroups[1], ngroups[0]}; const int gsz[3] = {ngroups[2], ngroups[1], ngroups[0]};
UMat groupedSum(3, gsz, CV_32S, Scalar(0)); UMat groupedSum(3, gsz, CV_32S, Scalar(0));
...@@ -1409,7 +1409,7 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals) ...@@ -1409,7 +1409,7 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals)
ocl::KernelArg::PtrReadOnly(volPoseGpu), ocl::KernelArg::PtrReadOnly(volPoseGpu),
voxelSize, voxelSize,
voxelSizeInv, voxelSizeInv,
ocl::KernelArg::Local(lsz), ocl::KernelArg::Local(lszscan),
ocl::KernelArg::WriteOnlyNoSize(groupedSum)); ocl::KernelArg::WriteOnlyNoSize(groupedSum));
if(!kscan.run(3, globalSize, localSize, true)) if(!kscan.run(3, globalSize, localSize, true))
...@@ -1422,12 +1422,6 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals) ...@@ -1422,12 +1422,6 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals)
// 2. fill output arrays according to per-group points count // 2. fill output arrays according to per-group points count
ocl::Kernel kfill;
kfill.create("fillPtsNrm", source, options, &errorStr);
if(kfill.empty())
throw std::runtime_error("Failed to create kernel: " + errorStr);
points.create(gpuSum, 1, POINT_TYPE); points.create(gpuSum, 1, POINT_TYPE);
UMat pts = points.getUMat(); UMat pts = points.getUMat();
UMat nrm; UMat nrm;
...@@ -1438,31 +1432,41 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals) ...@@ -1438,31 +1432,41 @@ void TSDFVolumeGPU::fetchPointsNormals(OutputArray points, OutputArray normals)
} }
else else
{ {
// it won't access but empty args are forbidden // it won't be accessed but empty args are forbidden
nrm = UMat(1, 1, POINT_TYPE); nrm = UMat(1, 1, POINT_TYPE);
} }
UMat atomicCtr(1, 1, CV_32S, Scalar(0));
// mem size to keep pts (and normals optionally) for all work-items in a group
lsz = localSize[0]*localSize[1]*localSize[2]*elemSize;
kfill.args(ocl::KernelArg::PtrReadOnly(volume), if (gpuSum)
volResGpu.val, {
volDims.val, ocl::Kernel kfill;
neighbourCoords.val, kfill.create("fillPtsNrm", source, options, &errorStr);
ocl::KernelArg::PtrReadOnly(volPoseGpu),
voxelSize, if(kfill.empty())
voxelSizeInv, throw std::runtime_error("Failed to create kernel: " + errorStr);
((int)needNormals),
ocl::KernelArg::Local(lsz), UMat atomicCtr(1, 1, CV_32S, Scalar(0));
ocl::KernelArg::PtrReadWrite(atomicCtr),
ocl::KernelArg::ReadOnlyNoSize(groupedSum), // mem size to keep pts (and normals optionally) for all work-items in a group
ocl::KernelArg::WriteOnlyNoSize(pts), size_t lszfill = localSize[0]*localSize[1]*localSize[2]*elemSize;
ocl::KernelArg::WriteOnlyNoSize(nrm)
); kfill.args(ocl::KernelArg::PtrReadOnly(volume),
volResGpu.val,
if(!kfill.run(3, globalSize, localSize, true)) volDims.val,
throw std::runtime_error("Failed to run kernel"); neighbourCoords.val,
ocl::KernelArg::PtrReadOnly(volPoseGpu),
voxelSize,
voxelSizeInv,
((int)needNormals),
ocl::KernelArg::Local(lszfill),
ocl::KernelArg::PtrReadWrite(atomicCtr),
ocl::KernelArg::ReadOnlyNoSize(groupedSum),
ocl::KernelArg::WriteOnlyNoSize(pts),
ocl::KernelArg::WriteOnlyNoSize(nrm)
);
if(!kfill.run(3, globalSize, localSize, true))
throw std::runtime_error("Failed to run kernel");
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment