Skip to content

Commit

Permalink
✨🏗️ changed cargo features
Browse files Browse the repository at this point in the history
  • Loading branch information
chriamue committed Jan 30, 2022
1 parent a77b68e commit b902959
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
toolchain: stable
- run: cargo install cross
- run: cargo install cargo-deb
- run: cross build --release --target armv7-unknown-linux-gnueabihf
- run: cross build --features=pi --release --target armv7-unknown-linux-gnueabihf
- run: ls
- run: ls target
- run: ls target/armv7-unknown-linux-gnueabihf
Expand Down
52 changes: 47 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ readme = "README.md"
repository = "https://github.com/chriamue/ornithology-pi"

[features]
default = ["bluetooth", "server", "window", "nokhwa/input-gst"]
default = ["server", "camera"]
full = ["bluetooth", "camera", "detect", "hotspot", "server"]
pi = ["bluetooth", "camera", "detect", "server"]
bluetooth = ["bluer"]
camera = ["nokhwa/input-gst"]
hotspot = ["wifi-rs"]
server = ["base64", "rocket", "rocket-include-static-resources"]
window = ["show-image/image"]
detect = [
"camera",
"lenna_core",
"lenna_core",
"lenna_birds_plugin",
"lenna_yolo_plugin",
"tract-onnx",
]

[dependencies]
async-trait = "0.1"
Expand All @@ -31,11 +42,11 @@ image = { version = "0.23.14", default-features = false, features = [
"jpeg",
] }
imageproc = { version = "0.22", default-features = false }
lenna_core = { git = "https://github.com/lenna-project/lenna-core", branch = "main" }
lenna_yolo_plugin = { git = "https://github.com/lenna-project/yolo-plugin", branch = "main", default-features = false }
lenna_birds_plugin = { git = "https://github.com/lenna-project/birds-plugin", branch = "main", default-features = false }
lenna_core = { git = "https://github.com/lenna-project/lenna-core", branch = "main", optional = true }
lenna_birds_plugin = { git = "https://github.com/lenna-project/birds-plugin", branch = "main", default-features = false, optional = true }
lenna_yolo_plugin = { git = "https://github.com/lenna-project/yolo-plugin", branch = "main", default-features = false, optional = true }
nokhwa = { version = "0.9.4", features = ["input-gst"] }
tract-onnx = { git = "https://github.com/sonos/tract.git", branch = "main" }
tract-onnx = { git = "https://github.com/sonos/tract.git", branch = "main", optional = true }

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down Expand Up @@ -85,3 +96,34 @@ assets = [
]
maintainer-scripts = "debian/"
systemd-units = { enable = false }

############# Examples ####

[[example]]
name = "window"
required-features = ["detect", "window"]

[[example]]
name = "label"
required-features = ["detect"]

[[example]]
name = "crop"
required-features = ["detect"]

[[example]]
name = "bluetooth"
required-features = ["bluetooth"]

[[example]]
name = "bt_client"
required-features = ["bluetooth"]

[[example]]
name = "bt_gatt_srv"
required-features = ["bluetooth"]

[[example]]
name = "hotspot"
required-features = ["hotspot"]

7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[cfg(feature = "detect")]
pub mod detector;
#[cfg(feature = "detect")]
pub use detector::BirdDetector;

pub mod capture;
Expand All @@ -7,15 +9,20 @@ pub use capture::WebCam;
pub mod mjpeg;
pub use mjpeg::MJpeg;

#[cfg(feature = "detect")]
pub mod crop;
#[cfg(feature = "detect")]
pub use crop::Crop;
#[cfg(feature = "detect")]
pub mod label;
#[cfg(feature = "detect")]
pub use label::Label;

pub mod sighting;
pub use sighting::{DataSighting, Sighting};

pub mod errors;

pub mod observer;

#[cfg(feature = "bluetooth")]
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ornithology_pi::bluetooth::run_bluetooth;
use ornithology_pi::hotspot::Hotspot;
#[cfg(feature = "server")]
use ornithology_pi::server::server;
#[cfg(feature = "detect")]
use ornithology_pi::{detector::Detector, BirdDetector};
use ornithology_pi::{
observer::{Observable, Observer},
Expand Down Expand Up @@ -40,6 +41,7 @@ impl Observer for BirdObserver {
}
}

#[cfg(feature = "detect")]
async fn run_detector(sightings: Arc<Mutex<Vec<Sighting>>>, capture: Arc<Mutex<WebCam>>) {
let observer = BirdObserver { sightings };

Expand All @@ -62,6 +64,7 @@ async fn main() {

#[cfg(feature = "bluetooth")]
let bluetooth_thread = tokio::spawn(run_bluetooth(sightings.clone()));
#[cfg(feature = "detect")]
let detector_thread = tokio::spawn(run_detector(sightings.clone(), capture.clone()));

#[cfg(feature = "hotspot")]
Expand All @@ -76,6 +79,7 @@ async fn main() {

#[cfg(feature = "bluetooth")]
bluetooth_thread.abort();
#[cfg(feature = "detect")]
detector_thread.abort();

#[cfg(feature = "hotspot")]
Expand Down
2 changes: 2 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "detect")]
use crate::BirdDetector;
use crate::{MJpeg, Sighting, WebCam};
use rocket::fs::NamedFile;
Expand Down Expand Up @@ -32,6 +33,7 @@ fn index(

#[derive(Clone)]
pub struct DetectorState {
#[cfg(feature = "detect")]
pub mutex: Arc<Mutex<BirdDetector>>,
}

Expand Down

0 comments on commit b902959

Please sign in to comment.