Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
Last active September 15, 2023 01:19
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save UnaNancyOwen/5061d8c966178b753447e8a9f9ac8cf1 to your computer and use it in GitHub Desktop.
Save UnaNancyOwen/5061d8c966178b753447e8a9f9ac8cf1 to your computer and use it in GitHub Desktop.
CMakeLists for OpenCV that installed using Vcpkg
cmake_minimum_required( VERSION 3.0 )
set( CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" )
# Create Project
project( solution )
add_executable( project main.cpp )
# Set OpenCVConfig.cmake Search Directory
set( OpenCV_DIR )
if( NOT CMAKE_CL_64 )
set( OpenCV_DIR "C:/vcpkg/installed/x86-windows/share/opencv" )
else()
set( OpenCV_DIR "C:/vcpkg/installed/x64-windows/share/opencv" )
endif()
# Find Package
find_package( OpenCV REQUIRED )
if( OpenCV_FOUND )
# Additional Include Directories
include_directories( ${OpenCV_INCLUDE_DIRS} )
# Additional Library Directories
link_directories( ${OpenCV_LIB_DIR} )
# Additional Dependencies
target_link_libraries( project ${OpenCV_LIBS} )
endif()

How to Install OpenCV using Vcpkg

Command

  • x86
    vcpkg install opencv:x86-windows
    
  • x64
    vcpkg install opencv:x64-windows
    
@SaverioFrancesco
Copy link

How do you install opencv 4.2.0 for ubuntu 20.04? do you have a tag for that? vcpkg install opencv builds everything and i had to install some dependency manualy so far.

Computing installation plan...
The following packages will be built and installed:

  • gtk[core]:x64-linux -> 4.6.2#2
  • harfbuzz[core]:x64-linux -> 5.0.1#2
  • libepoxy[core]:x64-linux -> 1.5.9#1
  • libsass[core]:x64-linux -> 3.6.5#1
  • libwebp[core,libwebpmux,nearlossless,simd]:x64-linux -> 1.2.4
    opencv[core,default-features]:x64-linux -> 4.6.0
  • opencv4[core,default-features,dnn,gtk,jpeg,png,quirc,tiff,webp]:x64-linux -> 4.6.0#5
  • pango[core]:x64-linux -> 1.50.9
  • quirc[core]:x64-linux -> 1.1#3
  • sassc[core]:x64-linux -> 3.6.2
  • vcpkg-get-python-packages[core]:x64-linux -> 2022-06-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment