2016-11-29 130 views
1

我用brew安裝了opencv3。我多次嘗試設置pkg-config,但是我無法成功編譯。我在互聯網上搜索的方式,但我無法找到。如何用Visual Studio代碼編譯Opencv?

的任務是如下:

{ 
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format 
    "version": "0.1.0", 
    "command": "g++", 
    "isShellCommand": true, 
    "showOutput": "always", 
    "suppressTaskName": true, 
    "tasks": [ 
     { 
      "taskName": "build", 
      "isBuildCommand": true, 
      "args": [ 
       `pkg-config --libs opencv --cflags opencv`, 
       "-o", 
       "vsc", 
       "${workspaceRoot}/main.cpp", 
       "-g" // Debug 
      ], 
      "showOutput": "always" 
     } 
    ] 
} 

pkg-config是象下面這樣:

pkg配置--libs

$ pkg-config --libs opencv 
-L/usr/local/Cellar/opencv3/3.1.0_3/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lippicv -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core 

pkg配置--cflags

$ pkg-config --cflags opencv 
-I/usr/local/Cellar/opencv3/3.1.0_3/include/opencv -I/usr/local/Cellar/opencv3/3.1.0_3/include 

你知道如何用Visual Studio代碼編譯opencv嗎?

回答

0

OS:的Ubuntu 16.04,OpenCV的版本:3.2.0,程序文件名:videocapture_starter.cpp和輸出文件名:videocapture_starter

要建立我用下面的task.json文件

{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "g++", "isShellCommand": true, "showOutput": "always", "args": ["-g", "videocapture_starter.cpp", "-o", "videocapture_starter", "-I/usr/local/include/opencv", "-I/usr/local/include","-I/usr/include", "-L/usr/local/lib", "-lopencv_shape", "-lopencv_stitching", "-lopencv_objdetect", "-lopencv_superres", "-lopencv_videostab", "-lopencv_calib3d", "-lopencv_features2d", "-lopencv_highgui", "-lopencv_videoio", "-lopencv_imgcodecs", "-lopencv_video", "-lopencv_photo", "-lopencv_ml", "-lopencv_imgproc", "-lopencv_flann", "-lopencv_core"] }

要調試我用下面的launch.json文件 「{ 「版本」 的方案: 「0.2.0」, 「配置」: [

{ 
    "name": "C++ Launch", 
    "type": "cppdbg", 
    "request": "launch", 
    "program": "${workspaceRoot}/videocapture_starter", 
    "args": ["0"], 
    "stopAtEntry": false, 
    "cwd": "${workspaceRoot}", 
    "environment": [], 
    "externalConsole": true, 
    "linux": { 
    "MIMode": "gdb", 
    "includePath": ["/usr/include", "/usr/local/include/opencv", "/usr/local/include"], 
    "setupCommands": [ 
     { 
     "description": "Enable pretty-printing for gdb", 
     "text": "-enable-pretty-printing", 
     "ignoreFailures": true 
     }] 
    } 
}, 
{ 
    "name": "C++ Attach", 
    "type": "cppdbg", 
    "request": "attach", 
    "program": "${workspaceRoot}/a.out", 
    "processId": "${command:pickProcess}", 
    "linux": { 
    "MIMode": "gdb", 
    "setupCommands": [ 
     { 
     "description": "Enable pretty-printing for gdb", 
     "text": "-enable-pretty-printing", 
     "ignoreFailures": true 
     }] 
    }}]}' 
+0

showOutput已棄用。它會要求你使用「演示文稿」,而「揭示」裏面應該設置爲「始終」。 – Antoni