diff --git a/pipeless/Cargo.lock b/pipeless/Cargo.lock index 1ba3283..a1dd6e6 100644 --- a/pipeless/Cargo.lock +++ b/pipeless/Cargo.lock @@ -1483,7 +1483,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pipeless-ai" -version = "1.5.4" +version = "1.6.0" dependencies = [ "clap", "env_logger", diff --git a/pipeless/Cargo.toml b/pipeless/Cargo.toml index 4e6c877..b8f5f26 100644 --- a/pipeless/Cargo.toml +++ b/pipeless/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pipeless-ai" -version = "1.5.4" +version = "1.6.0" edition = "2021" authors = ["Miguel A. Cabrera Minagorri"] description = "An open-source computer vision framework to build and deploy applications in minutes" diff --git a/pipeless/src/config/video.rs b/pipeless/src/config/video.rs index 6bc56b2..141ddd4 100644 --- a/pipeless/src/config/video.rs +++ b/pipeless/src/config/video.rs @@ -30,7 +30,7 @@ impl Video { // Output to the screen protocol = String::from("screen"); location = String::from("screen"); - } else if uri != "v4l2" { + } else if !uri.starts_with("v4l2") { let uri_split: Vec<&str> = uri.split("://").collect(); protocol = uri_split.get(0).ok_or_else(|| { VideoConfigError::new("Unable to get protocol from URI") })?.to_string(); location = uri_split.get(1) diff --git a/pipeless/src/input/pipeline.rs b/pipeless/src/input/pipeline.rs index 02ee31a..4b533b0 100644 --- a/pipeless/src/input/pipeline.rs +++ b/pipeless/src/input/pipeline.rs @@ -158,11 +158,20 @@ fn create_input_bin( pipeless_bus_sender: &tokio::sync::mpsc::UnboundedSender, ) -> Result { let bin = gst::Bin::new(); - if uri == "v4l2" { // Device webcam + if uri.starts_with("v4l2") { // Device webcam let v4l2src = pipeless::gst::utils::create_generic_component("v4l2src", "v4l2src")?; let videoconvert = pipeless::gst::utils::create_generic_component("videoconvert", "videoconvert")?; let videoscale = pipeless::gst::utils::create_generic_component("videoscale", "videoscale")?; + // The input uri for v4l2 can contain the device to use. Example: "v4l2:/dev/video0" + let uri_parts: Vec<&str> = uri.split(':').collect(); + if uri_parts.len() == 2 { + v4l2src.set_property("device", uri_parts[1]); + } else if uri_parts.len() > 2 { + error!("The provided input URI using v4l2 contains more than one video source. URI: {}", uri); + return Err(InputPipelineError::new("Wrong input URI provided")); + } + // Webcam resolutions are not standard and we can't read the webcam caps, // force a hardcoded resolution so that we annouce a correct resolution to the output. let forced_size_str = "video/x-raw,width=1280,height=720";