added settigns-based jpeg quality

This commit is contained in:
Nickiel12 2024-06-29 14:18:12 -07:00
parent c28ffbaa17
commit 8a997a3d4c
5 changed files with 12 additions and 7 deletions

View file

@ -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

View file

@ -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,
}
}
}

View file

@ -60,6 +60,7 @@ impl<'a> CoordState<'a> {
to_gui: Sender<GuiUpdate>,
rt: Handle,
settings: Arc<RwLock<AppConfig>>,
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,

View file

@ -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

View file

@ -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<WebcamPipeline, PipelineError> {
pub fn new(jpeg_quality: i32) -> Result<WebcamPipeline, PipelineError> {
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" })?;