基于此视频 https://www.youtube.com/watch?v=l4372qtZ4dc 我正在尝试在 vscode 中使用 OpenCV,但我无法包含 .lib 文件我应该怎么做
main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
我收到这个错误
PS C:\Users\giorg\Documents\Development\Tests\node-addons-test\src\examples> g++ *.cpp main.cpp:1:33: fatal error: opencv2/core/core.hpp: No such file or directory #include ^ compilation terminated.
我设法包含了 dll,但找不到如何包含扩展名为 .lib 的文件。
这是我的 c_cpp_properties.json 文件
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/lib",
"C:\\openCV\\opencv\\build\\include",
"C:\\openCV\\opencv\\build\\x64\\vc15\\lib" <=== this is the problem , how to include this
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17134.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
最佳答案
为什么不加一个CMakeLists.txt来使用cmake呢,而且还是跨平台的,简单易用。 我也使用 VS Code。我建议使用 cmake。
关于c++ - 如何在 VSCODE 中使用 OpenCV C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51564772/