小编Dej*_*jan的帖子

OpenCV 无法从网络摄像头捕获帧

我在 VS2010 中使用 OpenCV 2.4.6。

我认为我的网络摄像头无法捕捉画面。当我执行它成功构建的代码时,但我没有得到输出。我想,当我检查if(!bSuccess)它被执行并且无法从网络摄像头捕获帧时。

我该如何解决这个问题?我的代码如下:


#include "opencv2/highgui/highgui.hpp"
#include 

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    VideoCapture cap(0); // open the video camera no. 0

    if (!cap.isOpened())  // if not success, exit program
    {
    cout  << "Cannot open the video file" << endl;
        return -1;
    }

   double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
   double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the  video
    cout << …
Run Code Online (Sandbox Code Playgroud)

c++ opencv

5
推荐指数
1
解决办法
2万
查看次数

argc是什么意思?

我无法理解,OpenCV中的代码功能是什么,用于加载图像.什么是if(argc!= 2)的功能?你能告诉我一下吗?

 if( argc != 2)
    {
     cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
     return -1;
    }
Run Code Online (Sandbox Code Playgroud)

完整代码:

1 #include <opencv2/core/core.hpp>
2 #include <opencv2/highgui/highgui.hpp>
3 #include <iostream>
4
5 using namespace cv;
6 using namespace std;
7
8 int main( int argc, char** argv )
9 {
10 if( argc != 2)
11 {
12 cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
13 return -1;
14 }
15
16 Mat image;
17 image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×2

opencv ×1