Skip to content

Commit d7bf6aa

Browse files
author
admin
committed
add features
1 parent 1883ac3 commit d7bf6aa

33 files changed

+437
-395
lines changed

.github/workflows/ci.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths-ignore:
7+
- 'README.md'
8+
pull_request:
9+
branches: [ "main" ]
10+
paths-ignore:
11+
- 'README.md'
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
18+
build-linux:
19+
name: build / linux / ffmpeg ${{ matrix.ffmpeg_version }}
20+
runs-on: ubuntu-latest
21+
container: jrottenberg/ffmpeg:${{ matrix.ffmpeg_version }}-ubuntu
22+
23+
strategy:
24+
matrix:
25+
include:
26+
# FFmpeg 7.x
27+
- ffmpeg_version: "7.1"
28+
feature: "rsmpeg,image,ndarray,nalgebra,imageproc"
29+
fail-fast: false
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Install dependencies
36+
run: |
37+
DEBIAN_FRONTEND=noninteractive apt-get update
38+
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ca-certificates clang curl pkg-config
39+
40+
- name: Setup Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Build
44+
run: cargo build --no-default-features --features ${{ matrix.feature }} --verbose
45+
46+
- name: Run Test
47+
run: cargo test --no-default-features --features ${{ matrix.feature }} --verbose
48+
49+
build-macos:
50+
name: build / macos / latest ffmpeg
51+
runs-on: macos-latest
52+
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Install dependencies
58+
run: |
59+
brew install ffmpeg pkg-config
60+
61+
- name: Setup Rust
62+
uses: dtolnay/rust-toolchain@stable
63+
64+
- name: Build
65+
run: cargo build --no-default-features --features ${{ matrix.feature }} --verbose
66+
67+
- name: Run Test
68+
run: cargo test --no-default-features --features ${{ matrix.feature }} --verbose
69+
70+
build-windows:
71+
name: build / windows / latest ffmpeg
72+
runs-on: windows-latest
73+
74+
env:
75+
FFMPEG_DOWNLOAD_URL: https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z
76+
RUST_BACKTRACE: 1
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
82+
- name: Install dependencies
83+
run: |
84+
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
85+
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
86+
Invoke-WebRequest "${env:FFMPEG_DOWNLOAD_URL}" -OutFile ffmpeg-release-full-shared.7z
87+
7z x ffmpeg-release-full-shared.7z
88+
mv ffmpeg-*/* ffmpeg/
89+
Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n"
90+
Add-Content $env:GITHUB_ENV "FFMPEG_INCLUDE_DIR=${pwd}\ffmpeg\include`n"
91+
Add-Content $env:GITHUB_ENV "FFMPEG_LIBS_DIR=${pwd}\ffmpeg\lib`n"
92+
Add-Content $env:GITHUB_ENV "FFMPEG_DLL_PATH=${pwd}\ffmpeg\bin`n"
93+
Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n"
94+
95+
- name: Setup Rust
96+
uses: dtolnay/rust-toolchain@stable
97+
98+
- name: Build
99+
run: cargo build --no-default-features --features ${{ matrix.feature }} --verbose
100+
101+
- name: Run Test
102+
run: cargo test --no-default-features --features ${{ matrix.feature }} --verbose
103+
104+
test:
105+
runs-on: ubuntu-latest
106+
container: jrottenberg/ffmpeg:7.1-ubuntu
107+
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v4
111+
112+
- name: Install dependencies
113+
run: |
114+
DEBIAN_FRONTEND=noninteractive apt-get update
115+
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ca-certificates clang curl pkg-config
116+
117+
# - name: Setup Rust
118+
# uses: dtolnay/rust-toolchain@stable
119+
- name: Setup Rust
120+
uses: dtolnay/rust-toolchain@nightly
121+
122+
- name: Test
123+
run: cargo +nightly test --no-default-features --features ${{ matrix.feature }} --verbose
124+
125+
lints:
126+
runs-on: ubuntu-latest
127+
container: jrottenberg/ffmpeg:7.1-ubuntu
128+
129+
steps:
130+
- name: Checkout
131+
uses: actions/checkout@v4
132+
133+
- name: Install dependencies
134+
run: |
135+
DEBIAN_FRONTEND=noninteractive apt-get update
136+
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ca-certificates clang curl pkg-config
137+
138+
- name: Setup Rust
139+
uses: dtolnay/rust-toolchain@stable
140+
with:
141+
components: rustfmt, clippy
142+
143+
- name: Rustfmt
144+
run: cargo fmt --all -- --all-features --check
145+
146+
- name: Clippy
147+
run: cargo clippy --all --no-default-features --features ${{ matrix.feature }} -- -D warnings

Cargo.toml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,20 @@ features = ['docs-only']
1515

1616
[features]
1717
default = [
18-
'tch',
19-
'rsmpeg',
20-
'ndarray',
21-
'opencv',
22-
'nalgebra',
23-
'image',
24-
'imageproc',
25-
]
26-
docs-only = [
27-
'tch',
28-
'rsmpeg',
29-
'ndarray',
30-
'opencv',
31-
'nalgebra',
32-
'image',
33-
'imageproc',
18+
"image",
19+
"ndarray",
20+
"nalgebra",
21+
"imageproc",
3422
]
23+
image = ["dep:image"]
24+
ndarray = ["dep:ndarray"]
25+
nalgebra = ["dep:nalgebra"]
26+
imageproc = ["dep:imageproc"]
27+
# 系统依赖库
28+
tch = ["dep:tch"]
29+
rsmpeg = ["dep:rsmpeg"]
30+
opencv = ["dep:opencv"]
31+
full = ["tch", "rsmpeg", "opencv"]
3532

3633
[dev-dependencies]
3734
rand = '0.9'
@@ -42,24 +39,12 @@ itertools = '0.14'
4239
half = '2.4'
4340
anyhow = '1.0'
4441
num-traits = '0.2'
45-
tch = { version = '0.18', default-features = true, optional = true}
4642
image = { version = '0.25', default-features = true, optional = true }
4743
nalgebra = { version = '0.33', default-features = true, optional = true }
4844
ndarray = { version = '0.16', default-features = true, optional = true }
4945
imageproc = { version = '0.25', default-features = true, optional = true }
46+
tch = { version = '0.18', default-features = true, optional = true}
47+
opencv = { version = '0.94', default-features = true, optional = true, features = ["clang-runtime"] }
5048
rsmpeg = { git = "https://github.com/larksuite/rsmpeg", branch = "master", optional = true, features = [
5149
"ffmpeg7", "link_system_ffmpeg"
5250
] }
53-
opencv = { version = '0.94', optional = true, features = [
54-
"dnn",
55-
"videoio",
56-
"highgui",
57-
"imgproc",
58-
"imgcodecs",
59-
"calib3d",
60-
"features2d",
61-
"objdetect",
62-
"tracking",
63-
"stitching",
64-
"clang-runtime",
65-
] }

LICENSE renamed to LICENSE.txt

File renamed without changes.

README.md

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,45 @@
1-
# cv-convert: Convert computer vision data types in Rust
1+
# cv-convert
2+
Convert computer vision data types in Rust
23

34
Type conversions among famous Rust computer vision libraries. It
45
supports the following crates:
56

67
reference:
78
https://github.com/jerry73204/rust-cv-convert
89

10+
## sys related
11+
- [opencv](https://crates.io/crates/opencv)
12+
- [tch](https://crates.io/crates/tch)
13+
- [rsmpeg](https://crates.io/crates/rsmpeg)
14+
15+
## lib
916
- [image](https://crates.io/crates/image)
1017
- [imageproc](https://crates.io/crates/imageproc)
1118
- [nalgebra](https://crates.io/crates/nalgebra)
12-
- [opencv](https://crates.io/crates/opencv)
13-
- [tch](https://crates.io/crates/tch)
1419
- [ndarray](https://crates.io/crates/ndarray)
1520

1621
## Usage
1722

18-
Run `cargo add cv-convert` to add this crate to your project. In the
19-
default setting, up-to-date dependency versions are used.
20-
21-
If you desire to enable specified dependency versions. Add
22-
`default-features = false` and select crate versions as Cargo
23-
features. For example, the feature `nalgebra_0-30` enables nalgebra
24-
0.30.x.
25-
2623
```toml
27-
[dependencies.cv-convert]
28-
version = 'x.y.z' # Please look up the recent version on crates.io
29-
default-features = false
30-
features = [
31-
'image',
32-
'opencv',
33-
'tch',
34-
'nalgebra',
35-
'ndarray',
36-
]
24+
[dependencies]
25+
cv-convert = { git = "https://github.com/phial3/cv-convert", branch = "main" }
3726
```
3827

3928
The minimum supported `rustc` is 1.81. You may use older versions of
4029
the crate (>=0.6) in order to use `rustc` versions that do not support
4130
const-generics.
4231

4332
## Cargo Features
33+
- `default`: enable `image` + `imageproc` + `nalgebra` + `ndarray`
34+
- `tch`
35+
- `opencv`
36+
- `rsmpeg`
37+
- `full` : enable `tch` + `opencv` + `rsmpeg`
38+
- `image`
39+
- `imageproc`
40+
- `nalgebra`
41+
- `ndarray`
4442

45-
### opencv
46-
47-
- `opencv 0.93`
48-
49-
### image
50-
51-
- `image 0.25`
52-
53-
### imageproc
54-
55-
- `imageproc 0.25`
56-
57-
### ndarray
58-
59-
- `ndarray 0.16`
60-
61-
### nalgebra
62-
63-
- `nalgebra 0.33`
64-
65-
### tch
66-
67-
- `tch 0.13`
6843

6944
## Usage
7045

0 commit comments

Comments
 (0)