我想用 OpenCV 打开视频文件 dt_passat.mpg
。我使用以下代码:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
VideoCapture capture("dt_passat.mpg");
if (!capture.isOpened()) {
std::cerr << "ERR: capture is not opened" << std::endl;
getchar();
return -1;
}
}
但是,它失败了,我不知道为什么。如何了解 VideoCapture 初始化的问题点(未找到文件/损坏的文件/未知编解码器/等)?
最佳答案
不幸的是,OpenCV 并不总是有最好的文档。
您可以尝试使用 cvGetErrorStatus()
查看内部错误代码,然后使用 cvErrorStr()
将其转换为可读字符串。请参阅http://opencv.willowgarage.com/documentation/c/core_utility_and_system_functions_and_macros.html#cvGetErrStatus
关于c++ - 我怎样才能知道 OpenCV 的 VideoCapture 初始化时出了什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16752255/