如何在 VSCODE 中使用 OpenCV c++ [英] How to use the OpenCV c++ with VSCODE

查看:442
本文介绍了如何在 VSCODE 中使用 OpenCV c++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于此视频

main.cpp

#include #include #include 使用命名空间 cv;使用命名空间标准;int main( int argc, char** argv ){如果(argc != 2){cout <<" 用法:display_image ImageToLoadAndDisplay" <<结束;返回-1;}垫子图像;image = imread(argv[1], CV_LOAD_IMAGE_COLOR);//读取文件if(!image.data)//检查无效输入{cout<<无法打开或找到图像"<<std::endl ;返回-1;}namedWindow( "Display window", WINDOW_AUTOSIZE );//创建一个显示窗口.imshow( "显示窗口", image );//在其中显示我们的图像.等待键(0);//等待窗口中的按键返回0;}

我收到此错误

<块引用>

PS C:\Users\giorg\Documents\Development\Tests\node-addons-test\src\examples> g++ *.cppmain.cpp:1:33: 致命错误: opencv2/core/core.hpp: 没有那个文件或目录#包括^编译终止.

我设法包含了 dll,但我找不到如何包含扩展名为 .lib 的文件.

这是我的 c_cpp_properties.json 文件

<代码>{配置":[{"name": "Win32",包含路径":["${workspaceFolder}/**","${workspaceFolder}/src/lib","C:\\openCV\\opencv\\build\\include","C:\\openCV\\opencv\\build\\x64\\vc15\\lib" <=== 这是问题,如何包含这个],定义":["_DEBUG","统一编码",_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",智能感知模式":msvc-x64"}],版本":4}

解决方案

要包含 .lib 文件,您应该访问项目的属性 =>linker=>entries=>附加依赖项,然后添加您的 .lib 文件项目属性

Base on this video https://www.youtube.com/watch?v=l4372qtZ4dc I am trying to use OpenCV in vscode but I canot include the, .lib files what should I do

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;
}

I get this error

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.

I manage to include the dlls but I can't find how I can include the files with .lib extension.

this is my c_cpp_properties.json file

{
    "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
}

解决方案

to include the .lib files you should acces the properties of your project =>linker=>entries=>additional dependencies then add your .lib fileproperties of project

这篇关于如何在 VSCODE 中使用 OpenCV c++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆