ubuntu16.04+VSCode+opencv3.1-读取图片

一.打开vs,写入程序:
(注意:图片应该与.cpp文件在同一路径,且在程序中引用时应该写出完整的路径:/home/xxx/…/x.jpeg)
ubuntu16.04+VSCode+opencv3.1-读取图片_第1张图片
二.点击vscode左侧的Run,点击Run and Debug->打开备选框 -> C++(GDB/LLDB) -> g++ build and debug active file,会打开launch.json文件,修改其中的设置项,主要修改两个地方:
“externalConsole”: true,(非必须修改,根据需要)
“preLaunchTask”: “g++ build active file”,
三.点击左侧Explorer,再点击.vscode,点击task.json文件即可打开,修改为如下:

       "label": "g++ build active file",
        "command": "g++",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}",
            "-I","/usr/local/include",
            "-I","/usr/local/include/opencv",
            "-I","/usr/local/include/opencv2",
            "-L","/usr/local/lib",
            "-l","opencv_core",
            "-l","opencv_highgui",
            "-l","opencv_imgproc",
            "-l","opencv_imgcodecs",
            "-l","opencv_video",
            "-l","opencv_videoio"
        ]

四.Ctrl + Shift + P 打开搜索框,键入c++,会出现备选项目,选择图示Edit configurations (JSON),进入c_cpp_properties.json文件内进行配置修改。 “includePath”: 修改如下:

            "${workspaceFolder}/**",
            "/usr/local/include",
            "/usr/local/include/opencv",
            "/usr/local/include/opencv2"

五.保存完毕后,按F5即可编译成功!!
ubuntu16.04+VSCode+opencv3.1-读取图片_第2张图片

你可能感兴趣的:(opencv,imread,imshow,linux,opencv,c++)