diff --git a/settings.toml b/settings.toml index 6a4be7c..563929e 100644 --- a/settings.toml +++ b/settings.toml @@ -1,5 +1,6 @@ -camera_ip = "localhost" +camera_ip = "10.0.0.33" camera_port = 8765 tracker_ip = "localhost" tracker_port = 6543 -tracker_refresh_rate_millis = 100 +tracker_refresh_rate_millis = 10 +tracker_jpeg_quality = 80 diff --git a/src/config.rs b/src/config.rs index 6da8b41..1c1ab97 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,6 +13,7 @@ pub struct AppConfig { pub tracker_ip: String, pub tracker_port: u32, pub tracker_refresh_rate_millis: u32, + pub tracker_jpeg_quality: i32, } impl Default for AppConfig { @@ -24,6 +25,7 @@ impl Default for AppConfig { tracker_ip: "10.0.0.210".to_string(), tracker_port: 6543, tracker_refresh_rate_millis: 100, + tracker_jpeg_quality: 50, } } } diff --git a/src/coordinator/coord_state.rs b/src/coordinator/coord_state.rs index a24e2bb..b5f6f9b 100644 --- a/src/coordinator/coord_state.rs +++ b/src/coordinator/coord_state.rs @@ -60,6 +60,7 @@ impl<'a> CoordState<'a> { to_gui: Sender, rt: Handle, settings: Arc>, + jpeg_quality: i32, ) -> Self { let this = CoordState { settings, @@ -81,7 +82,7 @@ impl<'a> CoordState<'a> { to_gui, rt, - pipeline: gstreamer_pipeline::WebcamPipeline::new().unwrap(), + pipeline: gstreamer_pipeline::WebcamPipeline::new(jpeg_quality).unwrap(), tracker_state: TrackerState{ tracking_id: 0, diff --git a/src/coordinator/mod.rs b/src/coordinator/mod.rs index b951024..0fde775 100644 --- a/src/coordinator/mod.rs +++ b/src/coordinator/mod.rs @@ -76,12 +76,15 @@ pub async fn start_coordinator( let mec = pin!(mec); + let jpeg_quality = settings.read().await.tracker_jpeg_quality.clone(); + let mut state = CoordState::new( mec, to_mec, to_gui, runtime, settings, + jpeg_quality, ); state diff --git a/src/gstreamer_pipeline.rs b/src/gstreamer_pipeline.rs index ff18c35..aab6e30 100644 --- a/src/gstreamer_pipeline.rs +++ b/src/gstreamer_pipeline.rs @@ -6,8 +6,6 @@ use snafu::prelude::*; use std::str::FromStr; use std::sync::{Arc, Mutex}; -pub const JPEG_QUALITY: i32 = 40; - #[derive(Debug)] pub struct WebcamPipeline { pub pipeline: Pipeline, @@ -18,7 +16,7 @@ pub struct WebcamPipeline { } impl WebcamPipeline { - pub fn new() -> Result { + pub fn new(jpeg_quality: i32) -> Result { let pipeline = Pipeline::with_name("webcam_pipeline"); // All of the following errors are unrecoverable @@ -78,7 +76,7 @@ impl WebcamPipeline { })?; let jpeg_enc = ElementFactory::make("jpegenc") - .property("quality", JPEG_QUALITY) + .property("quality", jpeg_quality) .build() .context(BuildSnafu { element: "jpegenc" })?;