Fan*_*Fox 3 c++ iostream point-cloud-library
从这个问题:将函数输出重定向到/ dev / null我尝试使用以下代码:
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);
Run Code Online (Sandbox Code Playgroud)
但是我仍然从注册库中获得大量输出:
[pcl::IterativeClosestPoint::computeTransformation] Not enough correspondences found. Relax your threshold parameters.
Run Code Online (Sandbox Code Playgroud)
此输出是否有其他与众不同之处,可以阻止它被此捕获?是不是去cout还是cerr?
由于PCL具有多线程特性,因此标准管道cout和cerr常规管道将无法工作。相反,您需要使用PCL提供的内置功能来关闭控制台打印。
使用命令:
pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS)
Run Code Online (Sandbox Code Playgroud)
将关闭所有内容。还有其他级别,可以在pcl::console名称空间页面上找到更多信息 :
http://docs.pointclouds.org/trunk/a02895.html#a1c1202ab693383b98842cb4f72ae625c