Ubuntu系統(tǒng)下如何在VScode配置OpenCV(C++)環(huán)境(.json文件)
創(chuàng)建一個(gè)test文件,用VScode打開(kāi)
(1)按住ctrl+shift+P搜索launch.json,點(diǎn)擊打開(kāi)即可
(2)按住ctrl+shift+P 打開(kāi)第一個(gè)
(1)、launch.json文件的配置
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "g++ - Build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}", //程序文件路徑 "args": [], //程序運(yùn)行需傳入的參數(shù) "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, //運(yùn)行時(shí)是否顯示控制臺(tái)窗口 "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: g++ build active file", "miDebuggerPath": "/usr/bin/gdb" } ] }
(2)、tasks.json文件
{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++ build active file", /* 與launch.json文件里的preLaunchTask的內(nèi)容保持一致 */ "command": "/usr/bin/g++", "args": [ "-std=c++11", "-g", //"${file}", /* 編譯單個(gè)文件 */ "${fileDirname}/*.cpp", /* 編譯多個(gè)文件 */ "-o", "${fileDirname}/${fileBasenameNoExtension}", /* 輸出文件路徑 */ /* 項(xiàng)目所需的頭文件路徑 */ "-I", "${workspaceFolder}/", "-I", "/usr/local/include/", "-I", "/usr/local/include/opencv4/", "-I", "/usr/local/include/opencv4/opencv2", /* 項(xiàng)目所需的庫(kù)文件路徑 */ "-L", "/usr/local/lib", /* OpenCV的lib庫(kù) */ "/usr/local/lib/libopencv_*" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Task generated by Debugger." } ], "version": "2.0.0" }
(3)、c_cpp_properties.json文件
{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/usr/local/include/opencv4", "/usr/include/**" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "gnu11", "cppStandard": "gnu++14", "intelliSenseMode": "linux-gcc-x64", "configurationProvider": "ms-vscode.makefile-tools" } ], "version": 4 }
(4)、測(cè)試
創(chuàng)建一個(gè)test.cpp文件,輸入測(cè)試代碼
#include <opencv2/opencv.hpp> #include <string> #include <iostream> using namespace std; int main(int argc, char* argv[]) { string Path = "test.jpg";//此處為的圖片路徑 //從文件中讀入圖像 cv::Mat img = cv::imread(Path, 1); //如果讀入圖像失敗 if (img.empty()) { cout<< "Not Found image"<<endl; return -1; } cv::imshow("image", img); //顯示圖像 cv::waitKey(); return 0; }
圖片顯示成功,配置完成?。ㄈ舫晒\(yùn)行仍有報(bào)錯(cuò)顯示,重啟VScode即可)
總結(jié)
到此這篇關(guān)于Ubuntu系統(tǒng)下如何在VScode配置OpenCV(C++)環(huán)境(.json文件)的文章就介紹到這了,更多相關(guān)Ubuntu VScode配置OpenCV環(huán)境內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C語(yǔ)言實(shí)現(xiàn)任何文件的加密解密功能
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)任何文件的加密解密功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03C++簡(jiǎn)單實(shí)現(xiàn)Dijkstra算法
這篇文章主要為大家詳細(xì)介紹了C++簡(jiǎn)單實(shí)現(xiàn)Dijkstra算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-05-05C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的五子棋小游戲
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的五子棋小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05C語(yǔ)言中單鏈表的基本操作(創(chuàng)建、銷(xiāo)毀、增刪查改等)
這篇文章主要介紹了C語(yǔ)言中單鏈表的基本操作(創(chuàng)建、銷(xiāo)毀、增刪查改等),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02QT利用QPdfWriter實(shí)現(xiàn)繪制PDF(支持表單輸出)
這篇文章主要為大家詳細(xì)介紹了QT如何利用QPdfWriter實(shí)現(xiàn)繪制PDF,并可以支持表單輸出。文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-01-01C++代碼和可執(zhí)行程序在x86和arm上的區(qū)別介紹
這篇文章主要介紹了C++代碼和可執(zhí)行程序在x86和arm上的區(qū)別,X86和ARM是占據(jù)CPU市場(chǎng)的兩大處理器,各有優(yōu)劣,本文給大家詳細(xì)介紹了兩者的區(qū)別,需要的朋友可以參考下2022-07-07