致命错误:opencv2 / opencv.hpp:没有这样的文件或目录

时间:2018-07-28 13:34:16

标签: c++ opencv visual-studio-code

我正在使用VScode,如果我运行: g++ main.cpp

我收到此错误:

  

PS C:\ Users \ giorg \ Documents \ Development \ Tests \ node-addons-test \ src> g ++ main.cpp

main.cpp:2:30: fatal error: opencv2/opencv.hpp: No such file or directory
 #include <opencv2/opencv.hpp>
                              ^

project / src / main.cpp

#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
  if ( argc != 2 )
  {
      printf("usage: DisplayImage.out <Image_Path>\n");
      return -1;
  }

  Mat image;
  image = imread( argv[1], 1 );

  if ( !image.data )
  {
      printf("No image data \n");
      return -1;
  }
  namedWindow("Display Image", WINDOW_AUTOSIZE );
  imshow("Display Image", image);

  waitKey(0);

  return 0;
}

project / .vscode / c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/src/lib",
                "${workspaceFolder}/src",
                "C:\\openCV\\opencv\\build\\include"
            ],
            "browse": {
                "path": [
                    "C:\\openCV\\opencv\\build\\x64\\vc15\\lib"
                ]
            },
            "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
}

我应该怎么做才能在vscode上使用opencv? 在此先感谢您,我相信会有更多的开发人员面临此问题,并且更多的开发人员将在功能上面对这一问题。

我尝试过的

enter image description here它不起作用

此外,必须包含此文件,但我不知道如何

enter image description here

0 个答案:

没有答案