Skip to content

Commit

Permalink
estimateProjectionMatrix: consistently use double
Browse files Browse the repository at this point in the history
This leads to a more precise projection matrix, and, in some cases, avoids high residuals although the point cloud is projectable.
Fixes #6181
  • Loading branch information
mvieth committed Dec 7, 2024
1 parent 2287402 commit 547df3c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions common/include/pcl/common/impl/projection_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ estimateProjectionMatrix (

while (pointIt)
{
unsigned yIdx = pointIt.getCurrentPointIndex () / cloud->width;
unsigned xIdx = pointIt.getCurrentPointIndex () % cloud->width;
Scalar yIdx = pointIt.getCurrentPointIndex () / cloud->width;
Scalar xIdx = pointIt.getCurrentPointIndex () % cloud->width;

const PointT& point = *pointIt;
if (std::isfinite (point.x))
{
Scalar xx = point.x * point.x;
Scalar xy = point.x * point.y;
Scalar xz = point.x * point.z;
Scalar yy = point.y * point.y;
Scalar yz = point.y * point.z;
Scalar zz = point.z * point.z;
Scalar xx = static_cast<Scalar>(point.x) * static_cast<Scalar>(point.x);
Scalar xy = static_cast<Scalar>(point.x) * static_cast<Scalar>(point.y);
Scalar xz = static_cast<Scalar>(point.x) * static_cast<Scalar>(point.z);
Scalar yy = static_cast<Scalar>(point.y) * static_cast<Scalar>(point.y);
Scalar yz = static_cast<Scalar>(point.y) * static_cast<Scalar>(point.z);
Scalar zz = static_cast<Scalar>(point.z) * static_cast<Scalar>(point.z);
Scalar xx_yy = xIdx * xIdx + yIdx * yIdx;

A.coeffRef (0) += xx;
Expand Down

0 comments on commit 547df3c

Please sign in to comment.