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

Error compiling example code. #143

Open
mostafamshkfides opened this issue Oct 1, 2023 · 2 comments
Open

Error compiling example code. #143

mostafamshkfides opened this issue Oct 1, 2023 · 2 comments

Comments

@mostafamshkfides
Copy link

mostafamshkfides commented Oct 1, 2023

Hey guys,
I'm trying to build and run a simple Cargo project that uses this crate to capture a frame with my laptop camera.
I'm using ubuntu 22.04 LTS as my OS and this is my code in main.rs :

use nokhwa::utils::CameraIndex;
use nokhwa::utils::RequestedFormat;
use nokhwa::pixel_format::RgbFormat;
use nokhwa::utils::RequestedFormatType;
use nokhwa::Camera;


fn main() {

    // 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();

    // 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());
}

But when I run cargo run --release , I got this error :

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotImplementedError("Platform requirements not satisfied. (No Selection)")', src/main.rs:16:52

and I can't figure it out.
I would appreciate it if you can help me.

@RakuJa
Copy link

RakuJa commented Oct 2, 2023

Did you specify in the Cargo.toml the input?
For example

nokhwa = {version = "0.10.4", features = ["input-native"]}

@G0rocks
Copy link

G0rocks commented Feb 20, 2024

I didn't and was getting the error "This operation is not implemented yet: Platform requirements not satisfied. (No Selection)" when running:
// make the camera let mut camera = match Camera::new(camera_index, requested){ Ok(t) => {t}, Err(e) => {println!("Camera creation error:\n{}", e); return;}, };

But adding the input in the cargo.toml file helped, added the answer to grepper, thank you!

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

3 participants