Skip to content

Commit

Permalink
📌 use nokhwa git version
Browse files Browse the repository at this point in the history
  • Loading branch information
chriamue committed Oct 21, 2023
1 parent 5aafada commit 7aaca8f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
102 changes: 49 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ repository = "https://github.com/chriamue/ornithology-pi"
build = "build.rs"

[features]
default = ["server", "camera", "yolo"]
default = ["server", "camera", "yolo", "bt-server"]
full = ["bt-server", "camera", "detect", "hotspot", "server"]
pi = ["bt-server", "camera", "detect", "server"]
bluetooth = ["base64"]
bt-server = ["bluetooth", "bluer"]
webcam = ["camera"]
camera = ["nokhwa/input-native"]
hotspot = ["wifi-rs"]
server = ["axum", "base64", "tower", "tower-http"]
server = ["axum", "base64", "tower", "tower-http", "webcam"]
window = ["show-image/image"]
detect = [
"camera",
Expand Down Expand Up @@ -51,7 +51,7 @@ lenna_birds_plugin = { git = "https://github.com/lenna-project/birds-plugin", br
lenna_yolo_plugin = { git = "https://github.com/lenna-project/yolo-plugin", branch = "main", default-features = false, optional = true }
log = "0.4"
mime = "0.3.17"
nokhwa = { version = "0.10.4", features = ["output-threaded"], optional = true}
nokhwa = { git = "https://github.com/l1npengtul/nokhwa", branch = "0.10", features = ["output-threaded"], optional = true}

rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
Expand Down
8 changes: 6 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(feature = "detect")]
use crate::BirdDetector;
use crate::{sighting::save_to_file, Config};
use crate::{Capture, MJpeg, Sighting, WebCam};
use crate::{Capture, Sighting};
#[cfg(feature = "webcam")]
use crate::{MJpeg, WebCam};
use axum::{
body::StreamBody,
extract,
Expand Down Expand Up @@ -89,6 +91,7 @@ async fn get_sightings(
Ok(Json(json!(sightings)))
}

#[cfg(feature = "webcam")]
async fn webcam(
Extension(capture): Extension<Arc<Mutex<WebCam>>>,
) -> Result<Response<Body>, AppError> {
Expand All @@ -104,6 +107,7 @@ async fn webcam(
.map_err(|_| AppError::ResponseBuildError)
}

#[cfg(feature = "webcam")]
async fn frame(
Extension(capture): Extension<Arc<Mutex<WebCam>>>,
) -> Result<Response<Body>, AppError> {
Expand Down Expand Up @@ -189,9 +193,9 @@ pub async fn server(config: &Config, sightings: SightingsContainer, capture: Arc
let app = Router::new()
.nest_service("/", serve_dir.clone())
.route("/generate_204", get(generate_204))
.route("/sightings", get(get_sightings))
.route("/webcam", get(webcam))
.route("/frame", get(frame))
.route("/sightings", get(get_sightings))
.route("/sightings/:id", get(sighting))
.route("/sightings/:id", delete(delete_sighting))
.layer(Extension(sightings.clone()))
Expand Down

0 comments on commit 7aaca8f

Please sign in to comment.