1+ $ErrorActionPreference = " Stop"
2+
3+ $RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot " ..\.." )).Path
4+ $DepsRoot = Join-Path $RepoRoot " .deps"
5+ $OcvVer = " 4.11.0"
6+
7+ $ZipPath = Join-Path $DepsRoot " opencv-$OcvVer .zip"
8+ $SrcDir = Join-Path $DepsRoot " opencv-$OcvVer "
9+ $BuildDir = Join-Path $DepsRoot " opencv-build-$OcvVer "
10+ $InstDir = Join-Path $DepsRoot " opencv-install-$OcvVer "
11+
12+ New-Item - ItemType Directory - Force - Path $DepsRoot | Out-Null
13+
14+ # Download OpenCV sources
15+ if (-not (Test-Path $ZipPath )) {
16+ Write-Host " Downloading OpenCV $OcvVer ..."
17+ Invoke-WebRequest - Uri " https://github.com/opencv/opencv/archive/$OcvVer .zip" - OutFile $ZipPath
18+ }
19+
20+ # Extract
21+ if (-not (Test-Path $SrcDir )) {
22+ Write-Host " Extracting..."
23+ Expand-Archive - Path $ZipPath - DestinationPath $DepsRoot - Force
24+ }
25+
26+ New-Item - ItemType Directory - Force - Path $BuildDir | Out-Null
27+ New-Item - ItemType Directory - Force - Path $InstDir | Out-Null
28+
29+ # Configure (VS2022)
30+ Write-Host " Configuring OpenCV..."
31+ & cmake - S $SrcDir - B $BuildDir - G " Visual Studio 17 2022" - A x64 `
32+ - DCMAKE_INSTALL_PREFIX= " $InstDir " `
33+ - DCMAKE_CONFIGURATION_TYPES= " Debug;RelWithDebInfo" `
34+ - DINSTALL_CREATE_DISTRIB= ON `
35+ - DBUILD_LIST= features2d, highgui, flann, calib3d, imgcodecs `
36+ - DWITH_OPENEXR= ON `
37+ - DBUILD_EXAMPLES= OFF - DBUILD_PERF_TESTS= OFF - DBUILD_TESTS= OFF - DBUILD_DOCS= OFF `
38+ - DWITH_CUDA= OFF
39+
40+ # Build + install both configs (your project uses RelWithDebInfo in CI)
41+ Write-Host " Building+Installing OpenCV RelWithDebInfo..."
42+ & cmake -- build $BuildDir -- config RelWithDebInfo -- target INSTALL
43+
44+ Write-Host " Building+Installing OpenCV Debug..."
45+ & cmake -- build $BuildDir -- config Debug -- target INSTALL
46+
47+ # Find OpenCVConfig.cmake and write OpenCV_DIR
48+ $cfg = Get-ChildItem - Path $InstDir - Recurse - Filter OpenCVConfig.cmake | Select-Object - First 1
49+ if ($null -eq $cfg ) { throw " OpenCVConfig.cmake not found under $InstDir " }
50+
51+ $OpenCV_DIR = $cfg.Directory.FullName
52+ Set-Content - Path (Join-Path $DepsRoot " opencv_dir.txt" ) - Value $OpenCV_DIR - Encoding ASCII
53+
54+ # Also store bin path for runtime (opencv_world*.dll)
55+ $dll = Get-ChildItem - Path $InstDir - Recurse - Filter " opencv_world*.dll" | Select-Object - First 1
56+ if ($dll ) {
57+ Set-Content - Path (Join-Path $DepsRoot " opencv_bin.txt" ) - Value $dll.Directory.FullName - Encoding ASCII
58+ }
59+
60+ Write-Host " OpenCV_DIR = $OpenCV_DIR "
0 commit comments