Skip to content

Commit 64751f3

Browse files
authored
Merge pull request #118 from pipeless-ai/source_camera
feat: Allow source camera selection
2 parents 5af9a31 + e18797c commit 64751f3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

pipeless/Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pipeless/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pipeless-ai"
3-
version = "1.5.4"
3+
version = "1.6.0"
44
edition = "2021"
55
authors = ["Miguel A. Cabrera Minagorri"]
66
description = "An open-source computer vision framework to build and deploy applications in minutes"

pipeless/src/config/video.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Video {
3030
// Output to the screen
3131
protocol = String::from("screen");
3232
location = String::from("screen");
33-
} else if uri != "v4l2" {
33+
} else if !uri.starts_with("v4l2") {
3434
let uri_split: Vec<&str> = uri.split("://").collect();
3535
protocol = uri_split.get(0).ok_or_else(|| { VideoConfigError::new("Unable to get protocol from URI") })?.to_string();
3636
location = uri_split.get(1)

pipeless/src/input/pipeline.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,20 @@ fn create_input_bin(
158158
pipeless_bus_sender: &tokio::sync::mpsc::UnboundedSender<pipeless::events::Event>,
159159
) -> Result<gst::Bin, InputPipelineError> {
160160
let bin = gst::Bin::new();
161-
if uri == "v4l2" { // Device webcam
161+
if uri.starts_with("v4l2") { // Device webcam
162162
let v4l2src = pipeless::gst::utils::create_generic_component("v4l2src", "v4l2src")?;
163163
let videoconvert = pipeless::gst::utils::create_generic_component("videoconvert", "videoconvert")?;
164164
let videoscale = pipeless::gst::utils::create_generic_component("videoscale", "videoscale")?;
165165

166+
// The input uri for v4l2 can contain the device to use. Example: "v4l2:/dev/video0"
167+
let uri_parts: Vec<&str> = uri.split(':').collect();
168+
if uri_parts.len() == 2 {
169+
v4l2src.set_property("device", uri_parts[1]);
170+
} else if uri_parts.len() > 2 {
171+
error!("The provided input URI using v4l2 contains more than one video source. URI: {}", uri);
172+
return Err(InputPipelineError::new("Wrong input URI provided"));
173+
}
174+
166175
// Webcam resolutions are not standard and we can't read the webcam caps,
167176
// force a hardcoded resolution so that we annouce a correct resolution to the output.
168177
let forced_size_str = "video/x-raw,width=1280,height=720";

0 commit comments

Comments
 (0)