vzense_rust/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#![doc = include_str!("../README.md")]
// #![warn(missing_docs)]

pub mod dcam560;
pub mod scepter;

pub mod util;

/// The default resolution is 640x480. For depth and IR frames there is only this resolution. The color frame can be set to higher resolutions using `set_color_resolution()`, but the defaults is also 640x480.
pub const DEFAULT_RESOLUTION: Resolution = Resolution::new(640, 480);

/// Total number of pixels for `DEFAULT_RESOLUTION`.
pub const DEFAULT_PIXEL_COUNT: usize = DEFAULT_RESOLUTION.to_pixel_count();

/// Choose RGB or BGR format.
pub enum ColorFormat {
    Rgb,
    Bgr,
}

/// Possible color resolutions.
#[derive(PartialEq)]
pub enum ColorResolution {
    Res640x480,
    Res800x600,
    Res1600x1200,
}

/// Frame resolution.
#[derive(PartialEq)]
pub struct Resolution {
    width: u32,
    height: u32,
}
impl Resolution {
    pub const fn new(w: u32, h: u32) -> Self {
        Self {
            width: w,
            height: h,
        }
    }
    pub const fn to_array(&self) -> [u32; 2] {
        [self.width, self.height]
    }
    pub const fn to_tuple(&self) -> (u32, u32) {
        (self.width, self.height)
    }
    pub const fn to_pixel_count(&self) -> usize {
        (self.width * self.height) as usize
    }
    pub const fn double(&self) -> Self {
        Self {
            width: 2 * self.width,
            height: 2 * self.height,
        }
    }
}

/// Possible depth measuring ranges. Only used for DCAM560.
pub enum DepthMeasuringRange {
    Near,
    Mid,
    Far,
}