Skip to content

Commit

Permalink
Merge pull request #118 from pipeless-ai/source_camera
Browse files Browse the repository at this point in the history
feat: Allow source camera selection
  • Loading branch information
miguelaeh authored Jan 16, 2024
2 parents 5af9a31 + e18797c commit 64751f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pipeless/Cargo.lock

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

2 changes: 1 addition & 1 deletion pipeless/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pipeless/src/config/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion pipeless/src/input/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,20 @@ fn create_input_bin(
pipeless_bus_sender: &tokio::sync::mpsc::UnboundedSender<pipeless::events::Event>,
) -> Result<gst::Bin, InputPipelineError> {
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";
Expand Down

0 comments on commit 64751f3

Please sign in to comment.