A simple C++ project demonstrating OpenCV integration using vcpkg package manager.
- Visual Studio 2022 Community (with C++ development tools)
- Git
- vcpkg package manager
# Clone vcpkg (if not already done)
git clone https://github.com/Microsoft/vcpkg.git S:\Dev\GitHub\microsoft\vcpkg
# Bootstrap vcpkg
cd S:\Dev\GitHub\microsoft\vcpkg
.\bootstrap-vcpkg.bat
# Install OpenCV
.\vcpkg.exe install opencv:x64-windows
# Integrate with Visual Studio
.\vcpkg.exe integrate install# Configure CMake with vcpkg toolchain
cmake -B build -DCMAKE_TOOLCHAIN_FILE="S:/Dev/GitHub/microsoft/vcpkg/scripts/buildsystems/vcpkg.cmake"
# Build the project
cmake --build build --config Release.\build\Release\OpenCVTest.exeThis project includes VS Code configuration files:
.vscode/tasks.json- Build tasks for CMake.vscode/launch.json- Debug and run configurations.vscode/c_cpp_properties.json- C++ IntelliSense configuration
- Build: Press
Ctrl+Shift+Bor use Command Palette → "Tasks: Run Task" - Run: Press
Ctrl+F5or use Command Palette → "Debug: Start Without Debugging" - Debug: Press
F5or use Command Palette → "Debug: Start Debugging"
CVTest/
├── .vscode/ # VS Code configuration
│ ├── tasks.json
│ ├── launch.json
│ └── c_cpp_properties.json
├── build/ # Build output (git ignored)
├── CMakeLists.txt # CMake configuration
├── main.cpp # Main program
└── README.md # This file
The program demonstrates basic OpenCV functionality:
- Creates a 300x400 pixel image
- Draws a green circle
- Adds "Hello OpenCV!" text
- Saves the result as
test_output.jpg - Displays OpenCV version and image dimensions
- OpenCV 4.11.0 (installed via vcpkg)
- CMake 3.10+
- MSVC compiler (Visual Studio 2022)
- The vcpkg toolchain file path is hardcoded for this specific setup
- Adjust paths in VS Code configuration files if vcpkg is installed elsewhere
- Output images are ignored by Git (see
.gitignore)