@@ -845,7 +845,7 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
845
845
// top and bottom borders
846
846
// That sets the output density to false!
847
847
output.is_dense = false ;
848
- auto border = static_cast <unsigned >(normal_smoothing_size_);
848
+ const auto border = static_cast <unsigned >(normal_smoothing_size_);
849
849
PointOutT* vec1 = &output [0 ];
850
850
PointOutT* vec2 = vec1 + input_->width * (input_->height - border);
851
851
@@ -895,7 +895,13 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
895
895
if (smoothing > 2 .0f )
896
896
{
897
897
setRectSize (static_cast <int > (smoothing), static_cast <int > (smoothing));
898
- computePointNormal (ci, ri, index, output [index]);
898
+ // Since depth can be anything, we have no guarantee that the border is sufficient, so we need to check
899
+ if (ci>static_cast <unsigned >(rect_width_2_) && ri>static_cast <unsigned >(rect_height_2_) && (ci+rect_width_2_)<input_->width && (ri+rect_height_2_)<input_->height ) {
900
+ computePointNormal (ci, ri, index, output [index]);
901
+ } else {
902
+ output[index].getNormalVector3fMap ().setConstant (bad_point);
903
+ output[index].curvature = bad_point;
904
+ }
899
905
}
900
906
else
901
907
{
@@ -907,8 +913,6 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
907
913
}
908
914
else
909
915
{
910
- float smoothing_constant = normal_smoothing_size_;
911
-
912
916
index = border + input_->width * border;
913
917
unsigned skip = (border << 1 );
914
918
for (unsigned ri = border; ri < input_->height - border; ++ri, index += skip)
@@ -924,7 +928,7 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
924
928
continue ;
925
929
}
926
930
927
- float smoothing = (std::min)(distanceMap[index], smoothing_constant );
931
+ float smoothing = (std::min)(distanceMap[index], normal_smoothing_size_ );
928
932
929
933
if (smoothing > 2 .0f )
930
934
{
@@ -981,8 +985,6 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
981
985
}
982
986
else
983
987
{
984
- float smoothing_constant = normal_smoothing_size_;
985
-
986
988
// index = border + input_->width * border;
987
989
// unsigned skip = (border << 1);
988
990
// for (unsigned ri = border; ri < input_->height - border; ++ri, index += skip)
@@ -1000,7 +1002,7 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeatureFull (con
1000
1002
continue ;
1001
1003
}
1002
1004
1003
- float smoothing = (std::min)(distanceMap[index], smoothing_constant );
1005
+ float smoothing = (std::min)(distanceMap[index], normal_smoothing_size_ );
1004
1006
1005
1007
if (smoothing > 2 .0f )
1006
1008
{
@@ -1027,9 +1029,9 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeaturePart (con
1027
1029
if (border_policy_ == BORDER_POLICY_IGNORE)
1028
1030
{
1029
1031
output.is_dense = false ;
1030
- auto border = static_cast <unsigned >(normal_smoothing_size_);
1031
- unsigned bottom = input_->height > border ? input_->height - border : 0 ;
1032
- unsigned right = input_->width > border ? input_->width - border : 0 ;
1032
+ const auto border = static_cast <unsigned >(normal_smoothing_size_);
1033
+ const unsigned bottom = input_->height > border ? input_->height - border : 0 ;
1034
+ const unsigned right = input_->width > border ? input_->width - border : 0 ;
1033
1035
if (use_depth_dependent_smoothing_)
1034
1036
{
1035
1037
// Iterating over the entire index vector
@@ -1075,7 +1077,6 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeaturePart (con
1075
1077
}
1076
1078
else
1077
1079
{
1078
- float smoothing_constant = normal_smoothing_size_;
1079
1080
// Iterating over the entire index vector
1080
1081
for (std::size_t idx = 0 ; idx < indices_->size (); ++idx)
1081
1082
{
@@ -1103,7 +1104,7 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeaturePart (con
1103
1104
continue ;
1104
1105
}
1105
1106
1106
- float smoothing = (std::min)(distanceMap[pt_index], smoothing_constant );
1107
+ float smoothing = (std::min)(distanceMap[pt_index], normal_smoothing_size_ );
1107
1108
1108
1109
if (smoothing > 2 .0f )
1109
1110
{
@@ -1154,7 +1155,6 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeaturePart (con
1154
1155
}
1155
1156
else
1156
1157
{
1157
- float smoothing_constant = normal_smoothing_size_;
1158
1158
for (std::size_t idx = 0 ; idx < indices_->size (); ++idx)
1159
1159
{
1160
1160
unsigned pt_index = (*indices_)[idx];
@@ -1168,7 +1168,7 @@ pcl::IntegralImageNormalEstimation<PointInT, PointOutT>::computeFeaturePart (con
1168
1168
continue ;
1169
1169
}
1170
1170
1171
- float smoothing = (std::min)(distanceMap[pt_index], smoothing_constant );
1171
+ float smoothing = (std::min)(distanceMap[pt_index], normal_smoothing_size_ );
1172
1172
1173
1173
if (smoothing > 2 .0f )
1174
1174
{
0 commit comments