如何用Visual Studio代码编译Opencv?
我用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吗?
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
}]
}}]}'
showOutput已弃用。它会要求你使用“演示文稿”,而“揭示”里面应该设置为“始终”。 – Antoni