gpt4 book ai didi

windows - OpenCV VideoCapture 在 Visual Studio 2017 (Windows 10) 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 23:07:50 25 4
gpt4 key购买 nike

我有一个很奇怪的问题。当我从 Visual Studio 运行 C++ 应用程序时,VideoCapture 既不打开网络摄像头也不打开视频文件,如果是网络摄像头,则会出现以下错误:

WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'

其次是

Microsoft C++ exception: _com_error at memory location 0x000000D9B66FCBB0. Microsoft C++ exception: _com_error at memory location 0x000000D9B66FCAA0. Microsoft C++ exception: cv::Exception at memory location 0x000000D9B66FEFD0. Microsoft C++ exception: cv::Exception at memory location 0x000000D9B66FEFD0.

但是当我从 VS 外部运行应用程序时,一切正常。我使用 OpenCV v4.0.0

最佳答案

要诊断您的问题,请先尝试以下操作并向我提供反馈。

#include <opencv2/opencv.hpp>

using namespace cv;

int main()
{
VideoCapture cap(0); // open the default camera
if (!cap.isOpened()) // check if we succeeded
return -1;

Mat edges;
Mat frame;
namedWindow("edges", WINDOW_NORMAL);

while (true)
{
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, COLOR_RGB2GRAY);
GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5);
Canny(edges, edges, 0, 50, 3);
imshow("edges", edges);
if (waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
}

所需的库:

opencv_core401.lib
opencv_imgproc401.lib
opencv_videoio401.lib
opencv_highgui401.lib

关于windows - OpenCV VideoCapture 在 Visual Studio 2017 (Windows 10) 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55523837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com