Update video capture example code
MODIFY
examples/video_capture.rs
examples/video_capture.rs
@@ -7,11 +7,10 @@ use opencv::videoio;
fn run() -> opencv::Result<()> {
let window = "video capture";
highgui::named_window(window, 1)?;
- let mut cam = videoio::VideoCapture::new(1)?;
+ let mut cam = videoio::VideoCapture::new(0)?; // 0 is the default camera
let opened = videoio::VideoCapture::is_opened(&cam)?;
if !opened {
- println!("Using different camera");
- cam = videoio::VideoCapture::new(0)?;
+ panic!("Unable to open default camera!");
}
loop {
let mut frame = core::Mat::new()?;

MODIFY
examples/video_facedetect.rs
examples/video_facedetect.rs
@@ -8,11 +8,10 @@ fn run() -> opencv::Result<()> {
let window = "video capture";
let xml = "/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml";
highgui::named_window(window, 1)?;
- let mut cam = videoio::VideoCapture::new(1)?;
+ let mut cam = videoio::VideoCapture::new(0)?; // 0 is the default camera
let opened = videoio::VideoCapture::is_opened(&cam)?;
if !opened {
- println!("Using different camera");
- cam = videoio::VideoCapture::new(0)?;
+ panic!("Unable to open default camera!");
}
let mut face = objdetect::CascadeClassifier::new(xml)?;
loop {

MODIFY
examples/video_features.rs
examples/video_features.rs
@@ -8,11 +8,10 @@ use opencv::videoio;
fn run() -> opencv::Result<()> {
let window = "video capture";
highgui::named_window(window, 1)?;
- let mut cam = videoio::VideoCapture::new(1)?;
+ let mut cam = videoio::VideoCapture::new(0)?; // 0 is the default camera
let opened = videoio::VideoCapture::is_opened(&cam)?;
if !opened {
- println!("Using different camera");
- cam = videoio::VideoCapture::new(0)?;
+ panic!("Unable to open default camera!");
}
let mut orb = features2d::ORB::create(
500,

MODIFY
examples/video_to_gray.rs
examples/video_to_gray.rs
@@ -8,11 +8,10 @@ use opencv::videoio;
fn run() -> opencv::Result<()> {
let window = "video capture";
highgui::named_window(window, 1)?;
- let mut cam = videoio::VideoCapture::new(1)?;
+ let mut cam = videoio::VideoCapture::new(0)?; // 0 is the default camera
let opened = videoio::VideoCapture::is_opened(&cam)?;
if !opened {
- println!("Using different camera");
- cam = videoio::VideoCapture::new(0)?;
+ panic!("Unable to open default camera!");
}
loop {
let mut frame = core::Mat::new()?;

Update video capture example code