Suppress cout output from pcl registration
Asked Answered
P

1

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?

Pilgrimage answered 5/6, 2014 at 23:32 Comment(16)
Have you tried std::cout.rdbuf(0); before calling your function?Kwiatkowski
The output still being shown on the console?Perplex
@0x499602D2 yes, very much so, its verbose and in red.Pilgrimage
@KristerAndersson It continues to print. even with std::cout.rdbuf(0/Null/nullptr)Pilgrimage
Is your program multithreaded?Perplex
Try doing the same with the stderr std::cerr.rdbuf(0);Kwiatkowski
@KristerAndersson I am redirecting both. It continues to print to the screen.Pilgrimage
@0x499602D2 My program is not but it is possible that the printing by pcl could be?Pilgrimage
@Ben That's what I'm suspicious about, yes.Perplex
@0x499602D2 perhaps pcl provides a method to suppress error output? Otherwise I have found where my particular thing prints, I could edit the source code, although i would absolutely prefer not to.Pilgrimage
@0x499602D2 it looks like there is an option to disable output here: pixinsight.com/developer/pcl/doc/html/… but i am getting a cant find header when i include pcl/Exception.hPilgrimage
Check the folder for where you're including the files. Do you see Exception.h anywhere?Perplex
@0x499602D2 yeah i am looking, doesnt appear, im not sure where to find this file?Pilgrimage
Actually now from grepping it doesnt look like DisableConsoleOutput appears anywhere in my pcl include files. Maybe it has been replaced? I also cant access the pcl website for some reason atmPilgrimage
@Ben Try #include <pcl/io/io_exception.h>Perplex
Let us continue this discussion in chat.Pilgrimage
P
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

Pilgrimage answered 6/6, 2014 at 1:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.