@@ -304,7 +304,8 @@ void computePointsNormals(const Intr intr, float depthFactor, const Depth depth,
304
304
static bool ocl_renderPointsNormals (const UMat points, const UMat normals, UMat image, Affine3f lightPose);
305
305
static bool ocl_makeFrameFromDepth (const UMat depth, OutputArrayOfArrays points, OutputArrayOfArrays normals,
306
306
const Intr intr, int levels, float depthFactor,
307
- float sigmaDepth, float sigmaSpatial, int kernelSize);
307
+ float sigmaDepth, float sigmaSpatial, int kernelSize,
308
+ float truncateThreshold);
308
309
static bool ocl_buildPyramidPointsNormals (const UMat points, const UMat normals,
309
310
OutputArrayOfArrays pyrPoints, OutputArrayOfArrays pyrNormals,
310
311
int levels);
@@ -490,20 +491,22 @@ static bool ocl_renderPointsNormals(const UMat points, const UMat normals,
490
491
491
492
static bool ocl_makeFrameFromDepth (const UMat depth, OutputArrayOfArrays points, OutputArrayOfArrays normals,
492
493
const Intr intr, int levels, float depthFactor,
493
- float sigmaDepth, float sigmaSpatial, int kernelSize)
494
+ float sigmaDepth, float sigmaSpatial, int kernelSize,
495
+ float truncateThreshold)
494
496
{
495
497
CV_TRACE_FUNCTION ();
496
498
497
499
// looks like OpenCV's bilateral filter works the same as KinFu's
498
500
UMat smooth;
499
501
// TODO: fix that
500
- // until 32f isn't implemented in OpenCV, we should use our workarounds
502
+ // until 32f isn't implemented in OpenCV in OpenCL , we should use our workarounds
501
503
// bilateralFilter(udepth, smooth, kernelSize, sigmaDepth*depthFactor, sigmaSpatial);
502
504
if (!customBilateralFilterGpu (depth, smooth, kernelSize, sigmaDepth*depthFactor, sigmaSpatial))
503
- return false ;
505
+ return false ;
504
506
505
- // depth truncation is not used by default
506
- // if (p.icp_truncate_depth_dist > 0) kfusion::cuda::depthTruncation(curr_.depth_pyr[0], p.icp_truncate_depth_dist);
507
+ // depth truncation can be used in some scenes
508
+ if (truncateThreshold > 0 .f )
509
+ threshold (depth, depth, truncateThreshold*depthFactor, 0.0 , THRESH_TOZERO_INV);
507
510
508
511
UMat scaled = smooth;
509
512
Size sz = smooth.size ();
@@ -596,7 +599,8 @@ void renderPointsNormals(InputArray _points, InputArray _normals, OutputArray im
596
599
void makeFrameFromDepth (InputArray _depth,
597
600
OutputArray pyrPoints, OutputArray pyrNormals,
598
601
const Intr intr, int levels, float depthFactor,
599
- float sigmaDepth, float sigmaSpatial, int kernelSize)
602
+ float sigmaDepth, float sigmaSpatial, int kernelSize,
603
+ float truncateThreshold)
600
604
{
601
605
CV_TRACE_FUNCTION ();
602
606
@@ -605,7 +609,8 @@ void makeFrameFromDepth(InputArray _depth,
605
609
CV_OCL_RUN (_depth.isUMat () && pyrPoints.isUMatVector () && pyrNormals.isUMatVector (),
606
610
ocl_makeFrameFromDepth (_depth.getUMat (), pyrPoints, pyrNormals,
607
611
intr, levels, depthFactor,
608
- sigmaDepth, sigmaSpatial, kernelSize));
612
+ sigmaDepth, sigmaSpatial, kernelSize,
613
+ truncateThreshold));
609
614
610
615
int kp = pyrPoints.kind (), kn = pyrNormals.kind ();
611
616
CV_Assert (kp == _InputArray::STD_ARRAY_MAT || kp == _InputArray::STD_VECTOR_MAT);
@@ -618,8 +623,9 @@ void makeFrameFromDepth(InputArray _depth,
618
623
619
624
bilateralFilter (depth, smooth, kernelSize, sigmaDepth*depthFactor, sigmaSpatial);
620
625
621
- // depth truncation is not used by default
622
- // if (p.icp_truncate_depth_dist > 0) kfusion::cuda::depthTruncation(curr_.depth_pyr[0], p.icp_truncate_depth_dist);
626
+ // depth truncation can be used in some scenes
627
+ if (truncateThreshold > 0 .f )
628
+ threshold (depth, depth, truncateThreshold, 0.0 , THRESH_TOZERO_INV);
623
629
624
630
// we don't need depth pyramid outside this method
625
631
// if we do, the code is to be refactored
0 commit comments