Vscode与Cmake搭配配置opencv使用

vscode与Cmake基本使用

  1. 下载插件
  2. Ctrl+Shift+p打开VSCode的指令面板,然后输入cmake:q,VSCode会根据输入自动提示,然后选择CMake: Quick Start
  3. 选择编译器
  4. 根据提示输入项目名称
  5. 选择可执行文件
  6. 编译项目
    • 方式一:执行命令

      bash 复制代码
      cd build
      cmake ..
    • 方式二: VSCode提供了更便捷的方式(点击底部的Build)

opencv 配置

  1. cmake文件内容

    bash 复制代码
    message(STATUS "Setting up OpenCV libs for: ${CMAKE_CURRENT_SOURCE_DIR}")
    message(STATUS "source dir: ${CMAKE_SOURCE_DIR}")
    include_directories("D:/MyWork/tools/dl_deploy_cpp-main/include/opencv4/")
    link_directories("D:/MyWork/tools/4.8.1/")
    set(OpenCV_LIBS opencv_world opencv_3rdparty)
    message(STATUS "Setting up OpenCV libs done! OpenCV_LIBS:+[${OpenCV_LIBS}]")
  2. txt文件内容

    bash 复制代码
    cmake_minimum_required(VERSION 3.0.0)
    project(demo VERSION 0.1.0 LANGUAGES C CXX)
    add_executable(demo main.cpp)
    
    
    # set(CPACK_PROJECT_NAME ${PROJECT_NAME})
    # set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
    # include(CPack)
    
    
    option(INCLUDE_OPENCV "package OpenCV into dl_deploy." ON)
    message(STATUS "INCLUDE_OPENCV: ${INCLUDE_OPENCV}")
    
    # opencv, add library
    if (INCLUDE_OPENCV)
        include(opencv.cmake)
    endif ()
    
    message(STATUS "libs is: ${OpenCV_LIBS}")
    
    if (INCLUDE_OPENCV)
        target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
    endif ()
相关推荐
rainFFrain15 小时前
单例模式与线程安全
linux·运维·服务器·vscode·单例模式
超级小的大杯柠檬水18 小时前
修改Anaconda中Jupyter Notebook默认工作路径的详细图文教程(Win 11)
ide·python·jupyter
jndingxin19 小时前
OpenCV 图形API(11)对图像进行掩码操作的函数mask()
人工智能·opencv·计算机视觉
阳光_你好19 小时前
请详细说明opencv/c++对图片缩放
c++·opencv·计算机视觉
契合qht53_shine19 小时前
OpenCV 从入门到精通(day_05)
人工智能·opencv·计算机视觉
xcLeigh20 小时前
OpenCV从零开始:30天掌握图像处理基础
图像处理·人工智能·python·opencv
色空大师20 小时前
【idea】实用插件
java·ide·intellij-idea
suanday_sunny21 小时前
VSCode运行,各类操作缓慢,如何清理
ide·vscode·编辑器
信计小白21 小时前
vscode报Module containing this breakpoint has not yet loaded
ide·vscode·编辑器
新知图书21 小时前
OpenCV单窗口显示多图片
人工智能·opencv·计算机视觉