c++ - 禁用 OpenCV VideoWriter 输出

标签 c++ opencv stl cout

当我使用 OpenCV 的 VideoWriter 类创建视频时,它会在终端中输出如下内容:

Output #0, avi, to 'video.avi':
Stream #0.0: Video: mpeg4, yuv420p, 512x384, q=2-31, 12582 kb/s, 90k tbn, 24 tbc

我想禁用它,但我不知道该怎么做。

最佳答案

将控制台“静音”一会儿。 Ref .

#include <iostream>
#include <fstream>
int main ( int argc, char** argv )
{
    std::streambuf* cout_sbuf = std::cout.rdbuf(); // save original sbuf
    std::ofstream   fout("temp");
    std::cout<<"A\n";
    std::cout.rdbuf(fout.rdbuf()); // redirect 'cout' to a 'fout'
    std::cout<<"B\n";
    std::cout.rdbuf(cout_sbuf); // restore the original stream buffer
    std::cout<<"C\n";
    return 0;
}

控制台输出:

A
C

关于c++ - 禁用 OpenCV VideoWriter 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23217239/

相关文章:

c++ - 如何在 C 程序中将日志记录逻辑与业务逻辑分开?而在 C++ 中呢?

C++ "expression must be a modifiable lvalue"错误

c++ - vector 分配是否会使 `reserve` 无效?

python - 在 Tkinter 中高效显示 OpenCV IplImage

java - 暴力匹配是否适用于 FREAK 描述符?

c++ - 处理数字的流对象

c++ - remove_if 字符串匹配集合中的给定字符串

c++ - xiAPI : Failed to change thread scheduler, 检查实时优先级的用户限制

c++ - 使用来自 OpenCV 的 .hpp 头文件

c++ - 在 map 中插入数组元素的时间复杂度是多少?