From 00051b4206d29ef371490c7678074bdf4a0e1772 Mon Sep 17 00:00:00 2001 From: sreeram-11 Date: Wed, 6 May 2026 13:20:05 -0700 Subject: [PATCH 1/5] CVML CI Tests --- playbooks/supplemental/cvml/README.md | 253 ++++++++++++++++++++++ playbooks/supplemental/cvml/playbook.json | 10 + 2 files changed, 263 insertions(+) diff --git a/playbooks/supplemental/cvml/README.md b/playbooks/supplemental/cvml/README.md index a4597f24..97bf2575 100644 --- a/playbooks/supplemental/cvml/README.md +++ b/playbooks/supplemental/cvml/README.md @@ -46,6 +46,79 @@ Before starting, ensure you have the following: - Vulkan SDK (installed in the [Linux-Specific Setup](#linux-specific-setup) section below) + + +```bash +cat /etc/os-release +uname -r +``` + + + + + +```powershell +$ErrorActionPreference = "Stop" + +git --version +git lfs version +cmake --version + +if (-not $env:OPENCV_INSTALL_ROOT) {throw "OPENCV_INSTALL_ROOT is not set. Set it to your OpenCV 4.11 installation root before running this test."} + +if (-not (Test-Path $env:OPENCV_INSTALL_ROOT)) {throw "OPENCV_INSTALL_ROOT does not exist: $env:OPENCV_INSTALL_ROOT"} + +$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +if (-not (Test-Path $vswhere)) {throw "vswhere.exe not found. Install Visual Studio 2022 with Desktop development with C++ workload."} + +$vsInstall = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath +if (-not $vsInstall) {throw "Visual Studio 2022 Desktop development with C++ workload was not found."} + +$clPath = Get-ChildItem "$vsInstall\VC\Tools\MSVC" -Recurse -Filter cl.exe -ErrorAction SilentlyContinue | Select-Object -First 1 +if (-not $clPath) {throw "MSVC cl.exe was not found under Visual Studio installation."} +``` + + + + + +```bash +set -euo pipefail + +git --version +git lfs version +cmake --version + +. /etc/os-release +if [ "${VERSION_ID}" != "24.04" ]; then + echo "This CI runner is expected to be Ubuntu 24.04. Found: ${PRETTY_NAME}" + exit 1 +fi + +if [ -z "${OPENCV_INSTALL_ROOT:-}" ]; then + echo "OPENCV_INSTALL_ROOT is not set. Set it to your OpenCV 4.11 installation root before running this test." + exit 1 +fi + +if [ ! -d "$OPENCV_INSTALL_ROOT" ]; then + echo "OPENCV_INSTALL_ROOT does not exist: $OPENCV_INSTALL_ROOT" + exit 1 +fi + +if ! command -v glslc >/dev/null 2>&1 && ! command -v vulkaninfo >/dev/null 2>&1; then + echo "Vulkan SDK tools were not found. Install the Vulkan SDK before running this test." + exit 1 +fi + +if [ ! -d /opt/xilinx/xrt/lib ]; then + echo "/opt/xilinx/xrt/lib was not found. Install the Ryzen AI Linux NPU driver/XRT runtime before running this test." + exit 1 +fi + +``` + + + ## Setting Up the CVML Library Clone the Ryzen AI Software repository to get the CVML Library: @@ -296,6 +369,186 @@ The face detection feature offers two model variants: | `fast` (default) | Higher FPS | Good | Real-time camera applications | | `precise` | Lower FPS | Best | Photo analysis, high-accuracy needs | + + +```powershell +$ErrorActionPreference = "Stop" + +$playbookRoot = (Get-Location).Path + +if (-not $env:OPENCV_INSTALL_ROOT) {throw "OPENCV_INSTALL_ROOT is not set."} + +$work = Join-Path $env:TEMP ("cvml-test-" + [System.Guid]::NewGuid().ToString()) +New-Item -ItemType Directory -Force -Path $work | Out-Null + +try { + $repo = Join-Path $work "RyzenAI-SW" + + git lfs install + git clone --depth 1 https://github.com/amd/RyzenAI-SW.git $repo + + Push-Location $repo + git lfs pull + Pop-Location + + $cvmlRoot = Join-Path $repo "Ryzen-AI-CVML-Library" + if (-not (Test-Path $cvmlRoot)) {throw "Ryzen-AI-CVML-Library folder was not found after cloning RyzenAI-SW."} + + $lfsCandidate = Get-ChildItem (Join-Path $cvmlRoot "windows") -Recurse -Include *.dll,*.lib,*.amodel,*.graphlib -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $lfsCandidate) {throw "No Windows CVML binary/runtime files were found. Git LFS may not have pulled the assets."} + + $firstLine = Get-Content -Path $lfsCandidate.FullName -TotalCount 1 -ErrorAction SilentlyContinue + if ($firstLine -like "version https://git-lfs.github.com/spec*") {throw "Git LFS file was downloaded as a pointer instead of the real binary: $($lfsCandidate.FullName)"} + + $samplesDir = Join-Path $cvmlRoot "samples" + $buildDir = Join-Path $samplesDir "build" + + cmake -S $samplesDir -B $buildDir -DOPENCV_INSTALL_ROOT="$env:OPENCV_INSTALL_ROOT" + cmake --build $buildDir --config Release --parallel + + $faceExe = Join-Path $buildDir "cvml-sample-face-detection\Release\cvml-sample-face-detection.exe" + $depthExe = Join-Path $buildDir "cvml-sample-depth-estimation\Release\cvml-sample-depth-estimation.exe" + $meshExe = Join-Path $buildDir "cvml-sample-face-mesh\Release\cvml-sample-face-mesh.exe" + + foreach ($exe in @($faceExe, $depthExe, $meshExe)) { + if (-not (Test-Path $exe)) {throw "Expected executable was not found: $exe"} + } + + $opencvBinCandidates = @( + (Join-Path $env:OPENCV_INSTALL_ROOT "build\x64\vc16\bin"), + (Join-Path $env:OPENCV_INSTALL_ROOT "x64\vc16\bin"), + (Join-Path $env:OPENCV_INSTALL_ROOT "bin") + ) | Where-Object { Test-Path $_ } + + foreach ($dir in $opencvBinCandidates) { + $env:PATH = "$dir;$env:PATH" + } + + $env:PATH = "$(Join-Path $cvmlRoot "windows");$env:PATH" + + $inputImage = Join-Path $playbookRoot "sample_face.jpg" + if (-not (Test-Path $inputImage)) { + $inputImage = Join-Path $work "sample_face.jpg" + curl.exe -L -o $inputImage "https://images.pexels.com/photos/895863/pexels-photo-895863.jpeg?cs=srgb&dl=pexels-jopwell-895863.jpg&fm=jpg" + } + + $outputFast = Join-Path $work "output_face_fast.jpg" + $outputPrecise = Join-Path $work "output_face_precise.jpg" + + Push-Location (Split-Path $faceExe) + & $faceExe -i $inputImage -o $outputFast + if ($LASTEXITCODE -ne 0) {throw "Face detection default model failed with exit code $LASTEXITCODE."} + + & $faceExe -i $inputImage -o $outputPrecise -m precise + if ($LASTEXITCODE -ne 0) {throw "Face detection precise model failed with exit code $LASTEXITCODE."} + Pop-Location + + foreach ($output in @($outputFast, $outputPrecise)) { + if (-not (Test-Path $output)) {throw "Expected output image was not created: $output"} + + if ((Get-Item $output).Length -le 0) {throw "Output image is empty: $output"} + } +} +finally { + Pop-Location -ErrorAction SilentlyContinue + Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue +} +``` + + + + + +```bash +set -euo pipefail + +playbook_root="$PWD" + +if [ -z "${OPENCV_INSTALL_ROOT:-}" ]; then + echo "OPENCV_INSTALL_ROOT is not set." + exit 1 +fi + +work="$(mktemp -d)" +cleanup() { + rm -rf "$work" +} +trap cleanup EXIT + +repo="$work/RyzenAI-SW" + +git lfs install +git clone --depth 1 https://github.com/amd/RyzenAI-SW.git "$repo" + +cd "$repo" +git lfs pull + +cvml_root="$repo/Ryzen-AI-CVML-Library" +if [ ! -d "$cvml_root" ]; then + echo "Ryzen-AI-CVML-Library folder was not found after cloning RyzenAI-SW." + exit 1 +fi + +lfs_candidate="$(find "$cvml_root/linux" -type f \( -name "*.so" -o -name "*.amod" -o -name "*.xclbin" \) | head -n 1 || true)" +if [ -z "$lfs_candidate" ]; then + echo "No Linux CVML binary/runtime files were found. Git LFS may not have pulled the assets." + exit 1 +fi + +if head -n 1 "$lfs_candidate" | grep -q "version https://git-lfs.github.com/spec"; then + echo "Git LFS file was downloaded as a pointer instead of the real binary: $lfs_candidate" + exit 1 +fi + +samples_dir="$cvml_root/samples" +build_dir="$samples_dir/build" + +cmake -S "$samples_dir" -B "$build_dir" -DOPENCV_INSTALL_ROOT="$OPENCV_INSTALL_ROOT" +cmake --build "$build_dir" --config Release --parallel "$(nproc)" + +face_exe="$build_dir/cvml-sample-face-detection/cvml-sample-face-detection" +depth_exe="$build_dir/cvml-sample-depth-estimation/cvml-sample-depth-estimation" +mesh_exe="$build_dir/cvml-sample-face-mesh/cvml-sample-face-mesh" + +for exe in "$face_exe" "$depth_exe" "$mesh_exe"; do + if [ ! -x "$exe" ]; then + echo "Expected executable was not found or is not executable: $exe" + exit 1 + fi +done + +export LD_LIBRARY_PATH="$cvml_root/linux:/opt/xilinx/xrt/lib:${LD_LIBRARY_PATH:-}" + +for dir in "$OPENCV_INSTALL_ROOT/lib" "$OPENCV_INSTALL_ROOT/lib64" "$OPENCV_INSTALL_ROOT/build/lib"; do + if [ -d "$dir" ]; then + export LD_LIBRARY_PATH="$dir:$LD_LIBRARY_PATH" + fi +done + +input_image="$playbook_root/assets/sample_face.jpg" +if [ ! -f "$input_image" ]; then + input_image="$work/sample_face.jpg" + curl -L -o "$input_image" "https://images.pexels.com/photos/895863/pexels-photo-895863.jpeg?cs=srgb&dl=pexels-jopwell-895863.jpg&fm=jpg" +fi + +output_fast="$work/output_face_fast.jpg" +output_precise="$work/output_face_precise.jpg" + +cd "$(dirname "$face_exe")" + +"$face_exe" -i "$input_image" -o "$output_fast" +"$face_exe" -i "$input_image" -o "$output_precise" -m precise + +for output in "$output_fast" "$output_precise"; do + if [ ! -s "$output" ]; then + echo "Expected output image was not created or is empty: $output" + exit 1 + fi +done +``` + + + ## Integrating CVML into Your Own Application To use the CVML Library in your own C++ project, add it via CMake's `find_package`: diff --git a/playbooks/supplemental/cvml/playbook.json b/playbooks/supplemental/cvml/playbook.json index 2b8f45a7..74aa5fdc 100644 --- a/playbooks/supplemental/cvml/playbook.json +++ b/playbooks/supplemental/cvml/playbook.json @@ -11,6 +11,16 @@ "windows" ] }, + "tested_platforms": { + "halo": [ + "windows" + ] + }, + "required_platforms": { + "halo": [ + "windows" + ] + }, "difficulty": "intermediate", "isNew": false, "isFeatured": false, From 9e08ede2e2ffe97e995f5ee857bc94cb90a0dc1b Mon Sep 17 00:00:00 2001 From: sreeram-11 Date: Wed, 6 May 2026 14:46:02 -0700 Subject: [PATCH 2/5] Adding OpenCV_DIR path --- playbooks/supplemental/cvml/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playbooks/supplemental/cvml/README.md b/playbooks/supplemental/cvml/README.md index 97bf2575..e3abb0b6 100644 --- a/playbooks/supplemental/cvml/README.md +++ b/playbooks/supplemental/cvml/README.md @@ -377,8 +377,9 @@ $ErrorActionPreference = "Stop" $playbookRoot = (Get-Location).Path if (-not $env:OPENCV_INSTALL_ROOT) {throw "OPENCV_INSTALL_ROOT is not set."} +if (-not $env:OpenCV_DIR) {throw "OpenCV_DIR is not set."} -$work = Join-Path $env:TEMP ("cvml-test-" + [System.Guid]::NewGuid().ToString()) +$work = $work = Join-Path (Get-Location) "cvml-test" New-Item -ItemType Directory -Force -Path $work | Out-Null try { @@ -403,7 +404,7 @@ try { $samplesDir = Join-Path $cvmlRoot "samples" $buildDir = Join-Path $samplesDir "build" - cmake -S $samplesDir -B $buildDir -DOPENCV_INSTALL_ROOT="$env:OPENCV_INSTALL_ROOT" + cmake -S $samplesDir -B $buildDir -DOPENCV_INSTALL_ROOT="$env:OPENCV_INSTALL_ROOT" -DOpenCV_DIR="$env:OpenCV_DIR" cmake --build $buildDir --config Release --parallel $faceExe = Join-Path $buildDir "cvml-sample-face-detection\Release\cvml-sample-face-detection.exe" From d59dd379e2908e495d1f29f0ff133f5400e62cb5 Mon Sep 17 00:00:00 2001 From: sreeram-11 Date: Wed, 6 May 2026 17:22:20 -0700 Subject: [PATCH 3/5] Added opencv.md and OpenCV_DIR tests --- playbooks/dependencies/opencv.md | 71 +++++++++++++++++++++++++++ playbooks/dependencies/registry.json | 11 +++++ playbooks/supplemental/cvml/README.md | 16 ++++-- 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 playbooks/dependencies/opencv.md diff --git a/playbooks/dependencies/opencv.md b/playbooks/dependencies/opencv.md new file mode 100644 index 00000000..0c316723 --- /dev/null +++ b/playbooks/dependencies/opencv.md @@ -0,0 +1,71 @@ + + +### OpenCV 4.11.0 + +**1. Install build dependencies** +```bash +sudo apt update +sudo apt install -y build-essential cmake git pkg-config unzip wget +sudo apt install -y libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev +sudo apt install -y libjpeg-dev libpng-dev libtiff-dev +``` + +**2. Download OpenCV 4.11.0 source** +```bash +cd /tmp +wget -O opencv-4.11.0.zip https://github.com/opencv/opencv/archive/refs/tags/4.11.0.zip +unzip opencv-4.11.0.zip +``` + +**3. Configure build** +```bash +cd /tmp/opencv-4.11.0 +mkdir build +cd build + +cmake -S .. -B . \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/opt/opencv-4.11.0 \ + -DBUILD_opencv_python3=OFF \ + -DBUILD_opencv_python2=OFF \ + -DBUILD_TESTS=OFF \ + -DBUILD_PERF_TESTS=OFF \ + -DBUILD_EXAMPLES=OFF + ``` + +**4. Build and install** +```bash +cmake --build . --parallel "$(nproc)" +sudo cmake --install . +``` + +**5. Set OPENCV_INSTALL_ROOT permanently for interactive shells** +```bash +echo 'export OPENCV_INSTALL_ROOT=/opt/opencv-4.11.0' >> ~/.bashrc +source ~/.bashrc +``` + +Verify: +```bash +echo $OPENCV_INSTALL_ROOT +ls $OPENCV_INSTALL_ROOT +``` + +You should see folders like: +- bin +- include +- Lib +- share +or similar. + + +**6. System library path setup** +If the sample executable cannot find OpenCV shared libraries at runtime, add: +```bash +export LD_LIBRARY_PATH=/opt/opencv-4.11.0/lib:$LD_LIBRARY_PATH +``` + diff --git a/playbooks/dependencies/registry.json b/playbooks/dependencies/registry.json index 3f07eba1..2a1c4609 100644 --- a/playbooks/dependencies/registry.json +++ b/playbooks/dependencies/registry.json @@ -24,6 +24,17 @@ "windows": ["halo_box"] } }, + "opencv": { + "name": "OpenCV", + "description": "Computer Vision library and framework", + "category": "framework", + "platforms": ["windows", "linux"], + "file": "opencv.md", + "preinstalled": { + "linux": ["halo_box"], + "windows": ["halo_box"] + } + }, "lmstudio": { "name": "LM Studio", "description": "Desktop app for running local LLMs", diff --git a/playbooks/supplemental/cvml/README.md b/playbooks/supplemental/cvml/README.md index e3abb0b6..fd9cf38e 100644 --- a/playbooks/supplemental/cvml/README.md +++ b/playbooks/supplemental/cvml/README.md @@ -65,9 +65,11 @@ git lfs version cmake --version if (-not $env:OPENCV_INSTALL_ROOT) {throw "OPENCV_INSTALL_ROOT is not set. Set it to your OpenCV 4.11 installation root before running this test."} - if (-not (Test-Path $env:OPENCV_INSTALL_ROOT)) {throw "OPENCV_INSTALL_ROOT does not exist: $env:OPENCV_INSTALL_ROOT"} +if (-not $env:OpenCV_DIR) {throw "OpenCV_DIR is not set. Set it to point to the folder containing OpenCVConfig.cmake before running this test."} +if (-not (Test-Path $env:OpenCV_DIR)) {throw "OpenCV_DIR does not exist: $env:OpenCV_DIR"} + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" if (-not (Test-Path $vswhere)) {throw "vswhere.exe not found. Install Visual Studio 2022 with Desktop development with C++ workload."} @@ -99,12 +101,20 @@ if [ -z "${OPENCV_INSTALL_ROOT:-}" ]; then echo "OPENCV_INSTALL_ROOT is not set. Set it to your OpenCV 4.11 installation root before running this test." exit 1 fi - if [ ! -d "$OPENCV_INSTALL_ROOT" ]; then echo "OPENCV_INSTALL_ROOT does not exist: $OPENCV_INSTALL_ROOT" exit 1 fi +if [ -z "${OpenCV_DIR:-}" ]; then + echo "OpenCV_DIR is not set. Set it to point to the folder containing OpenCVConfig.cmake before running this test." + exit 1 +fi +if [ ! -d "$OpenCV_DIR" ]; then + echo "OpenCV_DIR does not exist: $OpenCV_DIR" + exit 1 +fi + if ! command -v glslc >/dev/null 2>&1 && ! command -v vulkaninfo >/dev/null 2>&1; then echo "Vulkan SDK tools were not found. Install the Vulkan SDK before running this test." exit 1 @@ -526,7 +536,7 @@ for dir in "$OPENCV_INSTALL_ROOT/lib" "$OPENCV_INSTALL_ROOT/lib64" "$OPENCV_INST fi done -input_image="$playbook_root/assets/sample_face.jpg" +input_image="$playbook_root/sample_face.jpg" if [ ! -f "$input_image" ]; then input_image="$work/sample_face.jpg" curl -L -o "$input_image" "https://images.pexels.com/photos/895863/pexels-photo-895863.jpeg?cs=srgb&dl=pexels-jopwell-895863.jpg&fm=jpg" From 2ffe1c63f3e384b9e50cae08eab0a12d78754b00 Mon Sep 17 00:00:00 2001 From: sreeram-11 Date: Wed, 6 May 2026 23:57:24 -0700 Subject: [PATCH 4/5] Removing temp dir in Linux --- playbooks/supplemental/cvml/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playbooks/supplemental/cvml/README.md b/playbooks/supplemental/cvml/README.md index fd9cf38e..5aac46ac 100644 --- a/playbooks/supplemental/cvml/README.md +++ b/playbooks/supplemental/cvml/README.md @@ -389,7 +389,7 @@ $playbookRoot = (Get-Location).Path if (-not $env:OPENCV_INSTALL_ROOT) {throw "OPENCV_INSTALL_ROOT is not set."} if (-not $env:OpenCV_DIR) {throw "OpenCV_DIR is not set."} -$work = $work = Join-Path (Get-Location) "cvml-test" +$work = Join-Path (Get-Location) "cvml-test" New-Item -ItemType Directory -Force -Path $work | Out-Null try { @@ -480,7 +480,8 @@ if [ -z "${OPENCV_INSTALL_ROOT:-}" ]; then exit 1 fi -work="$(mktemp -d)" +work="$PWD/cvml-test" +mkdir -p "$work" cleanup() { rm -rf "$work" } From 9cd6bb833ecbea1db84e77e7dd7696ee5b5ceca1 Mon Sep 17 00:00:00 2001 From: sreeram-11 Date: Tue, 12 May 2026 12:03:50 -0700 Subject: [PATCH 5/5] Set openCV_DIR --- playbooks/dependencies/opencv.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playbooks/dependencies/opencv.md b/playbooks/dependencies/opencv.md index 0c316723..67437139 100644 --- a/playbooks/dependencies/opencv.md +++ b/playbooks/dependencies/opencv.md @@ -62,8 +62,14 @@ You should see folders like: - share or similar. +**6. Set OpenCV_DIR permanently for interactive shells** +`OpenCV_DIR` should point to the folder containing `OpenCVConfig.cmake`. +```bash +echo 'export OpenCV_DIR=/opt/opencv-4.11.0/lib/cmake/opencv4' >> ~/.bashrc +source ~/.bashrc +``` -**6. System library path setup** +**7. System library path setup** If the sample executable cannot find OpenCV shared libraries at runtime, add: ```bash export LD_LIBRARY_PATH=/opt/opencv-4.11.0/lib:$LD_LIBRARY_PATH