在 OpenCV 中播放视频:无错误无输出
video playing in opencv: no error no output
我编写了一个程序来显示存储的视频文件,使用 opencv
.我附上了下面的代码。我在构建它时没有收到任何错误,但没有显示输出。
int main(int argc, char *argv[])
{
if (argc <= 1)
{
printf("Usage: %s videon", argv[0]);
return -1;
}
VideoCapture capture(argv[1]);
namedWindow("display",cv::WINDOW_AUTOSIZE);
capture.set(cv::CAP_PROP_FRAME_WIDTH, 640);
capture.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
if(!capture.isOpened())
{
printf("Failed to open the videon");
return -1;
}
int i;
for(i=0;i<390;i++)
{
Mat frame;
capture >> frame; // get a new frame from camera
cout << "frame =" << endl << " " << frame << endl << endl;
imshow("display",frame);
}
}
我在末尾包含cout
行以检查帧是否获得任何值。所以 a 在矩阵中得到了许多值,但视频窗口没有出现。
您必须
在使用waitKey
imshow
后添加非常小的延迟。
imshow("display",frame);
waitKey(10); //Wait 10 milliseconds before showing next frame.
相关文章:
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- 显示错误输出的简单数组排序程序
- 多线程减慢程序速度:无错误共享,无互斥锁,无缓存未命中,无小工作量
- Dijkstra 中的错误输出
- 自定义runtime_error,如果我在 #what 中使用#c_str(),则错误输出始终为空
- 流字符串错误输出
- C++ 异常处理错误输出
- C ++中的错误输出,i = 65530,当我们打印i的值时,它给出-6状态65530
- SSE和iostream:浮点类型的错误输出
- C++将 popen 错误输出读取为字符串
- 如何将 Openh264 解码帧无延迟输出格式转换为 OpenCV 矩阵
- 为什么可以无错误地编译此片段
- 部分透视/高斯消除 - 交换列而不是产生错误输出的行
- 获得程序输出(无错误),但程序.exe在使用 graphics.h 时不起作用
- C++,向量:获得包含 0 的错误输出
- C 在代码中初始化字符串变量时无控制台输出
- 数组函数错误输出
- CC1plus 错误:输出文件名指定两次
- 字符串错误输出
- 在 OpenCV 中播放视频:无错误无输出