Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 265 additions & 72 deletions common/include/pcl/console/print.h

Large diffs are not rendered by default.

337 changes: 93 additions & 244 deletions common/src/print.cpp

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions examples/segmentation/example_cpc_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ CPCSegmentation Parameters: \n\
pcl::PCLPointCloud2 input_pointcloud2;
if (pcl::io::loadPCDFile (pcd_filename, input_pointcloud2))
{
PCL_ERROR ("ERROR: Could not read input point cloud %s.\n", pcd_filename.c_str ());
PCL_ERROR ("ERROR: Could not read input point cloud %s.\n", pcd_filename.c_str());
return (3);
}
pcl::fromPCLPointCloud2 (input_pointcloud2, *input_cloud_ptr);
Expand Down Expand Up @@ -361,9 +361,8 @@ CPCSegmentation Parameters: \n\
PCL_INFO ("Refining supervoxels\n");
super.refineSupervoxels (2, supervoxel_clusters);
}
std::stringstream temp;
temp << " Nr. Supervoxels: " << supervoxel_clusters.size () << "\n";
PCL_INFO (temp.str ().c_str ());

PCL_INFO(" Nr. Supervoxels: %zu\n", supervoxel_clusters.size());

PCL_INFO ("Getting supervoxel adjacency\n");
std::multimap<std::uint32_t, std::uint32_t>supervoxel_adjacency;
Expand Down
7 changes: 3 additions & 4 deletions examples/segmentation/example_lccp_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ LCCPSegmentation Parameters: \n\
pcl::PCLPointCloud2 input_pointcloud2;
if (pcl::io::loadPCDFile (pcd_filename, input_pointcloud2))
{
PCL_ERROR ("ERROR: Could not read input point cloud %s.\n", pcd_filename.c_str ());
PCL_ERROR ("ERROR: Could not read input point cloud %s.\n", pcd_filename.c_str());
return (3);
}
pcl::fromPCLPointCloud2 (input_pointcloud2, *input_cloud_ptr);
Expand Down Expand Up @@ -288,9 +288,8 @@ LCCPSegmentation Parameters: \n\
PCL_INFO ("Refining supervoxels\n");
super.refineSupervoxels (2, supervoxel_clusters);
}
std::stringstream temp;
temp << " Nr. Supervoxels: " << supervoxel_clusters.size () << "\n";
PCL_INFO (temp.str ().c_str ());

PCL_INFO(" Nr. Supervoxels: %zu\n", supervoxel_clusters.size());

PCL_INFO ("Getting supervoxel adjacency\n");
std::multimap<std::uint32_t, std::uint32_t> supervoxel_adjacency;
Expand Down
2 changes: 1 addition & 1 deletion octree/include/pcl/octree/impl/octree2buf_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Octree2BufBase<LeafContainerT, BranchContainerT>::setMaxVoxelIndex(

// tree depth == amount of bits of maxVoxels
treeDepth =
std::max<uindex_t>(std::min<uindex_t>(OctreeKey::maxDepth,
std::max<uindex_t>(std::min<uindex_t>(OctreeKey::getMaxDepth(),
std::ceil(std::log2(max_voxel_index_arg))),
0);

Expand Down
9 changes: 6 additions & 3 deletions octree/include/pcl/octree/impl/octree_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#ifndef PCL_OCTREE_BASE_HPP
#define PCL_OCTREE_BASE_HPP

#include <pcl/octree/octree_base.h>
#include <pcl/octree/octree_key.h>

#include <vector>

namespace pcl {
Expand Down Expand Up @@ -75,7 +78,7 @@ OctreeBase<LeafContainerT, BranchContainerT>::setMaxVoxelIndex(

// tree depth == bitlength of maxVoxels
tree_depth =
std::min(static_cast<uindex_t>(OctreeKey::maxDepth),
std::min(static_cast<uindex_t>(OctreeKey::getMaxDepth()),
static_cast<uindex_t>(std::ceil(std::log2(max_voxel_index_arg))));

setTreeDepth(tree_depth);
Expand All @@ -91,11 +94,11 @@ OctreeBase<LeafContainerT, BranchContainerT>::setTreeDepth(uindex_t depth_arg)
depth_arg);
return;
}
if (depth_arg > OctreeKey::maxDepth) {
if (depth_arg > OctreeKey::getMaxDepth()) {
PCL_ERROR("[pcl::octree::OctreeBase::setTreeDepth] Tree depth (%lu) must be <= max "
"depth(%lu)!\n",
depth_arg,
OctreeKey::maxDepth);
OctreeKey::getMaxDepth());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion octree/include/pcl/octree/impl/octree_pointcloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ pcl::octree::OctreePointCloud<PointT, LeafContainerT, BranchContainerT, OctreeT>

// tree depth == amount of bits of max_voxels
this->octree_depth_ = std::max<uindex_t>(
std::min<uindex_t>(OctreeKey::maxDepth,
std::min<uindex_t>(OctreeKey::getMaxDepth(),
std::ceil(std::log2(max_voxels) - minValue)),
0);

Expand Down
1 change: 0 additions & 1 deletion octree/include/pcl/octree/octree_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@
#include <pcl/octree/impl/octree_iterator.hpp>
#include <pcl/octree/impl/octree_pointcloud.hpp>
#include <pcl/octree/impl/octree_search.hpp>
#include <pcl/octree/octree.h>
11 changes: 10 additions & 1 deletion octree/include/pcl/octree/octree_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,19 @@ class OctreeKey {
(!!(this->z & depthMask)));
}

/* \brief maximum depth that can be addressed */
PCL_DEPRECATED(1, 18, "Use getMaxDepth() instead.")
static const unsigned char maxDepth =
static_cast<unsigned char>(sizeof(uindex_t) * 8);
Comment thread
larshg marked this conversation as resolved.

static unsigned char
getMaxDepth()
{
/* \brief maximum depth that can be addressed */
static const unsigned char maxDepth{
static_cast<unsigned char>(sizeof(uindex_t) * 8)};
return maxDepth;
}

// Indices addressing a voxel at (X, Y, Z)
// NOLINTBEGIN(modernize-use-default-member-init)
union {
Expand Down
1 change: 1 addition & 0 deletions octree/src/octree_inst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include <pcl/octree/octree.h>
#include <pcl/octree/octree_impl.h>
#include <pcl/octree/octree_key.h>

// Instantiations of specific point types

Expand Down
16 changes: 14 additions & 2 deletions sample_consensus/include/pcl/sample_consensus/sac_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace pcl

// Get a second point which is different than the first
samples.resize (getSampleSize ());
for (unsigned int iter = 0; iter < max_sample_checks_; ++iter)
for (unsigned int iter = 0; iter < getMaxSampleChecks(); ++iter)
{
// Choose the random indices
if (samples_radius_ < std::numeric_limits<double>::epsilon ())
Expand All @@ -189,7 +189,10 @@ namespace pcl
return;
}
}
PCL_DEBUG ("[pcl::SampleConsensusModel::getSamples] WARNING: Could not select %d sample points in %d iterations!\n", getSampleSize (), max_sample_checks_);
PCL_DEBUG("[pcl::SampleConsensusModel::getSamples] WARNING: Could not select "
"%d sample points in %d iterations!\n",
getSampleSize(),
getMaxSampleChecks());
samples.clear ();
}

Expand Down Expand Up @@ -347,6 +350,14 @@ namespace pcl
return sample_size_;
}

static unsigned int
getMaxSampleChecks()
{
/** The maximum number of samples to try until we get a good one */
static const unsigned int max_sample_checks_ = 1000;
return max_sample_checks_;
}

/** \brief Return the number of coefficients in the model. */
inline unsigned int
getModelSize () const
Expand Down Expand Up @@ -545,6 +556,7 @@ namespace pcl
IndicesPtr indices_;

/** The maximum number of samples to try until we get a good one */
PCL_DEPRECATED(1, 18, "Use getMaxSampleChecks() instead.")
static const unsigned int max_sample_checks_ = 1000;

/** \brief The minimum and maximum radius limits for the model.
Expand Down
1 change: 1 addition & 0 deletions test/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(NOT build)
endif()

# Args: name, executable_name
PCL_ADD_TEST(common_console test_console FILES test_console.cpp LINK_WITH pcl_gtest pcl_common)
PCL_ADD_TEST(common_test_wrappers test_wrappers FILES test_wrappers.cpp LINK_WITH pcl_gtest pcl_common)
PCL_ADD_TEST(common_test_macros test_macros FILES test_macros.cpp LINK_WITH pcl_gtest pcl_common)
PCL_ADD_TEST(common_vector_average test_vector_average FILES test_vector_average.cpp LINK_WITH pcl_gtest pcl_common)
Expand Down
108 changes: 108 additions & 0 deletions test/common/test_console.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include <pcl/test/gtest.h>

#include <pcl/console/print.h>
#include <pcl/point_types.h>

TEST(PCL, printStreamsMacros) {
pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);

PCL_ALWAYS_STREAM("Always_stream\n")
PCL_ERROR_STREAM("Error_stream\n")
Comment thread
larshg marked this conversation as resolved.
PCL_WARN_STREAM("Warn_stream\n")
PCL_INFO_STREAM("Info_stream: this is a point: " << pcl::PointXYZ(1.0, 2.0, 3.0)
<< "\n")
PCL_DEBUG_STREAM("Debug_stream\n")
PCL_VERBOSE_STREAM("Verbose_stream: an Eigen vector: "
<< "\n"
<< Eigen::Vector3f(1.0, 2.0, 3.0) << "\n")
}

TEST(PCL, printMacros)
{
pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);

PCL_ALWAYS("Always\n");
PCL_ERROR("Error\n");
PCL_WARN("Warn\n");
PCL_INFO("Info\n");
PCL_DEBUG("Debug\n");
PCL_VERBOSE("Verbose\n");
PCL_HIGH("High\n");
}

TEST(PCL, print)
{
pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);

pcl::console::print(pcl::console::L_ALWAYS, "Print always\n");

pcl::console::print_error("Error\n");
pcl::console::print_warn("Warn\n");
pcl::console::print_info("Info\n");
pcl::console::print_debug("Debug\n");
pcl::console::print(pcl::console::L_VERBOSE, "Print verbose\n");

pcl::console::print_highlight("Highlight\n");
pcl::console::print_value("%g\n", 0.001235);
}

void
callPrints()
{
pcl::console::print(pcl::console::L_ALWAYS, "Print always\n");
pcl::console::print_error("Error\n");
pcl::console::print_warn("Warn\n");
pcl::console::print_info("Info\n");
pcl::console::print_debug("Debug\n");
pcl::console::print(pcl::console::L_VERBOSE, "Print verbose\n");
}

TEST(PCL, checkLogLevel)
{
int callbackCount = 0;

pcl::console::setCallback(
[&callbackCount](const pcl::console::LogRecord& rec) {
std::cout << "Received logrecord: level:" << rec.level << " with message: " << rec.message;
callbackCount++;
});

pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS);
callPrints();
EXPECT_EQ(callbackCount, 1);

callbackCount = 0;
pcl::console::setVerbosityLevel(pcl::console::L_ERROR);
callPrints();
EXPECT_EQ(callbackCount, 2);

callbackCount = 0;
pcl::console::setVerbosityLevel(pcl::console::L_WARN);
callPrints();
EXPECT_EQ(callbackCount, 3);

callbackCount = 0;
pcl::console::setVerbosityLevel(pcl::console::L_INFO);
callPrints();
EXPECT_EQ(callbackCount, 4);

callbackCount = 0;
pcl::console::setVerbosityLevel(pcl::console::L_DEBUG);
callPrints();
EXPECT_EQ(callbackCount, 5);

callbackCount = 0;
pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);
callPrints();
EXPECT_EQ(callbackCount, 6);

}

/* ---[ */
int
main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return (RUN_ALL_TESTS());
}
/* ]--- */
10 changes: 4 additions & 6 deletions tools/train_linemod_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ bool
loadCloud (const std::string & filename, PointCloudXYZRGBA & cloud)
{
TicToc tt;
print_highlight ("Loading "); print_value ("%s ", filename.c_str ());
print_highlight ("Loading "); print_value ("%s ", filename);

tt.tic ();
if (loadPCDFile (filename, cloud) < 0)
return (false);

printElapsedTimeAndNumberOfPoints (tt.toc (), cloud.width, cloud.height);

print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (cloud).c_str ());
print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (cloud));

return (true);
}
Expand Down Expand Up @@ -271,15 +271,13 @@ main (int argc, char** argv)
if (!loadCloud (input_filename, *cloud))
{
error_code = -1;
std::string warn_msg = "Could not load point cloud from file: " + input_filename + "\n";
print_warn (warn_msg.c_str ());
print_warn("Could not load point cloud from file: " + input_filename + "\n");
continue;
}

if (!cloud->isOrganized())
{
std::string warn_msg = "Unorganized point cloud detected. Skipping file " + input_filename + "\n";
print_warn(warn_msg.c_str());
print_warn("Unorganized point cloud detected. Skipping file " + input_filename + "\n");
continue;
}
else
Expand Down