Skip to content

Commit a657519

Browse files
authored
Merge pull request #23 from bghira/bugfix/transposed-numpy-input
fix issue with transposed/strided numpy arrays
2 parents c5694ff + 30a5ef4 commit a657519

11 files changed

Lines changed: 450 additions & 116 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232
ls -la /usr/lib/llvm-18/lib/libclang.so
3333
which llvm-config-18
3434
35-
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
36-
echo "Building OpenCV 4.12 from source..."
35+
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
36+
echo "Building OpenCV 4.11 from source..."
3737
cd /tmp
38-
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
39-
tar -xzf 4.12.0.tar.gz
40-
cd opencv-4.12.0
38+
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
39+
tar -xzf 4.11.0.tar.gz
40+
cd opencv-4.11.0
4141
mkdir build
4242
cd build
4343
cmake \
@@ -127,12 +127,12 @@ jobs:
127127
ls -la /usr/lib/llvm-18/lib/libclang.so
128128
which llvm-config-18
129129
130-
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
131-
echo "Building OpenCV 4.12 from source..."
130+
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
131+
echo "Building OpenCV 4.11 from source..."
132132
cd /tmp
133-
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
134-
tar -xzf 4.12.0.tar.gz
135-
cd opencv-4.12.0
133+
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
134+
tar -xzf 4.11.0.tar.gz
135+
cd opencv-4.11.0
136136
mkdir build
137137
cd build
138138
cmake \
@@ -218,12 +218,12 @@ jobs:
218218
ls -la /usr/lib/llvm-18/lib/libclang.so
219219
which llvm-config-18
220220
221-
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
222-
echo "Building OpenCV 4.12 from source..."
221+
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
222+
echo "Building OpenCV 4.11 from source..."
223223
cd /tmp
224-
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
225-
tar -xzf 4.12.0.tar.gz
226-
cd opencv-4.12.0
224+
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
225+
tar -xzf 4.11.0.tar.gz
226+
cd opencv-4.11.0
227227
mkdir build
228228
cd build
229229
cmake \
@@ -298,12 +298,12 @@ jobs:
298298
ls -la /usr/lib/llvm-18/lib/libclang.so
299299
which llvm-config-18
300300
301-
# Build OpenCV 4.12 from source since Ubuntu 24.04 only has 4.6
302-
echo "Building OpenCV 4.12 from source..."
301+
# Build OpenCV 4.11 from source since Ubuntu 24.04 only has 4.6
302+
echo "Building OpenCV 4.11 from source..."
303303
cd /tmp
304-
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
305-
tar -xzf 4.12.0.tar.gz
306-
cd opencv-4.12.0
304+
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
305+
tar -xzf 4.11.0.tar.gz
306+
cd opencv-4.11.0
307307
mkdir build
308308
cd build
309309
cmake \
@@ -348,19 +348,19 @@ jobs:
348348
- name: Install maturin (Linux/macOS)
349349
run: pip install maturin[patchelf]
350350

351-
- name: Install OpenCV (macOS)
351+
- name: Install OpenCV build dependencies (macOS)
352352
if: runner.os == 'macOS'
353353
run: |
354-
# Install OpenCV and LLVM via Homebrew
355-
brew install opencv llvm
354+
# Build against a pinned OpenCV version instead of Homebrew's moving target
355+
brew install llvm cmake nasm pkg-config
356356
# Set up LLVM environment for opencv-rust bindings (keg-only installation)
357357
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
358358
echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
359359
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
360-
# Set up OpenCV environment
361-
echo "OPENCV_LINK_LIBS=opencv_calib3d,opencv_core,opencv_dnn,opencv_features2d,opencv_flann,opencv_highgui,opencv_imgcodecs,opencv_imgproc,opencv_ml,opencv_objdetect,opencv_photo,opencv_stitching,opencv_video,opencv_videoio" >> $GITHUB_ENV
362-
echo "OPENCV_LINK_PATHS=/opt/homebrew/lib" >> $GITHUB_ENV
363-
echo "OPENCV_INCLUDE_PATHS=/opt/homebrew/include/opencv4" >> $GITHUB_ENV
360+
361+
- name: Build static OpenCV (macOS)
362+
if: runner.os == 'macOS'
363+
run: ./scripts/build-opencv-static.sh
364364

365365
- name: Build wheels (Linux)
366366
if: runner.os == 'Linux'
@@ -369,6 +369,11 @@ jobs:
369369
- name: Build wheels (macOS)
370370
if: runner.os == 'macOS'
371371
run: maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv,metal
372+
env:
373+
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
374+
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
375+
OPENCV_LINK_LIBS: static=opencv_world,static=avformat,static=avcodec,static=avfilter,static=swresample,static=swscale,static=avutil,static=jpeg,static=png,static=tiff,static=webp,static=jasper,framework=Accelerate,dylib=c++,framework=OpenCL,z
376+
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
372377

373378

374379
- name: Upload wheels
@@ -398,12 +403,12 @@ jobs:
398403
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
399404
echo "LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
400405
401-
# Build OpenCV 4.12 from source
402-
echo "Building OpenCV 4.12 from source..."
406+
# Build OpenCV 4.11 from source
407+
echo "Building OpenCV 4.11 from source..."
403408
cd /tmp
404-
wget -q https://github.com/opencv/opencv/archive/4.12.0.tar.gz
405-
tar -xzf 4.12.0.tar.gz
406-
cd opencv-4.12.0
409+
wget -q https://github.com/opencv/opencv/archive/4.11.0.tar.gz
410+
tar -xzf 4.11.0.tar.gz
411+
cd opencv-4.11.0
407412
mkdir build
408413
cd build
409414
cmake \

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: actions/cache@v4
5050
with:
5151
path: third_party/opencv-static
52-
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}
52+
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}
5353

5454
- name: Install build dependencies
5555
run: |
@@ -147,7 +147,7 @@ jobs:
147147
uses: actions/cache@v4
148148
with:
149149
path: third_party/opencv-static
150-
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-aarch64-${{ runner.arch }}-manylinux_2_39
150+
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-linux-aarch64-${{ runner.arch }}-manylinux_2_39
151151

152152
- name: Install build dependencies
153153
run: |
@@ -229,7 +229,7 @@ jobs:
229229
uses: actions/cache@v4
230230
with:
231231
path: third_party/opencv-static
232-
key: opencv-static-4.12.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-macos-${{ runner.os }}-${{ runner.arch }}
232+
key: opencv-static-4.11.0-codecs-jasper-ffmpeg-no-itt-no-openjpeg-macos-${{ runner.os }}-${{ runner.arch }}
233233

234234
- name: Install build dependencies
235235
run: |

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ num_cpus = "1.16"
1010
numpy = {version = "0.22", optional = true}
1111
objc = {version = "0.2", optional = true}
1212
# OpenCV bindings for performance parity
13-
opencv = {version = "0.93", optional = true}
13+
# Limit binding generation to the modules this crate actually uses.
14+
opencv = {version = "0.98", optional = true, default-features = false, features = ["clang-runtime", "imgproc", "videoio"]}
1415
# Python bindings (optional)
1516
pyo3 = {version = "0.22", features = ["extension-module"], optional = true}
1617
rayon = "1.8"

rust-toolchain.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[toolchain]
22
channel = "1.89"
3-
components = ["rustfmt", "clippy"]
43
profile = "minimal"

scripts/build-opencv-static.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
# Build static OpenCV bundle for embedding in Python wheels
55
# This eliminates the need for users to install OpenCV system packages
66

7-
OPENCV_VERSION="4.12.0"
7+
OPENCV_VERSION="4.11.0"
88
FFMPEG_VERSION="6.1.1"
99
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"

0 commit comments

Comments
 (0)