[package]
name = "od_opencv"
repository = "https://github.com/LdDl/object-detection-opencv-rust"
readme = "README.md"
keywords = [
  "computer-vision",
  "object-detection",
  "yolo",
  "opencv",
  "onnx",
]
license = "MIT"
version = "0.6.0"
edition = "2024"
rust-version = "1.91.0"
authors = ["Dimitrii Lopanov <sexykdi@gmail.com>"]
exclude = ["/.github", "/ci", "/tools", "/scripts", "release.toml", "rustfmt.toml", "/images", "/pretrained"]
description = "Object detection utilities in Rust programming language for YOLO-based neural networks in OpenCV ecosystem"
homepage = "https://github.com/LdDl/object-detection-opencv-rust"
documentation = "https://docs.rs/od_opencv"
categories = [
  "algorithms",
  "multimedia",
  "computer-vision",
  "mathematics",
  "science",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["ort-backend"]

# Backend features - user should choose one
# opencv-backend adds the DNN module which conflicts with ORT static linking
opencv-backend = ["dep:opencv", "opencv/dnn"]
ort-backend = ["dep:ort", "dep:image"]

# GPU acceleration for ort-backend
ort-cuda-backend = ["ort-backend", "ort/cuda"]
ort-tensorrt-backend = ["ort-backend", "ort/tensorrt"]

# Compatibility layer: allows ORT backend to accept OpenCV Mat
# Note: This does NOT enable OpenCV's DNN module to avoid conflicts with ORT
ort-opencv-compat = ["ort-backend", "dep:opencv"]

# RKNN NPU backend (Rockchip RV1106 has been tested only)
rknn-backend = ["dep:rknn-runtime", "dep:image"]

# Preprocessing options
letterbox = []

[lib]
name = "od_opencv"
path = "src/lib.rs"
doctest = false

# YOLOv3 examples
[[example]]
name = "yolo_v3"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v3_tiny"
required-features = ["opencv-backend"]

# YOLOv4 examples
[[example]]
name = "yolo_v4"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v4_tiny"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v4_tiny_onnx"
required-features = ["opencv-backend"]

# YOLOv7 examples
[[example]]
name = "yolo_v7"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v7_tiny"
required-features = ["opencv-backend"]

# YOLOv8 examples
[[example]]
name = "yolo_v8_l"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v8_m"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v8_n"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v8_s"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v8_x"
required-features = ["opencv-backend"]

# YOLOv9 examples
[[example]]
name = "yolo_v9_c"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v9_e"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v9_m"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v9_s"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v9_t"
required-features = ["opencv-backend"]

# YOLOv11 examples
[[example]]
name = "yolo_v11_l"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v11_m"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v11_n"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v11_s"
required-features = ["opencv-backend"]

[[example]]
name = "yolo_v11_x"
required-features = ["opencv-backend"]

# YOLOv8 examples (ort-backend)
[[example]]
name = "yolo_v8_n_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v8_s_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v8_m_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v8_l_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v8_x_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v8_n_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v8_s_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v8_m_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v8_l_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v8_x_ort_cuda"
required-features = ["ort-cuda-backend"]

# YOLOv9 examples (ort-backend)
[[example]]
name = "yolo_v9_t_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v9_s_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v9_m_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v9_c_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v9_e_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v9_t_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v9_s_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v9_m_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v9_c_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v9_e_ort_cuda"
required-features = ["ort-cuda-backend"]

# YOLOv11 examples (ort-backend)
[[example]]
name = "yolo_v11_n_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v11_s_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v11_m_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v11_l_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v11_x_ort"
required-features = ["ort-backend"]

[[example]]
name = "yolo_v11_n_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v11_s_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v11_m_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v11_l_ort_cuda"
required-features = ["ort-cuda-backend"]

[[example]]
name = "yolo_v11_x_ort_cuda"
required-features = ["ort-cuda-backend"]

# YOLOv8s - ORT + OpenCV compatibility example
[[example]]
name = "yolo_v8_s_ort_opencv"
required-features = ["ort-opencv-compat"]

# YOLOv8 examples (rknn-backend)
[[example]]
name = "yolo_v8_n_rknn"
required-features = ["rknn-backend"]

# YOLOv5u examples (ort-backend) - Ultralytics updated format (same as YOLOv8)
[[example]]
name = "yolo_v5u_n_ort"
required-features = ["ort-backend"]

# YOLOv5u examples (opencv-backend) - Ultralytics updated format (same as YOLOv8)
[[example]]
name = "yolo_v5u_n"
required-features = ["opencv-backend"]

# YOLOv5 examples (ort-backend) - Original format with objectness score
[[example]]
name = "yolo_v5_n_ort"
required-features = ["ort-backend"]

# YOLOv5 examples (opencv-backend)
[[example]]
name = "yolo_v5_n"
required-features = ["opencv-backend"]

[dependencies]
lazy_static = "1.5.0"
ndarray = "0.16"

# OpenCV backend (dnn feature is added via opencv-backend feature flag to avoid conflicts with ORT)
opencv = { version = "0.96.0", default-features = false, features = ["imgcodecs", "imgproc"], optional = true }

# ORT (ONNX runtime) backend
ort = { version = "2.0.0-rc.10", optional = true }
image = { version = "0.25", optional = true }

# RKNN NPU backend
rknn-runtime = { version = "0.1.1", optional = true }

[patch.crates-io]
cc = { git = "https://github.com/rust-lang/cc-rs.git", version = "1.0", tag = "1.0.79" }
