use pylon; use std::env; use std::error::Error; fn main() -> Result<(), Box> { pylon::initialize(); let devices = pylon::Device::enumerate_devices()?; println!("Number of devices: {}", devices); let mut dev = pylon::Device::create_device_by_index(0)?; dev.open()?; let s = dev.get_string_feature("DeviceModelName")?; println!("Device: {}", s); let path = env::temp_dir().join("image.jpg"); let frame = dev.grab_single_frame()?; println!("Save to: {}", path.to_string_lossy()); if let pylon::Image::Grey8(img) = frame { println!("Frame: {}x{}", img.width(), img.height()); let img = image::GrayImage::from_vec(img.width() as u32, img.height() as u32, img.buf).unwrap(); img.save(path)?; } Ok(()) }