desktop: open camera check

This commit is contained in:
ardocrat 2024-09-15 15:54:07 +03:00
parent d6ec4213ab
commit c3fae38d5c

View file

@ -226,8 +226,7 @@ impl Desktop {
let ctx = PlatformContext::default(); let ctx = PlatformContext::default();
let devices = ctx.devices().unwrap(); let devices = ctx.devices().unwrap();
let dev = ctx.open_device(&devices[0].uri).unwrap(); if let Ok(dev) = ctx.open_device(&devices[0].uri) {
let streams = dev.streams().unwrap(); let streams = dev.streams().unwrap();
let stream_desc = streams[0].clone(); let stream_desc = streams[0].clone();
let w = stream_desc.width; let w = stream_desc.width;
@ -239,7 +238,6 @@ impl Desktop {
// Stop if camera was stopped. // Stop if camera was stopped.
if stop_camera.load(Ordering::Relaxed) { if stop_camera.load(Ordering::Relaxed) {
stop_camera.store(false, Ordering::Relaxed); stop_camera.store(false, Ordering::Relaxed);
// Clear image.
let mut w_image = LAST_CAMERA_IMAGE.write(); let mut w_image = LAST_CAMERA_IMAGE.write();
*w_image = None; *w_image = None;
break; break;
@ -258,6 +256,7 @@ impl Desktop {
*w_image = Some((out, 0)); *w_image = Some((out, 0));
} }
} }
}
} }
lazy_static! { lazy_static! {