Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress cout output from pcl registration

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?

like image 393
Fantastic Mr Fox Avatar asked Jun 05 '14 23:06

Fantastic Mr Fox


1 Answers

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

like image 81
Fantastic Mr Fox Avatar answered Nov 16 '22 23:11

Fantastic Mr Fox