Ask Your Question

Revision history [back]

Cannot compile houghline.cpp after installing openCV 2.4.9

When i compile openCV2.4.9 sample code using following command

g++ houghlines.cpp -o application `pkg-config --cflags --libs opencv`

I get following errors, any suggestions pointers to solve it ?

houghlines.cpp:6:17: error: ‘cv’ is not a namespace-name
 using namespace cv;
                 ^
houghlines.cpp:6:19: error: expected namespace-name before ‘;’ token
 using namespace cv;
                   ^
houghlines.cpp: In function ‘int main(int, char**)’:
houghlines.cpp:20:5: error: ‘Mat’ was not declared in this scope
     Mat src = imread(filename, 0);
     ^
houghlines.cpp:20:9: error: expected ‘;’ before ‘src’
     Mat src = imread(filename, 0);
         ^
houghlines.cpp:21:8: error: ‘src’ was not declared in this scope
     if(src.empty())
        ^
houghlines.cpp:28:9: error: expected ‘;’ before ‘dst’
     Mat dst, cdst;
         ^
houghlines.cpp:29:11: error: ‘src’ was not declared in this scope
     Canny(src, dst, 50, 200, 3);
           ^
houghlines.cpp:29:16: error: ‘dst’ was not declared in this scope
     Canny(src, dst, 50, 200, 3);
                ^
houghlines.cpp:29:31: error: ‘Canny’ was not declared in this scope
     Canny(src, dst, 50, 200, 3);
                               ^
houghlines.cpp:30:19: error: ‘cdst’ was not declared in this scope
     cvtColor(dst, cdst, COLOR_GRAY2BGR);
                   ^
houghlines.cpp:30:25: error: ‘COLOR_GRAY2BGR’ was not declared in this scope
     cvtColor(dst, cdst, COLOR_GRAY2BGR);
                         ^
houghlines.cpp:30:39: error: ‘cvtColor’ was not declared in this scope
     cvtColor(dst, cdst, COLOR_GRAY2BGR);
                                       ^
houghlines.cpp:49:5: error: ‘vector’ was not declared in this scope
     vector<Vec4i> lines;
     ^
houghlines.cpp:49:12: error: ‘Vec4i’ was not declared in this scope
     vector<Vec4i> lines;
            ^
houghlines.cpp:49:19: error: ‘lines’ was not declared in this scope
     vector<Vec4i> lines;
                   ^
houghlines.cpp:50:32: error: ‘CV_PI’ was not declared in this scope
     HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
                                ^
houghlines.cpp:50:54: error: ‘HoughLinesP’ was not declared in this scope
     HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
                                                      ^
houghlines.cpp:53:15: error: expected ‘;’ before ‘l’
         Vec4i l = lines[i];
               ^
houghlines.cpp:54:27: error: ‘l’ was not declared in this scope
         line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
                           ^
houghlines.cpp:54:37: error: ‘Point’ was not declared in this scope
         line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
                                     ^
houghlines.cpp:54:73: error: ‘Scalar’ was not declared in this scope
         line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
                                                                         ^
houghlines.cpp:54:79: error: ‘CV_AA’ was not declared in this scope
         line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
                                                                               ^
houghlines.cpp:54:84: error: ‘line’ was not declared in this scope
         line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
                                                                                    ^
houghlines.cpp:57:25: error: ‘imshow’ was not declared in this scope
     imshow("source", src);
                         ^
houghlines.cpp:60:13: error: ‘waitKey’ was not declared in this scope
     waitKey();
             ^