Skip to content

Commit ff52de7

Browse files
feat: add viewer feature (default: minifb) (#137)
1 parent 101c9e2 commit ff52de7

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ imageproc = { version = "0.25" }
2020
ndarray = { version = "0.16.1", features = ["rayon", "serde"] }
2121
indicatif = { version = "0.17.11" }
2222
log = "0.4.26"
23-
minifb = { version = "0.28.0" }
23+
minifb = { version = "0.28.0", optional = true }
2424
rand = { version = "0.9" }
2525
http = "1.3"
2626
ureq = { version = "3" }
@@ -47,8 +47,6 @@ ort = { version = "=2.0.0-rc.10", default-features = false, optional = true, fea
4747
hf-hub = { version = "0.4.3", default-features = false, features = ["ureq", "native-tls"] }
4848
tokenizers = { version = "0.21.1" }
4949
paste = "1.0.15"
50-
base64ct = "=1.7.3"
51-
once_cell = "1.20"
5250

5351

5452
[dev-dependencies]
@@ -57,7 +55,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "chrono"] }
5755

5856

5957
[features]
60-
default = [ "ort-download-binaries" ]
58+
default = [ "ort-download-binaries", "viewer" ]
6159
serde = []
6260
video = [ "dep:video-rs" ]
6361
ort-download-binaries = [ "ort", "ort/download-binaries" ]
@@ -80,3 +78,13 @@ qnn = [ "ort/qnn" ]
8078
migraphx = [ "ort/migraphx" ]
8179
vitis = [ "ort/vitis" ]
8280
azure = [ "ort/azure" ]
81+
viewer = [ "dep:minifb" ]
82+
83+
84+
[[example]]
85+
name = "read_video"
86+
required-features = ["video"]
87+
88+
[[example]]
89+
name = "imshow"
90+
required-features = ["viewer"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ usls = "latest-version"
125125
## 📦 Cargo Features
126126
- **`ort-download-binaries`** (**default**): Automatically downloads prebuilt ONNXRuntime binaries for supported platforms
127127
- **`ort-load-dynamic`**: Dynamic linking to ONNXRuntime libraries ([Guide](https://ort.pyke.io/setup/linking#dynamic-linking))
128-
- **`video`**: Enable video stream reading and writing (via [video-rs](https://github.com/oddity-ai/video-rs) and [minifb](https://github.com/emoon/rust_minifb))
128+
- **`video`**: Enable video stream reading and writing (via [video-rs](https://github.com/oddity-ai/video-rs))
129+
- **`viewer`**: Enable image and video stream visualization (via [minifb](https://github.com/emoon/rust_minifb))
129130
- **`cuda`**: NVIDIA CUDA GPU acceleration support
130131
- **`tensorrt`**: NVIDIA TensorRT optimization for inference acceleration
131132
- **`coreml`**: Apple CoreML acceleration for macOS/iOS devices

src/core/global_ts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use once_cell::sync::Lazy;
21
use std::collections::HashMap;
32
use std::sync::{Arc, Mutex};
43
use std::time::{Duration, Instant};
@@ -299,7 +298,8 @@ impl GlobalTsManager {
299298
}
300299

301300
/// Global singleton instance
302-
static GLOBAL_TS_MANAGER: Lazy<GlobalTsManager> = Lazy::new(GlobalTsManager::new);
301+
static GLOBAL_TS_MANAGER: std::sync::LazyLock<GlobalTsManager> =
302+
std::sync::LazyLock::new(GlobalTsManager::new);
303303

304304
/// Get the global Ts manager instance
305305
pub fn global_ts_manager() -> &'static GlobalTsManager {

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
//! ## ⚡ Cargo Features
2828
//! - **`ort-download-binaries`** (**default**): Automatically downloads prebuilt ONNXRuntime binaries for supported platforms
2929
//! - **`ort-load-dynamic`**: Dynamic linking to ONNXRuntime libraries ([Guide](https://ort.pyke.io/setup/linking#dynamic-linking))
30-
//! - **`video`**: Enable video stream reading and writing (via [video-rs](https://github.com/oddity-ai/video-rs) and [minifb](https://github.com/emoon/rust_minifb))
30+
//! - **`video`**: Enable video stream reading and writing (via [video-rs](https://github.com/oddity-ai/video-rs)
31+
//! - **`viewer`**: Enable image and video stream visualization (via [minifb](https://github.com/emoon/rust_minifb))
3132
//! - **`cuda`**: NVIDIA CUDA GPU acceleration support
3233
//! - **`tensorrt`**: NVIDIA TensorRT optimization for inference acceleration
3334
//! - **`coreml`**: Apple CoreML acceleration for macOS/iOS devices
@@ -49,14 +50,14 @@
4950
//!
5051
5152
pub mod core;
52-
/// Model Zoo
5353
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
5454
pub mod models;
5555
#[macro_use]
5656
mod results;
5757
pub mod viz;
5858

5959
pub use core::*;
60+
#[cfg(feature = "viewer")]
6061
pub use minifb::Key;
6162
#[cfg(any(feature = "ort-download-binaries", feature = "ort-load-dynamic"))]
6263
pub use models::*;

src/viz/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ pub use draw_ctx::*;
1515
pub use drawable::*;
1616
pub use styles::*;
1717
pub use text_renderer::*;
18+
#[cfg(feature = "viewer")]
1819
pub use viewer::*;

0 commit comments

Comments
 (0)