vzense_rust/
lib.rs

1#![doc = include_str!("../README.md")]
2// #![warn(missing_docs)]
3
4pub mod dcam560;
5pub mod scepter;
6
7pub mod util;
8
9/// 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.
10pub const DEFAULT_RESOLUTION: Resolution = Resolution::new(640, 480);
11
12/// Total number of pixels for `DEFAULT_RESOLUTION`.
13pub const DEFAULT_PIXEL_COUNT: usize = DEFAULT_RESOLUTION.to_pixel_count();
14
15/// Choose RGB or BGR format.
16pub enum ColorFormat {
17    Rgb,
18    Bgr,
19}
20
21/// Possible color resolutions.
22#[derive(PartialEq)]
23pub enum ColorResolution {
24    Res640x480,
25    Res800x600,
26    Res1600x1200,
27}
28
29/// Frame resolution.
30#[derive(PartialEq)]
31pub struct Resolution {
32    width: u32,
33    height: u32,
34}
35impl Resolution {
36    pub const fn new(w: u32, h: u32) -> Self {
37        Self {
38            width: w,
39            height: h,
40        }
41    }
42    pub const fn to_array(&self) -> [u32; 2] {
43        [self.width, self.height]
44    }
45    pub const fn to_tuple(&self) -> (u32, u32) {
46        (self.width, self.height)
47    }
48    pub const fn to_pixel_count(&self) -> usize {
49        (self.width * self.height) as usize
50    }
51    pub const fn double(&self) -> Self {
52        Self {
53            width: 2 * self.width,
54            height: 2 * self.height,
55        }
56    }
57}
58
59/// Possible depth measuring ranges. Only used for DCAM560.
60pub enum DepthMeasuringRange {
61    Near,
62    Mid,
63    Far,
64}
65
66/// red format!
67#[macro_export]
68#[doc(hidden)]
69macro_rules! red {
70    ($($arg:tt)*) => {format!("\x1b[31m{}\x1b[0m", format_args!($($arg)*))}
71}
72/// yellow format!
73#[macro_export]
74#[doc(hidden)]
75macro_rules! yellow {
76    ($($arg:tt)*) => {format!("\x1b[33m{}\x1b[0m", format_args!($($arg)*))}
77}
78/// cyan format!
79#[macro_export]
80#[doc(hidden)]
81macro_rules! cyan {
82    ($($arg:tt)*) => {format!("\x1b[36m{}\x1b[0m", format_args!($($arg)*))}
83}