5

From this question: Redirecting function output to /dev/null I have tried to employ the following code:

 std::ofstream catchPCLStream("/dev/null");
 std::streambuf *originalOutputBuffer = std::cout.rdbuf();
 std::cout.rdbuf(catchPCLStream.rdbuf());
 std::cerr.rdbuf(catchPCLStream.rdbuf());

 icp_.align(dataCloudTransformedByIcp_, icpInternalUpdatePose_);

 std::cout.rdbuf(originalOutputBuffer);
 std::cerr.rdbuf(originalOutputBuffer);

But I still get a huge amount of output from the registration library:

[pcl::IterativeClosestPoint::computeTransformation] Not enough correspondences found. Relax your threshold parameters.

Is there something different about this output that stops it from being caught by this? Is it not going to cout or cerr?

Community
  • 1
  • 1
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175

1 Answers1

12

Due to the multi-threaded nature of PCL, the standard pipe cout and cerr away wont work. Instead you need to use the in-built functions provided by PCL to turn off the console printing.

Using the command:

pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS)

Will turn everything off. There are also other levels and more information can be found on the pcl::console namespace page:

http://docs.pointclouds.org/trunk/a02895.html#a1c1202ab693383b98842cb4f72ae625c

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175