opencv 与 netbeans C++ 链接器错误

opencv with netbeans c++ linker error

我正在尝试 运行 我在网上找到的以下代码,看看我是否正确设置了 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 中的所有库添加到链接器库中。

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

 using namespace cv;

高于或低于:

 using namespace std;