@@ -195,44 +195,74 @@ https://github.com/shimat?tab=packages
195195## OpenCvSharp Build Instructions
196196
197197### Windows
198- - Install Visual Studio 2022 or later
199- - VC++ features are required.
200- - Run ` download_opencv_windows.ps1 ` to download OpenCV libs and headers from https://github.com/shimat/opencv_files . Those lib files are precompiled by the owner of OpenCvSharp using GitHub Actions.
201- ```
202- .\download_opencv_windows.ps1
203- ```
204- - Build OpenCvSharp
205- - Open ` OpenCvSharp.sln ` and build
206-
207- #### How to customize OpenCV binaries yourself
208- If you want to use OpenCV features that are not included by default in OpenCvSharp (e.g., GPU support), you will need to build OpenCV yourself. The binary files of OpenCV for OpenCvSharp for Windows are created in the [ opencv_files] ( https://github.com/shimat/opencv_files ) repository. See the README for details.
209198
210- - ` git clone --recursive https://github.com/shimat/opencv_files `
211- - Edit ` build_windows.ps1 ` or ` build_uwp.ps1 ` to customize the CMake parameters
212- - Run the PowerShell script
199+ #### Prerequisites
200+ - Visual Studio 2022 / 2026, or the corresponding Build Tools, with the ** Desktop development with C++** workload
201+ - CMake 3.20+ in PATH (` winget install Kitware.CMake ` )
202+ - Git in PATH
203+ - [ vcpkg] ( https://github.com/microsoft/vcpkg ) in PATH or ` VCPKG_INSTALLATION_ROOT ` set
204+ ``` powershell
205+ git clone https://github.com/microsoft/vcpkg C:\vcpkg
206+ C:\vcpkg\bootstrap-vcpkg.bat
207+ # Add C:\vcpkg to PATH, or set $env:VCPKG_INSTALLATION_ROOT = 'C:\vcpkg'
208+ ```
209+
210+ #### Steps
211+ 1 . Clone the repository with submodules (opencv + opencv_contrib are included as submodules):
212+ ``` powershell
213+ git clone --recursive https://github.com/shimat/opencvsharp.git
214+ cd opencvsharp
215+ ```
216+ If you already cloned without submodules:
217+ ``` powershell
218+ git submodule update --init --recursive
219+ ```
220+
221+ 2 . Build OpenCV from source (Tesseract is automatically installed via vcpkg):
222+ ``` powershell
223+ .\build_opencv_windows.ps1
224+ # Use -Jobs N to control parallel build (default: 4)
225+ .\build_opencv_windows.ps1 -Jobs 8
226+ ```
227+ Output is installed to ` opencv_artifacts/ ` .
228+
229+ 3 . Build the native wrapper ` OpenCvSharpExtern ` :
230+ ``` powershell
231+ cmake -S src -B src\build -G "Visual Studio 17 2022" -A x64 `
232+ -D CMAKE_PREFIX_PATH="opencv_artifacts" `
233+ -D CMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" `
234+ -D VCPKG_TARGET_TRIPLET=x64-windows-static `
235+ -D VCPKG_INSTALLED_DIR="vcpkg_installed"
236+ cmake --build src\build --config Release
237+ ```
238+
239+ 4 . Build the managed OpenCvSharp library:
240+ - Open ` OpenCvSharp.sln ` and build, or:
241+ ``` powershell
242+ dotnet build src/OpenCvSharp/OpenCvSharp.csproj -c Release
243+ ```
213244
214245### Ubuntu
215246- Build OpenCV with opencv_contrib: https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
216247- Install .NET Core SDK: https://learn.microsoft.com/ja-jp/dotnet/core/install/linux-ubuntu
217248- Get OpenCvSharp source files
218249``` bash
219- git clone https://github.com/shimat/opencvsharp.git
250+ git clone --recursive https://github.com/shimat/opencvsharp.git
220251cd opencvsharp
221252git fetch --all --tags --prune && git checkout ${OPENCVSHARP_VERSION}
222253```
223254
224255- Build native wrapper ` OpenCvSharpExtern `
225256``` bash
226257cd opencvsharp/src
227- mkdir build
228- cd build
258+ mkdir build && cd build
229259cmake -D CMAKE_INSTALL_PREFIX=${YOUR_OPENCV_INSTALL_PATH} ..
230- make -j
260+ make -j
231261make install
232262```
233- You should add a reference to ` opencvsharp/src/build/OpenCvSharpExtern/libOpenCvSharpExtern.so `
263+ Add a reference to the built shared library:
234264``` bash
235- export LD_LIBRARY_PATH=" ${LD_LIBRARY_PATH} :/home/shimat /opencvsharp/src/build/OpenCvSharpExtern"
265+ export LD_LIBRARY_PATH=" ${LD_LIBRARY_PATH} :/path/to /opencvsharp/src/build/OpenCvSharpExtern"
236266```
237267
238268- Build the managed OpenCvSharp library
0 commit comments