我怎样才能得到OpenCV的VideoCapture初始化时出了什么问题?
How can I get what went wrong in initialization of OpenCV's VideoCapture?
我想用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;
}
}
然而,它失败了,我不知道为什么。我怎么能得到问题的点与videoccapture的初始化(未找到文件/损坏的文件/未知的编解码器/等)?
不幸的是,OpenCV并不总是有最好的文档。
您可以尝试使用cvGetErrorStatus()
查看内部错误代码,然后使用cvErrorStr()
将其转换为可读字符串。看到http://opencv.willowgarage.com/documentation/c/core_utility_and_system_functions_and_macros.html cvGetErrStatus
opencv的图像/视频/相机IO和gui实际上只是为了获得样本数据进出测试算法,使一个真正的应用程序,你需要一个更强大的通用库系统的东西。
但是实际的图像处理算法质量相当不错。
相关文章:
- 未初始化的变量有什么危险
- 初始化或分配空字符串文字到指向 C 中的 char 的指针或指向 C++ 中 const char 的指针的原因是什么
- 不同的类或结构初始化方法之间的性能差异是什么?
- 初始化数组、"memset"或" {//value} "的最佳方法是什么?
- C++ 未初始化的本地(非全局)int 数组中的元素类型到底是什么?
- 静态初始化的反义词是什么?
- 它解决了什么问题,对于非真空初始化,生命周期在初始化之前就开始了
- 初始化不是整数的巨大常量多维数组的最佳方法是什么?
- 使用 const char* 初始化 const ref 字符串成员时幕后会发生什么
- 初始化类成员的更好做法是什么?
- C++初始化的结果是什么?
- 如果在 C++ 构造函数中以错误的顺序初始化对象数据,会发生什么类型的错误
- 这些初始化之间有什么区别?
- 初始化对象以在 C++08 中作为参数传递的首选语法是什么?
- 构造函数中没有参数的对象类成员按什么顺序初始化?
- 两种初始化有什么区别:Foo f();Foo f = Foo()
- 在多个对象中初始化预定义成员变量的正确方法是什么?
- 统一初始化是隐式发生的,即使 int 强制转换运算符是使用 explicit 关键字声明的.原因是什么?
- 在C++中初始化带有和不使用构造函数调用的对象有什么区别
- C++11 大括号/聚合初始化.什么时候使用它?