trainingsample 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. trainingsample-0.2.2/.cargo/config.toml +7 -0
  2. {trainingsample-0.2.1 → trainingsample-0.2.2}/.github/workflows/publish.yml +48 -14
  3. {trainingsample-0.2.1 → trainingsample-0.2.2}/.gitignore +4 -0
  4. {trainingsample-0.2.1 → trainingsample-0.2.2}/Cargo.lock +83 -72
  5. {trainingsample-0.2.1 → trainingsample-0.2.2}/Cargo.toml +1 -1
  6. {trainingsample-0.2.1 → trainingsample-0.2.2}/PKG-INFO +1 -1
  7. {trainingsample-0.2.1 → trainingsample-0.2.2}/docs/API_COMPAT_CV2.md +3 -24
  8. trainingsample-0.2.2/docs/BUILDING_STATIC_OPENCV.md +103 -0
  9. {trainingsample-0.2.1 → trainingsample-0.2.2}/pyproject.toml +1 -1
  10. trainingsample-0.2.2/scripts/build-opencv-static.sh +88 -0
  11. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/lib.rs +0 -6
  12. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/opencv_ops.rs +7 -1
  13. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/python_bindings.rs +11 -61
  14. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/tests.rs +0 -11
  15. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/true_batch_ops.rs +7 -1
  16. {trainingsample-0.2.1 → trainingsample-0.2.2}/.envrc +0 -0
  17. {trainingsample-0.2.1 → trainingsample-0.2.2}/.github/workflows/ci.yml +0 -0
  18. {trainingsample-0.2.1 → trainingsample-0.2.2}/.pre-commit-config.yaml +0 -0
  19. {trainingsample-0.2.1 → trainingsample-0.2.2}/.rustfmt.toml +0 -0
  20. {trainingsample-0.2.1 → trainingsample-0.2.2}/BENCHMARKS.md +0 -0
  21. {trainingsample-0.2.1 → trainingsample-0.2.2}/LICENSE +0 -0
  22. {trainingsample-0.2.1 → trainingsample-0.2.2}/README.md +0 -0
  23. {trainingsample-0.2.1 → trainingsample-0.2.2}/clippy.toml +0 -0
  24. {trainingsample-0.2.1 → trainingsample-0.2.2}/scripts/run_competitive_benchmarks.sh +0 -0
  25. {trainingsample-0.2.1 → trainingsample-0.2.2}/setup-env.sh +0 -0
  26. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/core.rs +0 -0
  27. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/cropping.rs +0 -0
  28. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/cv_batch_ops.rs +0 -0
  29. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/cv_batch_ops_optimized.rs +0 -0
  30. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/cv_compat.rs +0 -0
  31. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/format_conversion_simd.rs +0 -0
  32. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/loading.rs +0 -0
  33. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/luminance.rs +0 -0
  34. {trainingsample-0.2.1 → trainingsample-0.2.2}/src/luminance_simd.rs +0 -0
  35. {trainingsample-0.2.1 → trainingsample-0.2.2}/tests/__init__.py +0 -0
  36. {trainingsample-0.2.1 → trainingsample-0.2.2}/tests/comprehensive_tests.rs +0 -0
  37. {trainingsample-0.2.1 → trainingsample-0.2.2}/tests/test_comprehensive.py +0 -0
  38. {trainingsample-0.2.1 → trainingsample-0.2.2}/tests/test_performance_benchmarks.py +0 -0
  39. {trainingsample-0.2.1 → trainingsample-0.2.2}/tests/test_python_bindings.py +0 -0
@@ -0,0 +1,7 @@
1
+ # Cargo configuration for OpenCV linking
2
+ #
3
+ # Default: Uses system OpenCV (for CI and local development)
4
+ # Release builds: Override with static linking via workflow env vars
5
+
6
+ # This file is intentionally minimal - it lets opencv-rust probe the system.
7
+ # The release workflow sets OPENCV_* env vars to force static linking.
@@ -4,6 +4,7 @@ on:
4
4
  push:
5
5
  tags:
6
6
  - 'v*'
7
+ workflow_dispatch:
7
8
 
8
9
  jobs:
9
10
  linux:
@@ -17,11 +18,18 @@ jobs:
17
18
  with:
18
19
  python-version: '3.11'
19
20
 
20
- - name: Install OpenCV and LLVM dependencies
21
+ - name: Cache static OpenCV
22
+ id: cache-opencv
23
+ uses: actions/cache@v4
24
+ with:
25
+ path: third_party/opencv-static
26
+ key: opencv-static-4.12.0-manylinux-linux-${{ runner.os }}-${{ runner.arch }}
27
+
28
+ - name: Install build dependencies
21
29
  run: |
22
30
  sudo apt-get update
23
- sudo apt-get install -y pkg-config libopencv-dev clang libclang-dev llvm-dev
24
- # Install LLVM 18 which has the proper libclang.so symlink
31
+ # Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
32
+ sudo apt-get install -y clang libclang-dev llvm-dev cmake curl
25
33
  sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
26
34
  # Set environment variables for LLVM 18
27
35
  echo "LIBCLANG_PATH=/usr/lib/llvm-18/lib" >> $GITHUB_ENV
@@ -31,16 +39,29 @@ jobs:
31
39
  ls -la /usr/lib/llvm-18/lib/libclang.so
32
40
  which llvm-config-18
33
41
 
42
+ - name: Build static OpenCV
43
+ if: steps.cache-opencv.outputs.cache-hit != 'true'
44
+ run: |
45
+ ./scripts/build-opencv-static.sh
46
+
34
47
  - name: Build wheels
35
48
  uses: PyO3/maturin-action@v1
36
49
  with:
37
50
  target: ${{ matrix.target }}
38
- args: --release --out dist --find-interpreter --zig --no-default-features --features python-bindings,simd,opencv
39
- sccache: 'true'
40
- manylinux: auto
51
+ args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv
52
+ sccache: 'false'
53
+ container: off
41
54
  env:
42
55
  # Use stable ABI for forward compatibility
43
56
  PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
57
+ # LLVM for opencv-rust bindings (from earlier install step)
58
+ LIBCLANG_PATH: /usr/lib/llvm-18/lib
59
+ LLVM_CONFIG_PATH: /usr/bin/llvm-config-18
60
+ # OpenCV static linking configuration
61
+ OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
62
+ OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
63
+ OPENCV_LINK_LIBS: static=opencv_world,static=stdc++
64
+ OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
44
65
 
45
66
  - name: Upload wheels
46
67
  uses: actions/upload-artifact@v4
@@ -60,28 +81,41 @@ jobs:
60
81
  with:
61
82
  python-version: '3.11'
62
83
 
63
- - name: Install OpenCV (macOS)
84
+ - name: Cache static OpenCV
85
+ id: cache-opencv
86
+ uses: actions/cache@v4
87
+ with:
88
+ path: third_party/opencv-static
89
+ key: opencv-static-4.12.0-v2-macos-${{ runner.os }}-${{ runner.arch }}
90
+
91
+ - name: Install build dependencies
64
92
  run: |
65
- # Install OpenCV and LLVM via Homebrew
66
- brew install opencv llvm
93
+ # Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
94
+ brew install llvm cmake
67
95
  # Set up LLVM environment for opencv-rust bindings (keg-only installation)
68
96
  echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
69
97
  echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
70
98
  echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
71
- # Set up OpenCV environment
72
- 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
73
- echo "OPENCV_LINK_PATHS=/opt/homebrew/lib" >> $GITHUB_ENV
74
- echo "OPENCV_INCLUDE_PATHS=/opt/homebrew/include/opencv4" >> $GITHUB_ENV
99
+
100
+ - name: Build static OpenCV
101
+ if: steps.cache-opencv.outputs.cache-hit != 'true'
102
+ run: |
103
+ ./scripts/build-opencv-static.sh
75
104
 
76
105
  - name: Build wheels
77
106
  uses: PyO3/maturin-action@v1
78
107
  with:
79
108
  target: ${{ matrix.target }}
80
109
  args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv,metal
81
- sccache: 'true'
110
+ sccache: 'false'
82
111
  env:
83
112
  # Use stable ABI for forward compatibility
84
113
  PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
114
+ # OpenCV static linking configuration
115
+ OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
116
+ OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
117
+ OPENCV_LINK_LIBS: static=opencv_world,framework=Accelerate,dylib=c++
118
+ OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
85
119
  - name: Upload wheels
86
120
  uses: actions/upload-artifact@v4
87
121
  with:
@@ -49,6 +49,10 @@ Thumbs.db
49
49
  target/
50
50
  Cargo.lock
51
51
 
52
+ # Static OpenCV bundle (built in CI, not committed)
53
+ third_party/
54
+ opencv-build-tmp/
55
+
52
56
  files.tbz
53
57
  */config/auth.json
54
58
  work
@@ -4,9 +4,9 @@ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "ab_glyph"
7
- version = "0.2.31"
7
+ version = "0.2.32"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "e074464580a518d16a7126262fffaaa47af89d4099d4cb403f8ed938ba12ee7d"
9
+ checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2"
10
10
  dependencies = [
11
11
  "ab_glyph_rasterizer",
12
12
  "owned_ttf_parser",
@@ -50,15 +50,15 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
50
50
 
51
51
  [[package]]
52
52
  name = "anstyle"
53
- version = "1.0.11"
53
+ version = "1.0.13"
54
54
  source = "registry+https://github.com/rust-lang/crates.io-index"
55
- checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
55
+ checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
56
56
 
57
57
  [[package]]
58
58
  name = "anyhow"
59
- version = "1.0.99"
59
+ version = "1.0.100"
60
60
  source = "registry+https://github.com/rust-lang/crates.io-index"
61
- checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
61
+ checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
62
62
 
63
63
  [[package]]
64
64
  name = "approx"
@@ -183,9 +183,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
183
183
 
184
184
  [[package]]
185
185
  name = "cc"
186
- version = "1.2.37"
186
+ version = "1.2.39"
187
187
  source = "registry+https://github.com/rust-lang/crates.io-index"
188
- checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44"
188
+ checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f"
189
189
  dependencies = [
190
190
  "find-msvc-tools",
191
191
  "jobserver",
@@ -258,18 +258,18 @@ dependencies = [
258
258
 
259
259
  [[package]]
260
260
  name = "clap"
261
- version = "4.5.47"
261
+ version = "4.5.48"
262
262
  source = "registry+https://github.com/rust-lang/crates.io-index"
263
- checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
263
+ checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
264
264
  dependencies = [
265
265
  "clap_builder",
266
266
  ]
267
267
 
268
268
  [[package]]
269
269
  name = "clap_builder"
270
- version = "4.5.47"
270
+ version = "4.5.48"
271
271
  source = "registry+https://github.com/rust-lang/crates.io-index"
272
- checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
272
+ checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
273
273
  dependencies = [
274
274
  "anstyle",
275
275
  "clap_lex",
@@ -480,9 +480,9 @@ dependencies = [
480
480
 
481
481
  [[package]]
482
482
  name = "find-msvc-tools"
483
- version = "0.1.1"
483
+ version = "0.1.2"
484
484
  source = "registry+https://github.com/rust-lang/crates.io-index"
485
- checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d"
485
+ checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959"
486
486
 
487
487
  [[package]]
488
488
  name = "flate2"
@@ -543,7 +543,7 @@ dependencies = [
543
543
  "cfg-if",
544
544
  "libc",
545
545
  "r-efi",
546
- "wasi 0.14.5+wasi-0.2.4",
546
+ "wasi 0.14.7+wasi-0.2.4",
547
547
  ]
548
548
 
549
549
  [[package]]
@@ -574,9 +574,9 @@ dependencies = [
574
574
 
575
575
  [[package]]
576
576
  name = "hashbrown"
577
- version = "0.15.5"
577
+ version = "0.16.0"
578
578
  source = "registry+https://github.com/rust-lang/crates.io-index"
579
- checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
579
+ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
580
580
 
581
581
  [[package]]
582
582
  name = "heck"
@@ -644,15 +644,15 @@ dependencies = [
644
644
 
645
645
  [[package]]
646
646
  name = "imgref"
647
- version = "1.11.0"
647
+ version = "1.12.0"
648
648
  source = "registry+https://github.com/rust-lang/crates.io-index"
649
- checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
649
+ checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8"
650
650
 
651
651
  [[package]]
652
652
  name = "indexmap"
653
- version = "2.11.1"
653
+ version = "2.11.4"
654
654
  source = "registry+https://github.com/rust-lang/crates.io-index"
655
- checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
655
+ checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
656
656
  dependencies = [
657
657
  "equivalent",
658
658
  "hashbrown",
@@ -722,9 +722,9 @@ dependencies = [
722
722
 
723
723
  [[package]]
724
724
  name = "js-sys"
725
- version = "0.3.78"
725
+ version = "0.3.81"
726
726
  source = "registry+https://github.com/rust-lang/crates.io-index"
727
- checksum = "0c0b063578492ceec17683ef2f8c5e89121fbd0b172cbc280635ab7567db2738"
727
+ checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
728
728
  dependencies = [
729
729
  "once_cell",
730
730
  "wasm-bindgen",
@@ -738,9 +738,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
738
738
 
739
739
  [[package]]
740
740
  name = "libc"
741
- version = "0.2.175"
741
+ version = "0.2.176"
742
742
  source = "registry+https://github.com/rust-lang/crates.io-index"
743
- checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
743
+ checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
744
744
 
745
745
  [[package]]
746
746
  name = "libfuzzer-sys"
@@ -804,9 +804,9 @@ dependencies = [
804
804
 
805
805
  [[package]]
806
806
  name = "memchr"
807
- version = "2.7.5"
807
+ version = "2.7.6"
808
808
  source = "registry+https://github.com/rust-lang/crates.io-index"
809
- checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
809
+ checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
810
810
 
811
811
  [[package]]
812
812
  name = "memoffset"
@@ -1208,9 +1208,9 @@ dependencies = [
1208
1208
 
1209
1209
  [[package]]
1210
1210
  name = "pxfm"
1211
- version = "0.1.23"
1211
+ version = "0.1.24"
1212
1212
  source = "registry+https://github.com/rust-lang/crates.io-index"
1213
- checksum = "f55f4fedc84ed39cb7a489322318976425e42a147e2be79d8f878e2884f94e84"
1213
+ checksum = "83f9b339b02259ada5c0f4a389b7fb472f933aa17ce176fd2ad98f28bb401fde"
1214
1214
  dependencies = [
1215
1215
  "num-traits",
1216
1216
  ]
@@ -1295,9 +1295,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
1295
1295
 
1296
1296
  [[package]]
1297
1297
  name = "quote"
1298
- version = "1.0.40"
1298
+ version = "1.0.41"
1299
1299
  source = "registry+https://github.com/rust-lang/crates.io-index"
1300
- checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
1300
+ checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
1301
1301
  dependencies = [
1302
1302
  "proc-macro2",
1303
1303
  ]
@@ -1426,9 +1426,9 @@ dependencies = [
1426
1426
 
1427
1427
  [[package]]
1428
1428
  name = "regex"
1429
- version = "1.11.2"
1429
+ version = "1.11.3"
1430
1430
  source = "registry+https://github.com/rust-lang/crates.io-index"
1431
- checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912"
1431
+ checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c"
1432
1432
  dependencies = [
1433
1433
  "aho-corasick",
1434
1434
  "memchr",
@@ -1438,9 +1438,9 @@ dependencies = [
1438
1438
 
1439
1439
  [[package]]
1440
1440
  name = "regex-automata"
1441
- version = "0.4.10"
1441
+ version = "0.4.11"
1442
1442
  source = "registry+https://github.com/rust-lang/crates.io-index"
1443
- checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6"
1443
+ checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad"
1444
1444
  dependencies = [
1445
1445
  "aho-corasick",
1446
1446
  "memchr",
@@ -1497,24 +1497,34 @@ dependencies = [
1497
1497
 
1498
1498
  [[package]]
1499
1499
  name = "semver"
1500
- version = "1.0.26"
1500
+ version = "1.0.27"
1501
1501
  source = "registry+https://github.com/rust-lang/crates.io-index"
1502
- checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
1502
+ checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
1503
1503
 
1504
1504
  [[package]]
1505
1505
  name = "serde"
1506
- version = "1.0.219"
1506
+ version = "1.0.228"
1507
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1508
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
1509
+ dependencies = [
1510
+ "serde_core",
1511
+ "serde_derive",
1512
+ ]
1513
+
1514
+ [[package]]
1515
+ name = "serde_core"
1516
+ version = "1.0.228"
1507
1517
  source = "registry+https://github.com/rust-lang/crates.io-index"
1508
- checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
1518
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
1509
1519
  dependencies = [
1510
1520
  "serde_derive",
1511
1521
  ]
1512
1522
 
1513
1523
  [[package]]
1514
1524
  name = "serde_derive"
1515
- version = "1.0.219"
1525
+ version = "1.0.228"
1516
1526
  source = "registry+https://github.com/rust-lang/crates.io-index"
1517
- checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
1527
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
1518
1528
  dependencies = [
1519
1529
  "proc-macro2",
1520
1530
  "quote",
@@ -1523,14 +1533,15 @@ dependencies = [
1523
1533
 
1524
1534
  [[package]]
1525
1535
  name = "serde_json"
1526
- version = "1.0.143"
1536
+ version = "1.0.145"
1527
1537
  source = "registry+https://github.com/rust-lang/crates.io-index"
1528
- checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
1538
+ checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
1529
1539
  dependencies = [
1530
1540
  "itoa",
1531
1541
  "memchr",
1532
1542
  "ryu",
1533
1543
  "serde",
1544
+ "serde_core",
1534
1545
  ]
1535
1546
 
1536
1547
  [[package]]
@@ -1692,7 +1703,7 @@ dependencies = [
1692
1703
 
1693
1704
  [[package]]
1694
1705
  name = "trainingsample"
1695
- version = "0.2.1"
1706
+ version = "0.2.2"
1696
1707
  dependencies = [
1697
1708
  "anyhow",
1698
1709
  "criterion",
@@ -1775,27 +1786,27 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
1775
1786
 
1776
1787
  [[package]]
1777
1788
  name = "wasi"
1778
- version = "0.14.5+wasi-0.2.4"
1789
+ version = "0.14.7+wasi-0.2.4"
1779
1790
  source = "registry+https://github.com/rust-lang/crates.io-index"
1780
- checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4"
1791
+ checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
1781
1792
  dependencies = [
1782
1793
  "wasip2",
1783
1794
  ]
1784
1795
 
1785
1796
  [[package]]
1786
1797
  name = "wasip2"
1787
- version = "1.0.0+wasi-0.2.4"
1798
+ version = "1.0.1+wasi-0.2.4"
1788
1799
  source = "registry+https://github.com/rust-lang/crates.io-index"
1789
- checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24"
1800
+ checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
1790
1801
  dependencies = [
1791
1802
  "wit-bindgen",
1792
1803
  ]
1793
1804
 
1794
1805
  [[package]]
1795
1806
  name = "wasm-bindgen"
1796
- version = "0.2.101"
1807
+ version = "0.2.104"
1797
1808
  source = "registry+https://github.com/rust-lang/crates.io-index"
1798
- checksum = "7e14915cadd45b529bb8d1f343c4ed0ac1de926144b746e2710f9cd05df6603b"
1809
+ checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
1799
1810
  dependencies = [
1800
1811
  "cfg-if",
1801
1812
  "once_cell",
@@ -1806,9 +1817,9 @@ dependencies = [
1806
1817
 
1807
1818
  [[package]]
1808
1819
  name = "wasm-bindgen-backend"
1809
- version = "0.2.101"
1820
+ version = "0.2.104"
1810
1821
  source = "registry+https://github.com/rust-lang/crates.io-index"
1811
- checksum = "e28d1ba982ca7923fd01448d5c30c6864d0a14109560296a162f80f305fb93bb"
1822
+ checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
1812
1823
  dependencies = [
1813
1824
  "bumpalo",
1814
1825
  "log",
@@ -1820,9 +1831,9 @@ dependencies = [
1820
1831
 
1821
1832
  [[package]]
1822
1833
  name = "wasm-bindgen-macro"
1823
- version = "0.2.101"
1834
+ version = "0.2.104"
1824
1835
  source = "registry+https://github.com/rust-lang/crates.io-index"
1825
- checksum = "7c3d463ae3eff775b0c45df9da45d68837702ac35af998361e2c84e7c5ec1b0d"
1836
+ checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
1826
1837
  dependencies = [
1827
1838
  "quote",
1828
1839
  "wasm-bindgen-macro-support",
@@ -1830,9 +1841,9 @@ dependencies = [
1830
1841
 
1831
1842
  [[package]]
1832
1843
  name = "wasm-bindgen-macro-support"
1833
- version = "0.2.101"
1844
+ version = "0.2.104"
1834
1845
  source = "registry+https://github.com/rust-lang/crates.io-index"
1835
- checksum = "7bb4ce89b08211f923caf51d527662b75bdc9c9c7aab40f86dcb9fb85ac552aa"
1846
+ checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
1836
1847
  dependencies = [
1837
1848
  "proc-macro2",
1838
1849
  "quote",
@@ -1843,18 +1854,18 @@ dependencies = [
1843
1854
 
1844
1855
  [[package]]
1845
1856
  name = "wasm-bindgen-shared"
1846
- version = "0.2.101"
1857
+ version = "0.2.104"
1847
1858
  source = "registry+https://github.com/rust-lang/crates.io-index"
1848
- checksum = "f143854a3b13752c6950862c906306adb27c7e839f7414cec8fea35beab624c1"
1859
+ checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
1849
1860
  dependencies = [
1850
1861
  "unicode-ident",
1851
1862
  ]
1852
1863
 
1853
1864
  [[package]]
1854
1865
  name = "web-sys"
1855
- version = "0.3.78"
1866
+ version = "0.3.81"
1856
1867
  source = "registry+https://github.com/rust-lang/crates.io-index"
1857
- checksum = "77e4b637749ff0d92b8fad63aa1f7cff3cbe125fd49c175cd6345e7272638b12"
1868
+ checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120"
1858
1869
  dependencies = [
1859
1870
  "js-sys",
1860
1871
  "wasm-bindgen",
@@ -1882,7 +1893,7 @@ version = "0.1.11"
1882
1893
  source = "registry+https://github.com/rust-lang/crates.io-index"
1883
1894
  checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
1884
1895
  dependencies = [
1885
- "windows-sys 0.61.0",
1896
+ "windows-sys 0.61.1",
1886
1897
  ]
1887
1898
 
1888
1899
  [[package]]
@@ -1892,7 +1903,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1892
1903
  checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1"
1893
1904
  dependencies = [
1894
1905
  "windows-core",
1895
- "windows-targets 0.53.3",
1906
+ "windows-targets 0.53.4",
1896
1907
  ]
1897
1908
 
1898
1909
  [[package]]
@@ -1905,7 +1916,7 @@ dependencies = [
1905
1916
  "windows-interface",
1906
1917
  "windows-result",
1907
1918
  "windows-strings",
1908
- "windows-targets 0.53.3",
1919
+ "windows-targets 0.53.4",
1909
1920
  ]
1910
1921
 
1911
1922
  [[package]]
@@ -1921,9 +1932,9 @@ dependencies = [
1921
1932
 
1922
1933
  [[package]]
1923
1934
  name = "windows-interface"
1924
- version = "0.59.1"
1935
+ version = "0.59.2"
1925
1936
  source = "registry+https://github.com/rust-lang/crates.io-index"
1926
- checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
1937
+ checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5"
1927
1938
  dependencies = [
1928
1939
  "proc-macro2",
1929
1940
  "quote",
@@ -1971,9 +1982,9 @@ dependencies = [
1971
1982
 
1972
1983
  [[package]]
1973
1984
  name = "windows-sys"
1974
- version = "0.61.0"
1985
+ version = "0.61.1"
1975
1986
  source = "registry+https://github.com/rust-lang/crates.io-index"
1976
- checksum = "e201184e40b2ede64bc2ea34968b28e33622acdbbf37104f0e4a33f7abe657aa"
1987
+ checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f"
1977
1988
  dependencies = [
1978
1989
  "windows-link 0.2.0",
1979
1990
  ]
@@ -1996,11 +2007,11 @@ dependencies = [
1996
2007
 
1997
2008
  [[package]]
1998
2009
  name = "windows-targets"
1999
- version = "0.53.3"
2010
+ version = "0.53.4"
2000
2011
  source = "registry+https://github.com/rust-lang/crates.io-index"
2001
- checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91"
2012
+ checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b"
2002
2013
  dependencies = [
2003
- "windows-link 0.1.3",
2014
+ "windows-link 0.2.0",
2004
2015
  "windows_aarch64_gnullvm 0.53.0",
2005
2016
  "windows_aarch64_msvc 0.53.0",
2006
2017
  "windows_i686_gnu 0.53.0",
@@ -2118,9 +2129,9 @@ dependencies = [
2118
2129
 
2119
2130
  [[package]]
2120
2131
  name = "wit-bindgen"
2121
- version = "0.45.1"
2132
+ version = "0.46.0"
2122
2133
  source = "registry+https://github.com/rust-lang/crates.io-index"
2123
- checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36"
2134
+ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
2124
2135
 
2125
2136
  [[package]]
2126
2137
  name = "zerocopy"
@@ -37,7 +37,7 @@ description = "High-performance Rust reimplementation of GIL-blocking video/imag
37
37
  edition = "2021"
38
38
  license = "MIT"
39
39
  name = "trainingsample"
40
- version = "0.2.1"
40
+ version = "0.2.2"
41
41
  readme = "README.md"
42
42
 
43
43
  [profile.release]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trainingsample
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -24,8 +24,7 @@ import trainingsample as tsr
24
24
  # 1.12x FASTER than cv2.resize() - leveraging OpenCV C++ without binding overhead
25
25
  result = tsr.batch_resize_images_zero_copy(
26
26
  img, # np.ndarray - single image
27
- target_size, # (width, height) - target dimensions
28
- interpolation=tsr.INTER_LINEAR # Optional: INTER_NEAREST, INTER_LINEAR (default), INTER_CUBIC, INTER_LANCZOS4
27
+ target_size # (width, height) - target dimensions
29
28
  )
30
29
  # Direct numpy array return, zero wrapper overhead, intelligent dispatch
31
30
  ```
@@ -35,36 +34,16 @@ result = tsr.batch_resize_images_zero_copy(
35
34
  # BATCH LIST API: 2.4x faster than OpenCV individual calls
36
35
  results = tsr.batch_resize_images_zero_copy(
37
36
  images, # List[np.ndarray] - batch of images
38
- target_sizes, # List[(width, height)] - target dimensions
39
- interpolation=tsr.INTER_LINEAR # Optional: choose interpolation method
37
+ target_sizes # List[(width, height)] - target dimensions
40
38
  )
41
39
  # Returns: List[np.ndarray] - perfect for immediate processing
42
40
 
43
41
  # ITERATOR API: True zero-copy with lazy conversion (memory efficient)
44
- for result in tsr.batch_resize_images_iterator(images, target_sizes, interpolation=tsr.INTER_CUBIC):
42
+ for result in tsr.batch_resize_images_iterator(images, target_sizes):
45
43
  process(result) # Convert only when accessed, supports early termination
46
44
  # 2.3x faster than OpenCV, minimal memory footprint
47
45
  ```
48
46
 
49
- #### 🎯 Interpolation Methods
50
- ```python
51
- # Available interpolation constants (OpenCV-compatible):
52
- tsr.INTER_NEAREST # Fast, blocky - good for masks/labels
53
- tsr.INTER_LINEAR # Default - good balance of speed and quality
54
- tsr.INTER_CUBIC # High quality, slower - best for upsampling
55
- tsr.INTER_LANCZOS4 # Best quality, slowest - professional upsampling
56
-
57
- # Usage examples:
58
- fast_resize = tsr.batch_resize_images_zero_copy(images, sizes, tsr.INTER_NEAREST)
59
- quality_resize = tsr.batch_resize_images_zero_copy(images, sizes, tsr.INTER_LANCZOS4)
60
-
61
- # Performance vs Quality Trade-offs:
62
- # INTER_NEAREST: ~4x faster than LANCZOS4, acceptable for downsampling
63
- # INTER_LINEAR: ~2x faster than LANCZOS4, good general purpose (default)
64
- # INTER_CUBIC: ~1.5x faster than LANCZOS4, good for upsampling
65
- # INTER_LANCZOS4: Best quality, use for professional image processing
66
- ```
67
-
68
47
  ### Batch Cropping (Zero-Copy)
69
48
  ```python
70
49
  # 4-5x faster than regular batch operations
@@ -0,0 +1,103 @@
1
+ # Building a statically linked OpenCV bundle
2
+
3
+ The `opencv` crate expects to find an existing OpenCV toolkit and, by default, it
4
+ links against the dynamic libraries that come with a system installation
5
+ (`libopencv_core.dylib`, `libopencv_core.so`, …). To ship the `trainingsample`
6
+ crate without asking end users to install OpenCV themselves, build a static
7
+ OpenCV distribution once and point Cargo at it during compilation.
8
+
9
+ ## 1. Build OpenCV as static libraries
10
+
11
+ 1. Download an official OpenCV source archive (4.9+ recommended) and place it
12
+ somewhere outside the repository, e.g. `~/Downloads/opencv-4.10.0`.
13
+ 2. Configure a *Release* build that turns off shared libraries and only enables
14
+ the modules that `trainingsample` uses. On macOS or Linux:
15
+
16
+ ```bash
17
+ cmake -S ~/Downloads/opencv-4.10.0 \
18
+ -B ~/Downloads/opencv-build-static \
19
+ -DBUILD_LIST=core,imgproc,imgcodecs,highgui,video,videoio,calib3d,features2d,photo \
20
+ -DBUILD_SHARED_LIBS=OFF \
21
+ -DBUILD_opencv_world=ON \
22
+ -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF \
23
+ -DWITH_IPP=OFF -DWITH_OPENCL=OFF -DWITH_CUDA=OFF
24
+ cmake --build ~/Downloads/opencv-build-static --config Release --target opencv_world
25
+ cmake --install ~/Downloads/opencv-build-static \
26
+ --config Release \
27
+ --prefix $(pwd)/third_party/opencv-static
28
+ ```
29
+
30
+ The `opencv_world` target gives you a single `libopencv_world.a` archive;
31
+ switch it off and install the individual module archives if you prefer.
32
+
33
+ 3. After installation you should have:
34
+
35
+ ```text
36
+ third_party/opencv-static/include/opencv4/...
37
+ third_party/opencv-static/lib/libopencv_world.a
38
+ third_party/opencv-static/lib/libz.a (and other third-party static deps)
39
+ ```
40
+
41
+ If your OpenCV build links to optional third-party components (TBB, JPEG,
42
+ PNG, WebP, etc.), install their static archives into the same `lib/` folder
43
+ so Cargo can link them in one pass.
44
+
45
+ > **macOS note**: Apple does not provide static builds of the C++ standard
46
+ > library. Replace `static=stdc++` with `dylib=c++` (or `framework=Accelerate`
47
+ > when required) in the linking step below.
48
+
49
+ ## 2. Point Cargo at the static toolchain
50
+
51
+ Add a `.cargo/config.toml` (kept inside the repo) with the environment variables
52
+ that the `opencv` build script understands:
53
+
54
+ ```toml
55
+ [env]
56
+ # Paths are resolved relative to the workspace root.
57
+ OPENCV_INCLUDE_PATHS = { value = "third_party/opencv-static/include", relative = true }
58
+ OPENCV_LINK_PATHS = { value = "third_party/opencv-static/lib", relative = true }
59
+ # Tell the build script to stop probing the system.
60
+ OPENCV_DISABLE_PROBES = "pkg_config,cmake,vcpkg"
61
+ # Static link OpenCV and the extra libraries it depends on.
62
+ # Adjust the list to match the archives present in third_party/opencv-static/lib.
63
+ OPENCV_LINK_LIBS = "static=opencv_world,static=png,static=jpeg,static=tiff,static=webp,static=z,static=stdc++"
64
+ ```
65
+
66
+ If you elected to install the individual module archives instead of
67
+ `opencv_world`, list each one (`static=opencv_core`, `static=opencv_imgproc`,
68
+ …). Keep the order roughly from high- to low-level modules so the linker can
69
+ resolve symbols in one pass.
70
+
71
+ For cross-compilation add target-specific sections, e.g.:
72
+
73
+ ```toml
74
+ [target.aarch64-apple-darwin.env]
75
+ OPENCV_LINK_LIBS = "static=opencv_world,static=png,static=jpeg,static=tiff,static=z,dylib=c++"
76
+ ```
77
+
78
+ ## 3. Build the crate
79
+
80
+ With the static bundle in place you can now build the crate without touching the
81
+ system OpenCV installation:
82
+
83
+ ```bash
84
+ cargo build --features opencv --release
85
+ ```
86
+
87
+ The resulting `libtrainingsample.{so,dylib}` (or the wheels produced by the
88
+ Python bindings) now embed the OpenCV symbols directly, so end users do not need
89
+ `opencv_core` on their machines.
90
+
91
+ ## 4. Regenerating the bundle
92
+
93
+ Whenever you need to update OpenCV:
94
+
95
+ 1. Re-run the CMake configure/build/install steps pointing at the new source
96
+ tree.
97
+ 2. Verify that the list in `OPENCV_LINK_LIBS` still matches the archives produced.
98
+ 3. Commit the regenerated contents of `third_party/opencv-static/` if you keep
99
+ it under version control (or upload it to your release pipeline’s artifact
100
+ store).
101
+
102
+ That is all Cargo needs—no changes to `Cargo.toml` are required beyond enabling
103
+ the `opencv` feature when you want the acceleration path.
@@ -14,7 +14,7 @@ description = "High-performance Rust reimplementation of GIL-blocking video/imag
14
14
  license = {text = "MIT"}
15
15
  name = "trainingsample"
16
16
  requires-python = ">=3.11"
17
- version = "0.2.1"
17
+ version = "0.2.2"
18
18
 
19
19
  [project.optional-dependencies]
20
20
  dev = ["pytest>=6.0", "pytest-benchmark", "maturin>=1.0,<2.0", "pre-commit"]
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Build static OpenCV bundle for embedding in Python wheels
5
+ # This eliminates the need for users to install OpenCV system packages
6
+
7
+ OPENCV_VERSION="4.12.0"
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
10
+ BUILD_DIR="${PROJECT_ROOT}/opencv-build-tmp"
11
+ INSTALL_DIR="${PROJECT_ROOT}/third_party/opencv-static"
12
+
13
+ echo "Building static OpenCV ${OPENCV_VERSION}..."
14
+ echo "Install directory: ${INSTALL_DIR}"
15
+
16
+ # Skip if already built
17
+ if [ -d "${INSTALL_DIR}/lib" ] && [ -f "${INSTALL_DIR}/lib/libopencv_world.a" ]; then
18
+ echo "Static OpenCV already built at ${INSTALL_DIR}"
19
+ exit 0
20
+ fi
21
+
22
+ # Create build directory
23
+ mkdir -p "${BUILD_DIR}"
24
+ cd "${BUILD_DIR}"
25
+
26
+ # Download OpenCV source if not already present
27
+ if [ ! -d "opencv-${OPENCV_VERSION}" ]; then
28
+ echo "Downloading OpenCV ${OPENCV_VERSION}..."
29
+ curl -L "https://github.com/opencv/opencv/archive/refs/tags/${OPENCV_VERSION}.tar.gz" \
30
+ -o "opencv-${OPENCV_VERSION}.tar.gz"
31
+ tar -xzf "opencv-${OPENCV_VERSION}.tar.gz"
32
+ fi
33
+
34
+ # Configure CMake build
35
+ echo "Configuring CMake build..."
36
+ cmake -S "opencv-${OPENCV_VERSION}" \
37
+ -B build \
38
+ -DCMAKE_BUILD_TYPE=Release \
39
+ -DBUILD_LIST=core,imgproc,imgcodecs,highgui,video,videoio,calib3d,features2d,photo \
40
+ -DBUILD_SHARED_LIBS=OFF \
41
+ -DBUILD_opencv_world=ON \
42
+ -DBUILD_TESTS=OFF \
43
+ -DBUILD_PERF_TESTS=OFF \
44
+ -DBUILD_EXAMPLES=OFF \
45
+ -DBUILD_opencv_apps=OFF \
46
+ -DBUILD_DOCS=OFF \
47
+ -DWITH_IPP=OFF \
48
+ -DWITH_OPENCL=OFF \
49
+ -DWITH_CUDA=OFF \
50
+ -DWITH_FFMPEG=OFF \
51
+ -DWITH_GSTREAMER=OFF \
52
+ -DWITH_V4L=OFF \
53
+ -DWITH_GTK=OFF \
54
+ -DWITH_QT=OFF \
55
+ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
56
+
57
+ # Build opencv_world (single unified library)
58
+ echo "Building OpenCV (this may take several minutes)..."
59
+ cmake --build build --config Release --target opencv_world -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)
60
+
61
+ # Install to third_party/opencv-static
62
+ echo "Installing to ${INSTALL_DIR}..."
63
+ cmake --install build --config Release
64
+
65
+ # Verify installation - check both lib and lib64 (manylinux uses lib64)
66
+ if [ -f "${INSTALL_DIR}/lib64/libopencv_world.a" ]; then
67
+ # Move from lib64 to lib for consistency
68
+ mkdir -p "${INSTALL_DIR}/lib"
69
+ mv "${INSTALL_DIR}/lib64"/* "${INSTALL_DIR}/lib/"
70
+ rmdir "${INSTALL_DIR}/lib64"
71
+ fi
72
+
73
+ if [ ! -f "${INSTALL_DIR}/lib/libopencv_world.a" ]; then
74
+ echo "ERROR: libopencv_world.a not found after installation"
75
+ echo "Contents of ${INSTALL_DIR}:"
76
+ ls -R "${INSTALL_DIR}"
77
+ exit 1
78
+ fi
79
+
80
+ echo "Static OpenCV built successfully!"
81
+ echo "Library: ${INSTALL_DIR}/lib/libopencv_world.a"
82
+ echo "Headers: ${INSTALL_DIR}/include/opencv4/"
83
+
84
+ # Clean up build directory to save space
85
+ cd "${PROJECT_ROOT}"
86
+ rm -rf "${BUILD_DIR}"
87
+
88
+ echo "Build complete!"
@@ -138,11 +138,5 @@ fn trainingsample(m: &Bound<'_, PyModule>) -> PyResult<()> {
138
138
  // TRUE BATCH PROCESSING API (actually batched, not just parallel loops)
139
139
  m.add_class::<crate::python_bindings::PyTrueBatchProcessor>()?;
140
140
 
141
- // INTERPOLATION CONSTANTS (OpenCV-compatible)
142
- m.add("INTER_NEAREST", 0)?;
143
- m.add("INTER_LINEAR", 1)?;
144
- m.add("INTER_CUBIC", 2)?;
145
- m.add("INTER_LANCZOS4", 4)?;
146
-
147
141
  Ok(())
148
142
  }
@@ -180,7 +180,13 @@ impl OpenCVBatchProcessor {
180
180
  )?;
181
181
 
182
182
  #[cfg(not(target_os = "macos"))]
183
- cvt_color(&src_mat, &mut gray_mat, COLOR_RGB2GRAY, 0)?;
183
+ cvt_color(
184
+ &src_mat,
185
+ &mut gray_mat,
186
+ COLOR_RGB2GRAY,
187
+ 0,
188
+ opencv::core::AlgorithmHint::ALGO_HINT_DEFAULT,
189
+ )?;
184
190
 
185
191
  // Calculate mean (luminance)
186
192
  let mean_scalar = opencv::core::mean(&gray_mat, &opencv::core::no_array())?;
@@ -247,26 +247,14 @@ pub fn batch_calculate_luminance_zero_copy(
247
247
 
248
248
  #[cfg(all(feature = "python-bindings", feature = "opencv"))]
249
249
  #[pyfunction]
250
- #[pyo3(signature = (images, target_sizes, interpolation=None))]
251
250
  pub fn batch_resize_images_zero_copy<'py>(
252
251
  py: Python<'py>,
253
252
  images: &Bound<'py, PyAny>,
254
253
  target_sizes: &Bound<'py, PyAny>,
255
- interpolation: Option<i32>,
256
254
  ) -> PyResult<Bound<'py, PyAny>> {
257
- use crate::cv_compat::imgproc::ResizeInterpolation;
258
255
  use pyo3::types::PyList;
259
256
  use rayon::prelude::*;
260
257
 
261
- // Convert interpolation parameter (default to bilinear if not specified)
262
- let interp = match interpolation.unwrap_or(1) {
263
- 0 => ResizeInterpolation::InterNearest,
264
- 1 => ResizeInterpolation::InterLinear,
265
- 2 => ResizeInterpolation::InterCubic,
266
- 4 => ResizeInterpolation::InterLanczos4,
267
- _ => ResizeInterpolation::InterLinear, // Default fallback
268
- };
269
-
270
258
  // INTELLIGENT OVERLOADING: Detect single vs batch input
271
259
  let is_single_image = is_numpy_array(images);
272
260
  let is_single_size = is_tuple_or_list_of_two(target_sizes);
@@ -275,7 +263,7 @@ pub fn batch_resize_images_zero_copy<'py>(
275
263
  // SINGLE IMAGE PATH: Direct return, zero wrapper overhead!
276
264
  let image_array = images.extract::<PyReadonlyArray3<u8>>()?;
277
265
  let size_tuple = target_sizes.extract::<(usize, usize)>()?;
278
- let result = resize_single_image_direct(py, &image_array, size_tuple, interp)?;
266
+ let result = resize_single_image_direct(py, &image_array, size_tuple)?;
279
267
  return Ok(result.into_any());
280
268
  }
281
269
 
@@ -338,14 +326,6 @@ pub fn batch_resize_images_zero_copy<'py>(
338
326
  // Adaptive processing: use parallel only for larger batches to avoid threading overhead
339
327
  let use_parallel = batch_size >= 8; // Threshold where parallel processing becomes beneficial
340
328
 
341
- // Convert interpolation to OpenCV constant
342
- let cv_interpolation = match interp {
343
- ResizeInterpolation::InterNearest => opencv::imgproc::INTER_NEAREST,
344
- ResizeInterpolation::InterLinear => opencv::imgproc::INTER_LINEAR,
345
- ResizeInterpolation::InterCubic => opencv::imgproc::INTER_CUBIC,
346
- ResizeInterpolation::InterLanczos4 => opencv::imgproc::INTER_LANCZOS4,
347
- };
348
-
349
329
  let results: Result<Vec<ndarray::Array3<u8>>, String> = if use_parallel {
350
330
  // Pre-allocate all buffers on main thread to avoid lock contention
351
331
  let mut buffers = Vec::with_capacity(batch_size);
@@ -367,7 +347,6 @@ pub fn batch_resize_images_zero_copy<'py>(
367
347
  (data.src_height, data.src_width, data.src_channels),
368
348
  (data.target_height, data.target_width),
369
349
  output_buffer,
370
- cv_interpolation,
371
350
  )
372
351
  })
373
352
  .collect::<Result<Vec<_>, _>>()
@@ -385,7 +364,6 @@ pub fn batch_resize_images_zero_copy<'py>(
385
364
  (data.src_height, data.src_width, data.src_channels),
386
365
  (data.target_height, data.target_width),
387
366
  output_buffer,
388
- cv_interpolation,
389
367
  )
390
368
  };
391
369
  match result {
@@ -424,9 +402,11 @@ unsafe fn resize_raw_buffer(
424
402
  src_shape: (usize, usize, usize), // (height, width, channels)
425
403
  target_shape: (usize, usize), // (height, width)
426
404
  mut output_buffer: Vec<u8>,
427
- interpolation: i32, // OpenCV interpolation flag
428
405
  ) -> Result<ndarray::Array3<u8>, String> {
429
- use opencv::{core::Mat, imgproc::resize};
406
+ use opencv::{
407
+ core::Mat,
408
+ imgproc::{resize, INTER_LINEAR},
409
+ };
430
410
 
431
411
  let (src_height, src_width, channels) = src_shape;
432
412
  let (target_height, target_width) = target_shape;
@@ -468,7 +448,7 @@ unsafe fn resize_raw_buffer(
468
448
  opencv::core::Size::new(target_width as i32, target_height as i32),
469
449
  0.0,
470
450
  0.0,
471
- interpolation,
451
+ INTER_LINEAR,
472
452
  )
473
453
  .map_err(|e| format!("OpenCV resize failed: {}", e))?;
474
454
 
@@ -494,11 +474,10 @@ fn resize_single_image_direct<'py>(
494
474
  py: Python<'py>,
495
475
  image: &PyReadonlyArray3<u8>,
496
476
  target_size: (usize, usize),
497
- interpolation: crate::cv_compat::imgproc::ResizeInterpolation,
498
477
  ) -> PyResult<Bound<'py, PyArray3<u8>>> {
499
478
  use opencv::{
500
479
  core::Mat,
501
- imgproc::{resize, INTER_CUBIC, INTER_LANCZOS4, INTER_LINEAR, INTER_NEAREST},
480
+ imgproc::{resize, INTER_LINEAR},
502
481
  };
503
482
 
504
483
  let img_view = image.as_array();
@@ -545,15 +524,6 @@ fn resize_single_image_direct<'py>(
545
524
  })?
546
525
  };
547
526
 
548
- // Convert ResizeInterpolation to OpenCV flag
549
- use crate::cv_compat::imgproc::ResizeInterpolation;
550
- let cv_interpolation = match interpolation {
551
- ResizeInterpolation::InterNearest => INTER_NEAREST,
552
- ResizeInterpolation::InterLinear => INTER_LINEAR,
553
- ResizeInterpolation::InterCubic => INTER_CUBIC,
554
- ResizeInterpolation::InterLanczos4 => INTER_LANCZOS4,
555
- };
556
-
557
527
  // OpenCV writes directly into our result array - MAXIMUM PERFORMANCE!
558
528
  resize(
559
529
  &src_mat,
@@ -561,7 +531,7 @@ fn resize_single_image_direct<'py>(
561
531
  opencv::core::Size::new(target_width as i32, target_height as i32),
562
532
  0.0,
563
533
  0.0,
564
- cv_interpolation,
534
+ INTER_LINEAR,
565
535
  )
566
536
  .map_err(|e| {
567
537
  pyo3::exceptions::PyRuntimeError::new_err(format!("OpenCV resize failed: {}", e))
@@ -651,37 +621,17 @@ impl ResizeIterator {
651
621
  /// NEW ITERATOR API: Zero-copy batch resize with lazy conversion
652
622
  #[cfg(all(feature = "python-bindings", feature = "opencv"))]
653
623
  #[pyfunction]
654
- #[pyo3(signature = (images, target_sizes, interpolation=None))]
655
624
  pub fn batch_resize_images_iterator<'py>(
656
625
  py: Python<'py>,
657
626
  images: Vec<PyReadonlyArray3<u8>>,
658
627
  target_sizes: Vec<(usize, usize)>,
659
- interpolation: Option<i32>,
660
628
  ) -> PyResult<Bound<'py, ResizeIterator>> {
661
- use crate::cv_compat::imgproc::ResizeInterpolation;
662
629
  use opencv::{
663
630
  core::Mat,
664
- imgproc::{resize, INTER_CUBIC, INTER_LANCZOS4, INTER_LINEAR, INTER_NEAREST},
631
+ imgproc::{resize, INTER_LINEAR},
665
632
  };
666
633
  use rayon::prelude::*;
667
634
 
668
- // Convert interpolation parameter (default to bilinear if not specified)
669
- let interp = match interpolation.unwrap_or(1) {
670
- 0 => ResizeInterpolation::InterNearest,
671
- 1 => ResizeInterpolation::InterLinear,
672
- 2 => ResizeInterpolation::InterCubic,
673
- 4 => ResizeInterpolation::InterLanczos4,
674
- _ => ResizeInterpolation::InterLinear, // Default fallback
675
- };
676
-
677
- // Convert to OpenCV constant
678
- let cv_interpolation = match interp {
679
- ResizeInterpolation::InterNearest => INTER_NEAREST,
680
- ResizeInterpolation::InterLinear => INTER_LINEAR,
681
- ResizeInterpolation::InterCubic => INTER_CUBIC,
682
- ResizeInterpolation::InterLanczos4 => INTER_LANCZOS4,
683
- };
684
-
685
635
  let batch_size = images.len();
686
636
  if batch_size != target_sizes.len() {
687
637
  return Err(pyo3::exceptions::PyValueError::new_err(
@@ -787,7 +737,7 @@ pub fn batch_resize_images_iterator<'py>(
787
737
  ),
788
738
  0.0,
789
739
  0.0,
790
- cv_interpolation,
740
+ INTER_LINEAR,
791
741
  )
792
742
  .map_err(|e| format!("OpenCV resize failed: {}", e))?;
793
743
 
@@ -850,7 +800,7 @@ pub fn batch_resize_images_iterator<'py>(
850
800
  opencv::core::Size::new(data.target_width as i32, data.target_height as i32),
851
801
  0.0,
852
802
  0.0,
853
- cv_interpolation,
803
+ INTER_LINEAR,
854
804
  ) {
855
805
  return Err(pyo3::exceptions::PyRuntimeError::new_err(format!(
856
806
  "OpenCV resize failed: {}",
@@ -1,4 +1,3 @@
1
- #[allow(unused_imports)]
2
1
  use super::*;
3
2
  use ndarray::{Array3, Array4};
4
3
 
@@ -6,7 +5,6 @@ fn create_test_image() -> Array3<u8> {
6
5
  Array3::from_shape_fn((100, 100, 3), |(y, x, c)| ((x + y + c * 50) % 256) as u8)
7
6
  }
8
7
 
9
- #[allow(dead_code)]
10
8
  fn create_test_video() -> Array4<u8> {
11
9
  Array4::from_shape_fn((5, 50, 50, 3), |(f, y, x, c)| {
12
10
  ((x + y + c * 50 + f * 10) % 256) as u8
@@ -15,11 +13,9 @@ fn create_test_video() -> Array4<u8> {
15
13
 
16
14
  #[cfg(test)]
17
15
  mod x86_optimization_tests {
18
- #[allow(unused_imports)]
19
16
  use super::*;
20
17
  use ndarray::Array3;
21
18
 
22
- #[allow(dead_code)]
23
19
  fn create_large_test_image() -> Array3<u8> {
24
20
  Array3::from_shape_fn((256, 256, 3), |(y, x, c)| ((x + y + c * 85) % 256) as u8)
25
21
  }
@@ -57,7 +53,6 @@ mod x86_optimization_tests {
57
53
 
58
54
  #[cfg(test)]
59
55
  mod cropping_tests {
60
- #[allow(unused_imports)]
61
56
  use super::*;
62
57
 
63
58
  #[test]
@@ -106,7 +101,6 @@ mod cropping_tests {
106
101
 
107
102
  #[cfg(test)]
108
103
  mod luminance_tests {
109
- #[allow(unused_imports)]
110
104
  use super::*;
111
105
 
112
106
  #[test]
@@ -141,7 +135,6 @@ mod luminance_tests {
141
135
 
142
136
  #[cfg(test)]
143
137
  mod resize_tests {
144
- #[allow(unused_imports)]
145
138
  use super::*;
146
139
 
147
140
  #[test]
@@ -179,7 +172,6 @@ mod resize_tests {
179
172
 
180
173
  #[cfg(test)]
181
174
  mod batch_tests {
182
- #[allow(unused_imports)]
183
175
  use super::*;
184
176
 
185
177
  #[test]
@@ -237,7 +229,6 @@ mod batch_tests {
237
229
 
238
230
  #[cfg(test)]
239
231
  mod integration_tests {
240
- #[allow(unused_imports)]
241
232
  use super::*;
242
233
 
243
234
  #[test]
@@ -275,7 +266,6 @@ mod integration_tests {
275
266
 
276
267
  #[cfg(test)]
277
268
  mod edge_case_tests {
278
- #[allow(unused_imports)]
279
269
  use super::*;
280
270
 
281
271
  #[test]
@@ -309,7 +299,6 @@ mod edge_case_tests {
309
299
  // OpenCV specific tests
310
300
  #[cfg(test)]
311
301
  mod opencv_tests {
312
- #[allow(unused_imports)]
313
302
  use super::*;
314
303
 
315
304
  #[cfg(feature = "opencv")]
@@ -282,7 +282,13 @@ impl TrueBatchProcessor {
282
282
  opencv::core::AlgorithmHint::ALGO_HINT_DEFAULT,
283
283
  )?;
284
284
  #[cfg(not(target_os = "macos"))]
285
- cvt_color(&src_mats[i], &mut dst_mat, opencv_code, 0)?;
285
+ cvt_color(
286
+ &src_mats[i],
287
+ &mut dst_mat,
288
+ opencv_code,
289
+ 0,
290
+ opencv::core::AlgorithmHint::ALGO_HINT_DEFAULT,
291
+ )?;
286
292
 
287
293
  results.push(result);
288
294
  }
File without changes
File without changes
File without changes