gpt4 book ai didi

c++ - opencv 与 netbeans C++ 链接器错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:55:04 25 4
gpt4 key购买 nike

我正在尝试运行我在网上找到的以下代码,看看我是否已正确设置 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;

关于c++ - opencv 与 netbeans C++ 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32388654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com