编译器无法识别OpenCV库

时间:2015-05-29 12:18:08

标签: c++ opencv visual-studio-2013

我正在使用Visual Studio 2013和opencv 3.0.0。 我想运行这段代码:

#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;

int main(){

    //Generate matrix to store image
    Mat image;

    //initialize capture
    VideoCapture cap;
    cap.open(0);

    //Create window to show image
    namedWindow("window", 1);

    while (1){
        //copy webcam stream to image
        cap >> image;

        //print image to screen
        imshow("window", image);

        //delay 33ms
        waitKey(33);

    }

}

但是,我收到了以下错误:

first.cpp(12): error C2065: 'VideoCapture' : undeclared identifier
1>first.cpp(12): error C2146: syntax error : missing ';' before identifier 'cap'
1>first.cpp(12): error C2065: 'cap' : undeclared identifier
1>first.cpp(13): error C2065: 'cap' : undeclared identifier
1>first.cpp(13): error C2228: left of '.open' must have class/struct/union
1>          type is 'unknown-type'
1>first.cpp(16): error C3861: 'namedWindow': identifier not found
1>first.cpp(20): error C2065: 'cap' : undeclared identifier
1>first.cpp(23): error C3861: 'imshow': identifier not found
1>first.cpp(26): error C3861: 'waitKey': identifier not found
1>
1>Build FAILED.

我方便地链接了这个库。编译器接收opencv库。但是,它会产生这样的错误。

0 个答案:

没有答案