mirror of
https://github.com/storytold/cloudcam.git
synced 2026-11-28 09:09:09 +01:00
cleaner
This commit is contained in:
1 parent
85e4050d1e
commit
f672bb5298
2 files changed
+10
-4
No files matched your search
@@ -4,19 +4,24 @@ use crate::capture::capture_buffer::CaptureBuffer;
|
||||
use kinect::{Device, Capture};
|
||||
use std::sync::Arc;
|
||||
|
||||
// TODO(bt): Move to kinect.rs crate.
|
||||
const WAIT_INFINITE : i32 = -1;
|
||||
|
||||
pub struct MultiDeviceCapturer {
|
||||
devices: Vec<Device>,
|
||||
capture_buffer: Arc<CaptureBuffer>,
|
||||
require_color_image: bool,
|
||||
require_depth_image: bool,
|
||||
}
|
||||
|
||||
impl MultiDeviceCapturer {
|
||||
|
||||
pub fn new(devices: Vec<Device>) -> Self {
|
||||
pub fn new(devices: Vec<Device>, require_depth_image: bool, require_color_image: bool) -> Self {
|
||||
Self {
|
||||
capture_buffer: Arc::new(CaptureBuffer::new(devices.len())),
|
||||
devices,
|
||||
require_color_image,
|
||||
require_depth_image,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +49,11 @@ impl MultiDeviceCapturer {
|
||||
for device in self.devices.iter() {
|
||||
let capture = device.get_capture(WAIT_INFINITE)?;
|
||||
|
||||
if capture.get_color_image().is_none() {
|
||||
if self.require_color_image && capture.get_color_image().is_none() {
|
||||
return Err(anyhow!("Capture contains no color image"));
|
||||
}
|
||||
if capture.get_depth_image().is_none() {
|
||||
|
||||
if self.require_depth_image && capture.get_depth_image().is_none() {
|
||||
return Err(anyhow!("Capture contains no depth image"));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ fn main() -> AnyhowResult<()> {
|
||||
camera_infos.push(camera_info);
|
||||
}
|
||||
|
||||
let multi_device_capturer = MultiDeviceCapturer::new(devices);
|
||||
let multi_device_capturer = MultiDeviceCapturer::new(devices, true, true);
|
||||
|
||||
thread::spawn(move || {
|
||||
multi_device_capturer.run_capture_loop()
|
||||
|
||||
Reference in new issue
Block a user