Skip to content

Commit 3fdae3a

Browse files
authored
Test for greater than 0 in centroid.hpp
1 parent ac66099 commit 3fdae3a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

common/include/pcl/common/impl/centroid.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ compute3DCentroid (ConstCloudIterator<PointT> &cloud_iterator,
7575
++cloud_iterator;
7676
}
7777

78-
if (cp) {
78+
if (cp > 0) {
7979
centroid = accumulator;
8080
centroid /= static_cast<Scalar> (cp);
8181
centroid[3] = 1;
@@ -122,7 +122,7 @@ compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
122122
accumulator[2] += point.z;
123123
++cp;
124124
}
125-
if (cp) {
125+
if (cp > 0) {
126126
centroid = accumulator;
127127
centroid /= static_cast<Scalar> (cp);
128128
centroid[3] = 1;
@@ -169,7 +169,7 @@ compute3DCentroid (const pcl::PointCloud<PointT> &cloud,
169169
accumulator[2] += cloud[index].z;
170170
++cp;
171171
}
172-
if (cp) {
172+
if (cp > 0) {
173173
centroid = accumulator;
174174
centroid /= static_cast<Scalar> (cp);
175175
centroid[3] = 1;
@@ -249,7 +249,7 @@ computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
249249
temp_covariance_matrix (0, 2) += pt.z ();
250250
++point_count;
251251
}
252-
if (point_count) {
252+
if (point_count > 0) {
253253
covariance_matrix = temp_covariance_matrix;
254254
}
255255
}
@@ -339,7 +339,7 @@ computeCovarianceMatrix (const pcl::PointCloud<PointT> &cloud,
339339
temp_covariance_matrix (0, 2) += pt.z ();
340340
++point_count;
341341
}
342-
if (point_count) {
342+
if (point_count > 0) {
343343
covariance_matrix = temp_covariance_matrix;
344344
}
345345
}

0 commit comments

Comments
 (0)