l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
502 stars 121 forks source link

Examples are broken due to breaking changes #95

Closed fre3dm4n closed 1 year ago

fre3dm4n commented 1 year ago

Hi I'm new to both rust and nokhwa (pretty cool library 😸 by the way), so fixing the examples could really help me getting started with this library, thanks

Janik-Haag commented 1 year ago

@r4ve1 did you write a appication with nokhaw yet? I tried to but got a bit frustrated with the example not working and then looked for issues and found this.

GordianDziwis commented 1 year ago
// first camera in system
let index = CameraIndex::Index(0); 
// request the absolute highest resolution CameraFormat that can be decoded to RGB.
let requested = RequestedFormat::new::<RgbFormat>(RequestedFormatType::AbsoluteHighestFrameRate);
// make the camera
let mut camera = Camera::new(index, requested).unwrap();
camera.open_stream().unwrap(); // This line is missing
// get a frame
let frame = camera.frame().unwrap();
println!("Captured Single Frame of {}", frame.buffer().len());
// decode into an ImageBuffer
let decoded = frame.decode_image::<RgbFormat>().unwrap();
println!("Decoded Frame of {}", decoded.len());
fre3dm4n commented 1 year ago

👏 Will try, thanks