Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I display images #10

Open
Kofituo opened this issue Oct 13, 2023 · 0 comments
Open

How can I display images #10

Kofituo opened this issue Oct 13, 2023 · 0 comments

Comments

@Kofituo
Copy link

Kofituo commented Oct 13, 2023

I want to know how to decode the images. Here's what I've tried

    let camera = Camera::new_default_device();
    camera.start();

    let Some(frame) = camera.wait_for_frame() else {
        return;
    }; // always blockingly waiting for next new frame
    let (w, h) = frame.size_u32();
    camera.stop(); // or drop it}

    println!("w, h {} {}", w, h);
    let data = frame.data();
    let image = data.data_u8(); // use this buffer, per default in ARGB format
                                 // for real use cases processing or displaying frames can get more complicated when trying to be most efficient
    image::save_buffer(format!("image.jpeg"), image, w, h, image::ColorType::Rgba8).unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant