【发布时间】:2017-05-07 08:06:43
【问题描述】:
我在 Visual Studio 2015 中使用 OpenCV 3.2.0 版,并且能够访问我的网络摄像头,直到我今天早上工作时突然之间。我无法弄清楚这个问题来自哪里。我现在得到:
它不会抛出任何错误,但也不会通过网络摄像头显示任何输入
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
VideoCapture cap;
cap.open(0);
if (!cap.isOpened())
{
printf("--(!)Error opening video capture\n");
return -3;
}
Mat image;
namedWindow("Image", CV_WINDOW_AUTOSIZE);
while (1)
{
cap.read(image);
imshow("Image", image);
waitKey(30);
}
return 0;
}
以前有人遇到过这个错误吗?
编辑: 我看过的东西:
我在 Google Hangouts 等应用中使用的网络摄像头,所以我认为这不是网络摄像头问题。
另外,我卸载了 Visual Studio 2015 并安装了 Visual Studio 2017,看看重新安装是否可以工作并且仍然得到相同的结果。
编辑:
当我创建一个新的 VideoCapture 对象时,我收到了错误 <information not available, no symboles loaded for opencv_world320d.dll>。我很确定我已正确包含所有内容。
配置属性 -> C/C++ -> 附加包含目录:
$(OPENCV_BUILD)\include
配置属性 -> 链接器 -> 常规:
$(OPENCV_BUILD)\x64\vc14\lib
配置属性->链接器->输入:
opencv_world320d.lib
【问题讨论】:
-
尝试在 while 循环中使用:
Mat frame; cap >> frame;,并在 while 之前删除Mat image。 -
@eyllanesc 否定。我使用
image而不是你建议的frame -
Mat对象的创建必须在循环内。
-
试试这个example
-
我删除了所有多余的东西,它给了我相同的屏幕。如果不删除东西,它会给我一个黑屏,因为它正在进入一个白屏。
标签: c++ opencv visual-studio-2015 computer-vision