OpenCV - highgui.hpp中的错误

时间:2015-09-23 11:42:17

标签: opencv ubuntu cmake

我正在尝试使用网络摄像头检测车道。我可以在开始时编译它并测试它但是在更改我曾经工作的机器之后。 它不再工作了。给我一些错误。

以下是代码

int run() {

    bool pause = false`;`
    VideoCapture cam(0);
    //VideoCapture cam("clip.mp4");
    if(!cam.isOpened())
    {
        cout<<"\n Error Opening Device"<<endl;
        return 0;
    }
    width=cam.get(CV_CAP_PROP_FRAME_WIDTH);
    height=cam.get(CV_CAP_PROP_FRAME_HEIGHT);
    init();
    while(1)
    {
        cam >> frame;
        frameclone=frame.clone();
        drawElement(frame);
        imshow("Live Feed",frame);
        cvtColor(frameclone,bw,CV_RGB2GRAY);
        blur( bw, bw, Size(5,5) );
        Canny( bw, canny,0,75,3);
        imshow("canny",canny);
        regionofinterest();
        cvtColor(canny,canny,CV_GRAY2BGR);
        imshow("debug",canny);
        //houghT();
        imshow("ROI",frame);
        switch(waitKey(18))
        {
            case 113:
                cout<<"Exiting"<<endl;
                return -1;
                break;
            case 033:
                cout<<"Exiting"<<endl;
                return -1;
                break;
            case 112:
                pause=!pause;
                cout<<"Code Paused"<<endl;
                if(pause==true)
                {
                    switch(waitKey())
                        case 112:
                            pause=!pause;
                            cout<<"Code Resumed"<<endl;
                            break;
                }
        }
    }
}

我还包括

#include "opencv2/opencv.hpp"
#include "opencv2/photo/photo.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "iostream"
#include "stdio.h"

但它仍然给我以下错误: -

/home/ashik/Desktop/Project/detectlane/detectlane.cpp: In member function ‘void Detect::init()’:

/home/ashik/Desktop/Project/detectlane/detectlane.cpp:35:23: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
   namedWindow("debug",CV_WINDOW_AUTOSIZE);
                       ^

/home/ashik/Desktop/Project/detectlane/detectlane.cpp:36:23: error: ‘CV_WINDOW_NORMAL’ was not declared in this scope
   namedWindow("canny",CV_WINDOW_NORMAL);
                       ^

/home/ashik/Desktop/Project/detectlane/detectlane.cpp: In member function ‘int Detect::run()’:


/home/ashik/Desktop/Project/detectlane/detectlane.cpp:89:17: error: 
‘CV_CAP_PROP_FRAME_WIDTH’ was not declared in this scope
   width=cam.get(CV_CAP_PROP_FRAME_WIDTH);
                 ^
/home/ashik/Desktop/Project/detectlane/detectlane.cpp:90:18: error: ‘CV_CAP_PROP_FRAME_HEIGHT’ was not declared in this scope
   height=cam.get(CV_CAP_PROP_FRAME_HEIGHT);
                  ^

/home/ashik/Desktop/Project/detectlane/detectlane.cpp:98:27: error: ‘CV_RGB2GRAY’ was not declared in this scope
    cvtColor(frameclone,bw,CV_RGB2GRAY);
                           ^

/home/ashik/Desktop/Project/detectlane/detectlane.cpp:103:25: error: ‘CV_GRAY2BGR’ was not declared in this scope
    cvtColor(canny,canny,CV_GRAY2BGR);
                         ^

make[2]: *** [CMakeFiles/detectlane.dir/detectlane.cpp.o] Error 1
make[1]: *** [CMakeFiles/detectlane.dir/all] Error 2
make: *** [all] Error 2

我使用了cmake和opencv 3.0.0 alpha

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。尝试包括

#include <highgui.h>