Crates.io | playerone-sdk |
lib.rs | playerone-sdk |
version | 0.2.0 |
source | src |
created_at | 2024-12-09 11:25:48.906631 |
updated_at | 2024-12-09 13:57:45.985275 |
description | PlayerOne SDK bindings |
homepage | |
repository | https://github.com/Uriopass/playerone-sdk-rs |
max_upload_size | |
id | 1477247 |
size | 126,894 |
Wrapper for the Player One Camera SDK.
See examples
for usage.
Here's a minimal one for reference:
pub fn main() {
let camera_description = playerone_sdk::Camera::all_cameras()
.into_iter()
.nth(0)
.expect("No cameras found");
let mut camera = camera_description.open().expect("opening camera");
println!("camera properties:\n{:#?}\n", camera.properties());
let bounds = camera.config_bounds();
println!("camera bounds:\n{:#?}\n", bounds);
camera
.set_image_format(playerone_sdk::ImageFormat::RAW8)
.expect("setting image format");
camera.set_exposure(10000, true).expect("setting exposure");
camera.set_gain(200, true).expect("setting gain");
camera
.set_image_size(
camera.properties().max_width,
camera.properties().max_height,
)
.expect("setting image size");
let mut buffer = camera.create_image_buffer();
camera
.capture(&mut buffer, Some(1000))
.expect("getting frame");
let (w, h) = camera.image_size();
let img: image::GrayImage =
image::ImageBuffer::from_vec(w, h, buffer).expect("converting to image buffer");
img.save("camera_frame.png").expect("saving to file failed");
}