-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_dump.rs
77 lines (67 loc) · 2.79 KB
/
data_dump.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
65
66
67
68
69
70
71
72
73
74
75
76
77
extern crate openni2;
use openni2::{
Device,
Status,
SensorType,
Stream,
OniRGB888Pixel,
OniDepthPixel,
OniGrayscale16Pixel,
Pixel,
// LogLevel,
};
fn interrogate_stream<PixelType: Pixel>(device: &Device, sensor_type: SensorType) {
if let Some(sensor_info) = device.get_sensor_info(sensor_type) {
println!("{:#?}", sensor_info);
if let Ok(mut stream) = device.create_stream(sensor_type) {
dump_stream_data(&stream);
println!("Starting stream: {:?}", stream.start());
{
for _ in 0..5 {
match stream.read_frame::<PixelType>() {
Ok(frame) => println!("Got frame: {:?}", frame),
Err(status) => println!("Couldn't read frame! {}", status),
}
}
}
stream.stop();
println!("Stopping stream.");
}
} else {
println!("Couldn't open {:?} stream", sensor_type);
}
}
fn dump_stream_data(stream: &Stream) {
println!("Cropping: {:?}", stream.get_cropping().ok());
println!("Horizontal FOV: {:?}", stream.get_horizontal_fov().ok());
println!("Vertical FOV: {:?}", stream.get_vertical_fov().ok());
println!("Video Mode: {:?}", stream.get_video_mode().ok());
println!("Max Value: {:?}", stream.get_max_value().ok());
println!("Min Value: {:?}", stream.get_min_value().ok());
println!("Stride: {:?}", stream.get_stride().ok());
println!("Mirroring: {:?}", stream.get_mirroring().ok());
println!("Number of frames: {:?}", stream.get_number_of_frames().ok());
println!("Auto White Balance: {:?}", stream.get_auto_white_balance().ok());
println!("Auto Exposure: {:?}", stream.get_auto_exposure().ok());
println!("Auto Exposure: {:?}", stream.get_auto_exposure().ok());
println!("Exposure: {:?}", stream.get_exposure().ok());
println!("Gain: {:?}", stream.get_gain().ok());
}
fn main() -> Result<(), Status> {
openni2::init()?;
// openni2::set_console_log(true);
// openni2::set_log_level(LogLevel::Verbose);
// Try openni2::Device::open_uri("uri") with a uri string returned
// from openni2::get_device_list()
let device = openni2::Device::open_default()?;
println!("{:?}", device.info());
println!("Firmware Version: {:?}", device.get_firmware_version());
println!("Driver Version: {:?}", device.get_driver_version());
println!("Hardware Version: {:?}", device.get_hardware_version());
println!("Serial No: {:?}", device.get_serial_number());
interrogate_stream::<OniRGB888Pixel>(&device, SensorType::COLOR);
interrogate_stream::<OniDepthPixel>(&device, SensorType::DEPTH);
interrogate_stream::<OniGrayscale16Pixel>(&device, SensorType::IR);
openni2::shutdown();
Ok(())
}