opencv与netbeans c ++链接器错误

时间:2015-09-04 01:08:51

标签: c++ opencv netbeans linker

我试图运行以下在线发现的代码,看看我是否正确设置了opencv,

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

using namespace std;

int main(int argc, char** argv) {

namedWindow("Output",1);

//initialize a 120X350 matrix of black pixels:
Mat output = Mat::zeros( 120, 350, CV_8UC3 );

//write text on the matrix:
putText(output,
        "Hello World :)",
        cvPoint(15,70),
        FONT_HERSHEY_PLAIN,
        3,
        cvScalar(0,255,0),
        4);

//display the image:
imshow("Output", output);

//wait for the user to press any key:
waitKey(0);

return 0;

}

我编译时遇到以下错误,

main.cpp: In function 'int main(int, char**)':
main.cpp:12:27: error: 'namedWindow' was not declared in this scope
main.cpp:15:5: error: 'Mat' was not declared in this scope
main.cpp:15:9: error: expected ';' before 'output'
main.cpp:18:13: error: 'output' was not declared in this scope
main.cpp:21:13: error: 'FONT_HERSHEY_PLAIN' was not declared in this     scope
main.cpp:24:14: error: 'putText' was not declared in this scope
main.cpp:27:28: error: 'imshow' was not declared in this scope
main.cpp:30:14: error: 'waitKey' was not declared in this scope
nbproject/Makefile-Debug.mk:66: recipe for target `build/Debug/MinGW-  Windows/main.o' failed

我在Windows上编译了opencv 3.0.0,并且我已将以下属性添加到我的项目中, 包含目录 - E:/ software / opencv / build / include 其他库目录 - E:/ software / opencv / release / lib 我已经将E:/ software / opencv / release / lib中的所有库添加到链接器库中。

1 个答案:

答案 0 :(得分:1)

我认为这可能很容易解决。 添加:

 using namespace cv;

高于或低于:

 using namespace std;