Skip to content

Commit

Permalink
Fix multiple small errors and make improvements
Browse files Browse the repository at this point in the history
- Simplify tools/image_viewer.cpp
- OrganizedFastMesh: add test whether input is organized
- extractEuclideanClusters: replace exit (should not be used in libraries)
- OrganizedPointCloudCompression: add return in case of stream error
  • Loading branch information
mvieth committed Dec 23, 2022
1 parent 7287da7 commit 8b9fc03
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ namespace pcl

// decode PNG compressed rgb data
decodePNGToImage (compressedColor, colorData, png_width, png_height, png_channels);
} else {
PCL_ERROR("[OrganizedPointCloudCompression::decodePointCloud] Unable to find an encoded point cloud in the input stream!\n");
return false;
}

if (disparityShift==0.0f)
Expand Down
4 changes: 2 additions & 2 deletions registration/include/pcl/registration/bfgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct BFGSDummyFunctor {
virtual void
fdf(const VectorType& x, Scalar& f, VectorType& df) = 0;
virtual BFGSSpace::Status
checkGradient(const VectorType& g)
checkGradient(const VectorType& /*g*/)
{
return BFGSSpace::NotStarted;
};
Expand Down Expand Up @@ -351,7 +351,7 @@ BFGS<FunctorType>::minimize(FVectorType& x)
BFGSSpace::Status status = minimizeInit(x);
do {
status = minimizeOneStep(x);
iter++;
++iter;
} while (status == BFGSSpace::Success && iter < parameters.max_iters);
return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ pcl::extractEuclideanClusters (const PointCloud<PointT> &cloud,
}

//////////////////////////////////////////////////////////////////////////////////////////////
/** @todo: fix the return value, make sure the exit is not needed anymore*/
template <typename PointT> void
pcl::extractEuclideanClusters (const PointCloud<PointT> &cloud,
const Indices &indices,
Expand Down Expand Up @@ -174,7 +173,7 @@ pcl::extractEuclideanClusters (const PointCloud<PointT> &cloud,
if( ret == -1)
{
PCL_ERROR("[pcl::extractEuclideanClusters] Received error code -1 from radiusSearch\n");
exit(0);
return;
}
if (!ret)
{
Expand Down
8 changes: 8 additions & 0 deletions surface/include/pcl/surface/impl/organized_fast_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
template <typename PointInT> void
pcl::OrganizedFastMesh<PointInT>::performReconstruction (pcl::PolygonMesh &output)
{
if (!input_->isOrganized()) {
PCL_ERROR("[OrganizedFastMesh::performReconstruction] Input point cloud must be organized but isn't!\n");
return;
}
reconstructPolygons (output.polygons);

// Get the field names
Expand All @@ -69,6 +73,10 @@ pcl::OrganizedFastMesh<PointInT>::performReconstruction (pcl::PolygonMesh &outpu
template <typename PointInT> void
pcl::OrganizedFastMesh<PointInT>::performReconstruction (std::vector<pcl::Vertices> &polygons)
{
if (!input_->isOrganized()) {
PCL_ERROR("[OrganizedFastMesh::performReconstruction] Input point cloud must be organized but isn't!\n");
return;
}
reconstructPolygons (polygons);
}

Expand Down
10 changes: 3 additions & 7 deletions tools/image_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,17 @@
int
main (int, char ** argv)
{
pcl::PCDReader reader;
pcl::PCLPointCloud2 cloud;
reader.read (argv[1], cloud);

pcl::PointCloud<pcl::PointXYZ> xyz;
pcl::fromPCLPointCloud2 (cloud, xyz);
pcl::io::loadPCDFile(argv[1], xyz);

pcl::visualization::ImageViewer depth_image_viewer_;
float* img = new float[cloud.width * cloud.height];
float* img = new float[xyz.width * xyz.height];

for (int i = 0; i < static_cast<int> (xyz.size ()); ++i)
img[i] = xyz[i].z;

depth_image_viewer_.showFloatImage (img,
cloud.width, cloud.height,
xyz.width, xyz.height,
std::numeric_limits<float>::min (),
// Scale so that the colors look brigher on screen
std::numeric_limits<float>::max () / 10,
Expand Down

0 comments on commit 8b9fc03

Please sign in to comment.